Skip to content

Commit

Permalink
Merge branch 'develop' into careui/forms
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Jan 31, 2023
2 parents ac39a5d + 948a551 commit d79c6d0
Show file tree
Hide file tree
Showing 71 changed files with 1,580 additions and 988 deletions.
10 changes: 0 additions & 10 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ REACT_APP_TITLE="CARE"
REACT_APP_META_DESCRIPTION="CoronaSafe Network is an open-source public utility designed by a multi-disciplinary team of innovators and volunteers. CoronaSafe Care is a Digital Public Good recognised by United Nations."
REACT_APP_COVER_IMAGE=https://cdn.coronasafe.network/care_logo.svg
REACT_APP_COVER_IMAGE_ALT=https://cdn.coronasafe.network/care_logo.svg
REACT_APP_GITHUB_URL=https://github.com/coronasafe
REACT_APP_HEADER_LOGO=https://cdn.coronasafe.network/header_logo.png
REACT_APP_DEPLOYED_URL=care.coronasafe.network
REACT_APP_LIGHT_LOGO=https://cdn.coronasafe.network/light-logo.svg
REACT_APP_LIGHT_COLLAPSE_LOGO=
REACT_APP_BLACK_LOGO=https://cdn.coronasafe.network/black-logo.svg
REACT_APP_RECAPTCHA_SITE_KEY=6LdvxuQUAAAAADDWVflgBqyHGfq-xmvNJaToM0pN
REACT_APP_KASP_ENABLED=false
REACT_APP_KASP_STRING=KASP
REACT_APP_KASP_FULL_STRING="Karunya Arogya Suraksha Padhathi"

# Dev envs
ESLINT_NO_DEV_ERRORS=true
8 changes: 8 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ force = true
from = "/*"
to = "/index.html"
status = 200

[[headers]]
for = "/*"
[headers.values]
cache-control = '''
max-age=0,
no-store'''

7 changes: 6 additions & 1 deletion public/config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"dashboard_url": "https://dashboard.coronasafe.in",
"github_url": "https://github.com/coronasafe",
"coronasafe_url": "https://coronasafe.network?ref=care",
"static_header_logo": "https://cdn.coronasafe.network/header_logo.png",
"static_light_logo": "https://cdn.coronasafe.network/light-logo.svg",
"static_black_logo": "https://cdn.coronasafe.network/black-logo.svg",
"static_dpg_white_logo": "https://digitalpublicgoods.net/wp-content/themes/dpga/images/logo-w.svg",
"static_coronasafe_logo": "https://3451063158-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M233b0_JITp4nk0uAFp%2F-M2Dx6gKxOSU45cjfgNX%2F-M2DxFOkMmkPNn0I6U9P%2FCoronasafe-logo.png?alt=media&token=178cc96d-76d9-4e27-9efb-88f3186368e8",
"gmaps_api_key": "AIzaSyDsBAc3y7deI5ZO3NtK5GuzKwtUzQNJNUk",
"gov_data_api_key": "579b464db66ec23bdd000001cdd3946e44ce4aad7209ff7b23ac571b",
"recaptcha_site_key": "6LdvxuQUAAAAADDWVflgBqyHGfq-xmvNJaToM0pN",
"kasp_enabled": false,
"kasp_string": "KASP",
"kasp_full_string": "Karunya Arogya Suraksha Padhathi",
"state_logo": "https://digitalpublicgoods.net/wp-content/themes/dpga/images/logo.svg"
"sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx",
"sample_format_external_result_import": "https://docs.google.com/spreadsheets/d/17VfgryA6OYSYgtQZeXU9mp7kNvLySeEawvnLBO_1nuE/export?format=csv&id=17VfgryA6OYSYgtQZeXU9mp7kNvLySeEawvnLBO_1nuE"
}
Binary file added public/favicon-dark.ico
Binary file not shown.
Binary file added public/favicon-light.ico
Binary file not shown.
10 changes: 5 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta property="og:title" content="%REACT_APP_TITLE%" />
<meta property="og:description" content="%REACT_APP_META_DESCRIPTION%" />
<meta property="og:image" content="%REACT_APP_COVER_IMAGE%"" />
<meta property="og:url" content="https://care.coronasafe.network/" />
<meta property=" og:url" content="https://care.coronasafe.network/" />
<meta property="og:site_name" content="Care CoronaSafe Network." />
<meta name="twitter:title" content="CARE" />
<meta name="twitter:description"
Expand All @@ -23,13 +23,13 @@
<meta name="apple-mobile-web-app-title" content="Care" />
<link rel="apple-touch-icon" href="https://cdn.coronasafe.network/care-manifest/images/icons/icon-192x192.png" />
<meta name="theme-color" content="#33BB17" />
<link rel="shortcut icon" href="https://cdn.coronasafe.network/care-manifest/images/icons/favicon.ico"
type="image/x-icon" />
<link rel="icon" href="https://cdn.coronasafe.network/care-manifest/images/icons/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon-dark.ico" type="image/x-icon" />
<link rel="icon" href="/favicon-dark.ico" type="image/x-icon" />
<link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet">
</head>

<body>
Expand Down
18 changes: 17 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useDispatch, useSelector } from "react-redux";
import { getConfig, getCurrentUser } from "./Redux/actions";
import { useAbortableEffect, statusType } from "./Common/utils";
import axios from "axios";
import { HistoryAPIProvider } from "./CAREUI/misc/HistoryAPIProvider";

const Loading = loadable(() => import("./Components/Common/Loading"));

Expand Down Expand Up @@ -57,6 +58,17 @@ const App: React.FC = () => {
[dispatch]
);

useEffect(() => {
const darkThemeMq = window.matchMedia("(prefers-color-scheme: dark)");
const favicon: any = document.querySelector("link[rel~='icon']");
console.log(favicon);
if (darkThemeMq.matches) {
favicon.href = "/favicon-light.ico";
} else {
favicon.href = "/favicon-dark.ico";
}
}, []);

if (
!currentUser ||
currentUser.isFetching ||
Expand All @@ -68,7 +80,11 @@ const App: React.FC = () => {
}

if (currentUser?.data) {
return <AppRouter />;
return (
<HistoryAPIProvider>
<AppRouter />
</HistoryAPIProvider>
);
} else {
return <SessionRouter />;
}
Expand Down
38 changes: 38 additions & 0 deletions src/CAREUI/misc/HistoryAPIProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useLocationChange } from "raviger";
import { createContext, ReactNode, useState } from "react";

export const HistoryContext = createContext<string[]>([]);
// eslint-disable-next-line @typescript-eslint/no-empty-function
export const ResetHistoryContext = createContext(() => {});

export const HistoryAPIProvider = (props: { children: ReactNode }) => {
const [history, setHistory] = useState<string[]>([]);

useLocationChange(
(newLocation) => {
setHistory((history) => {
if (history.length && newLocation.fullPath === history[0])
// Ignore push if navigate to same path (for some weird unknown reasons?)
return history;

if (history.length > 1 && newLocation.fullPath === history[1])
// Pop current path if navigate back to previous path
return history.slice(1);

// Otherwise just push the current path
return [newLocation.fullPath, ...history];
});
},
{ onInitial: true }
);

const resetHistory = () => setHistory((history) => history.slice(0, 1));

return (
<HistoryContext.Provider value={history}>
<ResetHistoryContext.Provider value={resetHistory}>
{props.children}
</ResetHistoryContext.Provider>
</HistoryContext.Provider>
);
};
63 changes: 36 additions & 27 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PatientCategory } from "../Components/Facility/models";
import { parsePhoneNumberFromString } from "libphonenumber-js";
import moment from "moment";
import { IConfig } from "./hooks/useConfig";

export const KeralaLogo = "images/kerala-logo.png";

Expand All @@ -13,10 +14,6 @@ export interface OptionsType {
disabled?: boolean;
}

export const KASP_STRING = process.env.REACT_APP_KASP_STRING ?? "";
export const KASP_FULL_STRING = process.env.REACT_APP_KASP_FULL_STRING ?? "";
export const KASP_ENABLED = process.env.REACT_APP_KASP_ENABLED === "true";

export type UserRole =
| "Pharmacist"
| "Volunteer"
Expand Down Expand Up @@ -168,28 +165,33 @@ export const PATIENT_FILTER_ORDER: (OptionsType & { order: string })[] = [
{ id: 6, text: "-review_time", desc: "Review Time", order: "Descending" },
];

const KASP_BED_TYPES = KASP_ENABLED
? [
{ id: 40, text: KASP_STRING + " Ordinary Beds" },
{ id: 60, text: KASP_STRING + " Oxygen beds" },
{ id: 50, text: KASP_STRING + " ICU (ICU without ventilator)" },
{ id: 70, text: KASP_STRING + " ICU (ICU with ventilator)" },
]
: [];

export const BED_TYPES: Array<OptionsType> = [
{ id: 1, text: "Non-Covid Ordinary Beds" },
{ id: 150, text: "Non-Covid Oxygen beds" },
{ id: 10, text: "Non-Covid ICU (ICU without ventilator)" },
{ id: 20, text: "Non-Covid Ventilator (ICU with ventilator)" },
{ id: 30, text: "Covid Ordinary Beds" },
{ id: 120, text: "Covid Oxygen beds" },
{ id: 110, text: "Covid ICU (ICU without ventilator)" },
{ id: 100, text: "Covid Ventilators (ICU with ventilator)" },
...KASP_BED_TYPES,
{ id: 2, text: "Hostel" },
{ id: 3, text: "Single Room with Attached Bathroom" },
];
export const getBedTypes = ({
kasp_enabled,
kasp_string,
}: Pick<IConfig, "kasp_enabled" | "kasp_string">) => {
const kaspBedTypes = kasp_enabled
? [
{ id: 40, text: kasp_string + " Ordinary Beds" },
{ id: 60, text: kasp_string + " Oxygen beds" },
{ id: 50, text: kasp_string + " ICU (ICU without ventilator)" },
{ id: 70, text: kasp_string + " ICU (ICU with ventilator)" },
]
: [];

return [
{ id: 1, text: "Non-Covid Ordinary Beds" },
{ id: 150, text: "Non-Covid Oxygen beds" },
{ id: 10, text: "Non-Covid ICU (ICU without ventilator)" },
{ id: 20, text: "Non-Covid Ventilator (ICU with ventilator)" },
{ id: 30, text: "Covid Ordinary Beds" },
{ id: 120, text: "Covid Oxygen beds" },
{ id: 110, text: "Covid ICU (ICU without ventilator)" },
{ id: 100, text: "Covid Ventilators (ICU with ventilator)" },
...kaspBedTypes,
{ id: 2, text: "Hostel" },
{ id: 3, text: "Single Room with Attached Bathroom" },
];
};

export const DOCTOR_SPECIALIZATION: Array<OptionsType> = [
{ id: 1, text: "General Medicine", desc: "bg-doctors-general" },
Expand Down Expand Up @@ -282,6 +284,14 @@ export const CONSULTATION_SUGGESTION = [
{ id: "DD", text: "Declare Death" },
];

export const CONSULTATION_STATUS = [
{ id: "1", text: "Brought Dead" },
{ id: "2", text: "Transferred from ward" },
{ id: "3", text: "Transferred from ICU" },
{ id: "4", text: "Referred from other hospital" },
{ id: "5", text: "Out-patient (walk in)" },
];

export const ADMITTED_TO = [
{ id: "1", text: "Isolation" },
{ id: "2", text: "ICU" },
Expand Down Expand Up @@ -367,7 +377,6 @@ export const DISEASE_STATUS = [
"SUSPECTED",
"NEGATIVE",
"RECOVERED",
"EXPIRED",
];

export const TEST_TYPE = [
Expand Down
6 changes: 0 additions & 6 deletions src/Common/env.tsx

This file was deleted.

26 changes: 26 additions & 0 deletions src/Common/hooks/useAppHistory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { navigate } from "raviger";
import { useContext } from "react";
import {
HistoryContext,
ResetHistoryContext,
} from "../../CAREUI/misc/HistoryAPIProvider";

export default function useAppHistory() {
const history = useContext(HistoryContext);
const resetHistory = useContext(ResetHistoryContext);

const goBack = (fallbackUrl?: string) => {
if (history.length > 1)
// Navigate to history present in the app navigation history stack.
return navigate(history[1]);

if (fallbackUrl)
// Otherwise, use provided fallback url if provided.
return navigate(fallbackUrl);

// Otherwise, fallback to browser's go back behaviour.
window.history.back();
};

return { history, resetHistory, goBack };
}
47 changes: 39 additions & 8 deletions src/Common/hooks/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,45 @@ import { useSelector } from "react-redux";

export interface IConfig {
dashboard_url: string;
// gmaps_api_key?: string;
// sentry_api_key?: string;
// recaptcha_site_key?: string;

// KASP related
// kasp_label?: string;
// kasp_long_label?: string;
// kasp_enabled?: boolean;
github_url: string;
coronasafe_url: string;
dpg_url: string;
static_header_logo: string;
static_light_logo: string;
static_black_logo: string;
/**
* White logo of Digital Public Goods.
*/
static_dpg_white_logo: string;
static_coronasafe_logo: string;
/**
* The API key for the Google Maps API used for location picker.
*/
gmaps_api_key: string;
/**
* The API key for the data.gov.in API used for pincode auto-complete.
*/
gov_data_api_key: string;
recaptcha_site_key: string;
kasp_enabled: boolean;
kasp_string: string;
kasp_full_string: string;
/**
* If present, the image will be displayed in the login page.
*/
state_logo?: string;
/**
* If true, the state logo will be white by applying "invert brightness-0" classes.
*/
state_logo_white?: boolean;
/**
* URL of the sample format for asset import.
*/
sample_format_asset_import: string;
/**
* URL of the sample format for external result import.
*/
sample_format_external_result_import: string;
}

const useConfig = () => {
Expand Down
Loading

0 comments on commit d79c6d0

Please sign in to comment.