-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'issues/8687/camera-permissions' of https://github.com/s…
…hauryag2002/care_fe into issues/8687/camera-permissions
- Loading branch information
Showing
13 changed files
with
114 additions
and
35 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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import Sentry from "./Sentry"; | ||
import Plausible from "./Plausible"; | ||
|
||
const Intergrations = { Sentry, Plausible }; | ||
const Integrations = { Sentry, Plausible }; | ||
|
||
export default Intergrations; | ||
export default Integrations; |
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,29 +1,13 @@ | ||
# Contributing Translation | ||
# Contributing Translations | ||
|
||
### For adding a new language | ||
|
||
<br> | ||
## Adding a new language | ||
|
||
- Open the Terminal and `cd` to `care_fe/src/Locale` | ||
- Run the command `node update_locale.js <LANG_CODE>` | ||
Eg: `node update_locale.js ml` for Malayalam | ||
- The command will create a directory with default locale files and you can start translating them. | ||
- The command will create a directory with default locale files. | ||
- After it's done, add the new language to `care_fe/src/Locale/config.ts` file. | ||
|
||
### For improving the existing language | ||
|
||
<br> | ||
|
||
- Open the Terminal and `cd` to `care_fe/src/Locale` | ||
- Run the command `node update_locale.js <LANG_CODE>` | ||
Eg: `node update_locale.js ml` for Malayalam | ||
- The command will update the new keys which are yet to be translated. | ||
- You can now start translating or improving it. | ||
|
||
## Note | ||
|
||
⚠ - If you are adding a new word, then please add it to the Default Locale (EN) first and then proceed with your language. | ||
|
||
⚠ - After translating, have a look at its appearance. It may be overflowing or cause some UI breaks. Try to adjust the words such that it fits the UI. | ||
|
||
⚠ - Try to separate the translation files for each module like `Facility`, `Patient` and more. Don't dump all the keys in one JSON 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { createContext, useContext, useState, useEffect } from "react"; | ||
import useQuery from "./request/useQuery"; | ||
import routes from "../Redux/api"; | ||
import useAuthUser from "../Common/hooks/useAuthUser"; | ||
import { FacilityModel } from "../Components/Facility/models"; | ||
|
||
export type FeatureFlag = "SCRIBE_ENABLED"; // "HCX_ENABLED" | "ABDM_ENABLED" | | ||
|
||
export interface FeatureFlagsResponse { | ||
user_flags: FeatureFlag[]; | ||
facility_flags: { | ||
facility: string; | ||
features: FeatureFlag[]; | ||
}[]; | ||
} | ||
|
||
const defaultFlags: FeatureFlag[] = []; | ||
|
||
const FeatureFlagsContext = createContext<FeatureFlagsResponse>({ | ||
user_flags: defaultFlags, | ||
facility_flags: [], | ||
}); | ||
|
||
export const FeatureFlagsProvider = (props: { children: React.ReactNode }) => { | ||
const [featureFlags, setFeatureFlags] = useState<FeatureFlagsResponse>({ | ||
user_flags: defaultFlags, | ||
facility_flags: [], | ||
}); | ||
|
||
const user = useAuthUser(); | ||
|
||
useEffect(() => { | ||
if (user.user_flags) { | ||
setFeatureFlags((ff) => ({ | ||
...ff, | ||
user_flags: [...defaultFlags, ...(user.user_flags || [])], | ||
})); | ||
} | ||
}, [user]); | ||
|
||
return ( | ||
<FeatureFlagsContext.Provider value={featureFlags}> | ||
{props.children} | ||
</FeatureFlagsContext.Provider> | ||
); | ||
}; | ||
|
||
export const useFeatureFlags = (facility?: FacilityModel | string) => { | ||
const [facilityObject, setFacilityObject] = useState< | ||
FacilityModel | undefined | ||
>(typeof facility === "string" ? undefined : facility); | ||
|
||
const context = useContext(FeatureFlagsContext); | ||
if (context === undefined) { | ||
throw new Error( | ||
"useFeatureFlags must be used within a FeatureFlagsProvider", | ||
); | ||
} | ||
|
||
const facilityQuery = useQuery(routes.getPermittedFacility, { | ||
pathParams: { | ||
id: typeof facility === "string" ? facility : "", | ||
}, | ||
prefetch: false, | ||
silent: true, | ||
onResponse: (res) => { | ||
setFacilityObject(res.data); | ||
}, | ||
}); | ||
|
||
const facilityFlags = facilityObject?.facility_flags || []; | ||
|
||
useEffect(() => { | ||
facilityQuery.refetch(); | ||
}, [facility]); | ||
|
||
return [...context.user_flags, ...facilityFlags]; | ||
}; |