forked from ohcnetwork/care_fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'fgp/develop' into issues/9308/unnecessa…
…ryAPIcallsAndRerenders
- Loading branch information
Showing
266 changed files
with
10,446 additions
and
10,318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
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 || '' }} | ||
|
||
steps: | ||
- name: Check and Notify | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
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(Boolean); | ||
if (labels.length > 0) { | ||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.issue.number, | ||
labels: labels | ||
}); | ||
} | ||
}; | ||
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(`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; | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,4 @@ cypress/fixtures/token.json | |
# Care Apps | ||
/apps/* | ||
src/pluginMap.ts | ||
/apps_backup/* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v20 | ||
v22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.