Skip to content

Commit

Permalink
Merge branch 'develop' into issues/8683/lab-orders
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-learner committed Dec 10, 2024
2 parents 8806e57 + b25ecd0 commit 0bd7f74
Show file tree
Hide file tree
Showing 156 changed files with 5,917 additions and 4,086 deletions.
42 changes: 27 additions & 15 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
Care is a React Typescript Project, built with Vite and styled with TailwindCSS.
You are an expert in TypeScript, React, Shadcn UI, Tailwind.

Care uses a Plugin Architecture. Apps are installed in /apps.
Key Principles

Care uses a custom useQuery hook to fetch data from the API. APIs are defined in the api.tsx file
- Write concise, technical TypeScript code with accurate examples.
- Use functional and declarative programming patterns; avoid classes.
- Prefer iteration and modularization over code duplication.
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).

Here's an example of how to use the useQuery hook to fetch data from the API:
Naming Conventions

```
useQuery from "@/common/hooks/useQuery";
const { data, loading, error } = useQuery(routes.getFacilityUsers, {
facility_id: "1",
});
- Use lowercase with dashes for directories (e.g., components/auth-wizard).
- Favor named exports for components.

request from "@/common/utils/request";
const { res } = await request(routes.partialUpdateAsset, {
pathParams: { external_id: assetId },
body: data,
});
```
TypeScript Usage

- Use TypeScript for all code; prefer interfaces over types.
- Avoid enums; use maps instead.
- Use functional components with TypeScript interfaces.

Syntax and Formatting

- Use the "function" keyword for pure functions.
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
- Use declarative JSX.

UI and Styling

- Use Shadcn UI, Radix, and Tailwind for components and styling.
- Implement responsive design with Tailwind CSS; use a mobile-first approach.

General Guidelines

- Care uses a custom useQuery hook to fetch data from the API. (Docs @ /Utils/request/useQuery)
- APIs are defined in the api.tsx file.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
5 changes: 3 additions & 2 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
containers: [1, 2, 3, 4]
env:
REACT_CARE_API_URL: http://localhost:9000
REACT_ENABLED_APPS: "ohcnetwork/care_hcx_fe@main"
REACT_ENABLED_APPS: "ohcnetwork/care_hcx_fe@main,ohcnetwork/care_abdm_fe@main"
REACT_ENABLE_HCX: true
REACT_ENABLE_ABDM: true
steps:
- name: Checkout 📥
uses: actions/checkout@v3
Expand Down Expand Up @@ -135,4 +136,4 @@ jobs:
if: ${{ failure() && steps.pr_origin.outputs.is_forked == 'true' }}
with:
name: cypress-videos
path: cypress/videos
path: cypress/videos
95 changes: 48 additions & 47 deletions .github/workflows/notify-non-core-qn.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
name: Notify Core Team on Non-Core Questions

on:
issue_comment:
types: [created]

permissions:
issues: write
pull-requests: write

jobs:
notify_core_team:
runs-on: ubuntu-latest
env:
ALLOWED_USERNAMES: ${{ vars.ALLOWED_USERNAMES }}
QUESTION_KEYWORDS: ${{ vars.QUESTION_KEYWORDS }}
QUESTION_LABELS: ${{ vars.QUESTION_LABELS }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
ALLOWED_USERNAMES: ${{ vars.ALLOWED_USERNAMES || '' }}
QUESTION_KEYWORDS: ${{ vars.QUESTION_KEYWORDS || '' }}
QUESTION_LABELS: ${{ vars.QUESTION_LABELS || '' }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK || '' }}

steps:
- name: Check and Notify
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log('Script started');
const isOrgMember = (commenter, allowedUsers) => {
return allowedUsers.split(',').map(u => u.trim()).includes(commenter);
};
const containsQuestionKeywords = (text, keywords) => {
return keywords.split(',').map(k => k.trim()).some(keyword =>
const isOrgMember = (commenter, allowedUsers) =>
allowedUsers.split(',').map(u => u.trim()).includes(commenter);
const containsQuestionKeywords = (text, keywords) =>
keywords.split(',').map(k => k.trim()).some(keyword =>
text.toLowerCase().includes(keyword.toLowerCase())
);
};
const addLabelsToIssue = async (github, context, labelsString) => {
const labels = labelsString.split(',').map(label => label.trim()).filter(label => label);
const labels = labelsString.split(',').map(label => label.trim()).filter(Boolean);
if (labels.length > 0) {
console.log('Adding labels:', labels);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -40,48 +42,47 @@ jobs:
});
}
};
const sendSlackNotification = async (webhook, payload) => {
const sendSlackNotification = async (webhook, commentUrl) => {
const payload = { commentUrl };
const response = await fetch(webhook, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
throw new Error(`Slack notification failed with status: ${response.status}`);
}
};
const isBot = async (github, commenter) => {
try {
const { data: user } = await github.rest.users.getByUsername({ username: commenter });
return user.type === 'Bot';
} catch {
return false;
}
};
const commenter = context.payload.comment.user.login;
console.log('Commenter:', commenter);
if (!isOrgMember(commenter, process.env.ALLOWED_USERNAMES)) {
const commentBody = context.payload.comment.body;
const sanitizedComment = commentBody
?.replace(/[^\w\s?]/gi, '')
.toLowerCase();
console.log('Comment body:', sanitizedComment);
if (containsQuestionKeywords(sanitizedComment, process.env.QUESTION_KEYWORDS)) {
try {
console.log('Adding labels to the issue');
await addLabelsToIssue(github, context, process.env.QUESTION_LABELS);
console.log('Labels added successfully');
const issueUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/issues/${context.payload.issue.number}`;
const issueTitle = context.payload.issue.title;
const issueNumber = context.payload.issue.number;
console.log('Issue URL:', issueUrl);
console.log('Issue Title:', issueTitle);
console.log('Issue Number:', issueNumber);
const payload = {
link: issueUrl,
Question: commentBody,
"issue-number": issueNumber,
title: issueTitle,
user: commenter
};
await sendSlackNotification(process.env.SLACK_WEBHOOK, payload);
console.log('Slack notification sent successfully');
} catch (error) {
console.error('Workflow failed:', error.message);
core.setFailed(`Workflow failed: ${error.message}`);
const allowedUsers = process.env.ALLOWED_USERNAMES;
const keywords = process.env.QUESTION_KEYWORDS;
const labels = process.env.QUESTION_LABELS;
const webhook = process.env.SLACK_WEBHOOK;
if (await isBot(github, commenter)) return;
if (allowedUsers && !isOrgMember(commenter, allowedUsers)) {
const commentBody = context.payload.comment.body.trim();
const filteredCommentBody = commentBody.split('\n').filter(line => !line.startsWith('>')).join('\n');
if (keywords && containsQuestionKeywords(filteredCommentBody, keywords)) {
if (labels) {
await addLabelsToIssue(github, context, labels);
}
if (webhook) {
const commentUrl = context.payload.comment.html_url;
await sendSlackNotification(webhook, commentUrl);
}
}
}
console.log('Script ended');
26 changes: 10 additions & 16 deletions .github/workflows/thank-you.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,20 @@ jobs:
uses: actions/[email protected]
with:
script: |
const thankyouNote = 'Your efforts have helped advance digital healthcare and TeleICU systems. :rocket: Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! :raised_hands:'
const thankyouNote = 'Your efforts have helped advance digital healthcare and TeleICU systems. :rocket: Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! :raised_hands:';
const options = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
}
};
const result = await github.rest.issues.get({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
const { assignees, user } = result.data
const { data : { assignees, user } } = await github.rest.issues.get(options);
const assignees_tagged = assignees.map((user) => '@' + user.login).join(' ')
const owner_tagged = '@' + user.login
const taggedUsers = [...new Set(
assignees.map(u => "@"+u.login).concat("@"+user.login)
)].join(" ")
if (assignees.length == 0) {
await github.rest.issues.createComment({ ...options, body: `${owner_tagged} ${thankyouNote}` })
} else {
await github.rest.issues.createComment({ ...options, body: `${assignees_tagged} ${owner_tagged} ${thankyouNote}` })
}
await github.rest.issues.createComment({
...options,
body: `${taggedUsers} ${thankyouNote}`
});
5 changes: 3 additions & 2 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
files:
- source: /src/Locale/en/*.json
translation: /src/Locale/%two_letters_code%/%original_file_name%
- source: /public/locale/{{lang}}.json
translation: /public/locale/%two_letters_code%/%original_file_name%
bundles:
- 2

Loading

0 comments on commit 0bd7f74

Please sign in to comment.