diff --git a/src/Routers/AppRouter.tsx b/src/Routers/AppRouter.tsx index 4030238eb3f..abf351764d7 100644 --- a/src/Routers/AppRouter.tsx +++ b/src/Routers/AppRouter.tsx @@ -25,11 +25,25 @@ import ShiftingRoutes from "./routes/ShiftingRoutes"; import AssetRoutes from "./routes/AssetRoutes"; import ResourceRoutes from "./routes/ResourceRoutes"; import ExternalResultRoutes from "./routes/ExternalResultRoutes"; -import { DetailRoute } from "./types"; import useAuthUser from "../Common/hooks/useAuthUser"; import careConfig from "@careConfig"; -const Routes = { +export type RouteParams = + T extends `${string}:${infer Param}/${infer Rest}` + ? { [K in Param | keyof RouteParams]: string } + : T extends `${string}:${infer Param}` + ? { [K in Param]: string } + : Record; + +export type RouteFunction = ( + params: RouteParams, +) => JSX.Element; + +export type AppRoutes = { + [K in string]: RouteFunction; +}; + +const Routes: AppRoutes = { "/": () => , ...AssetRoutes, @@ -41,15 +55,13 @@ const Routes = { ...ShiftingRoutes, ...UserRoutes, - "/notifications/:id": ({ id }: DetailRoute) => ( - - ), + "/notifications/:id": ({ id }) => , "/notice_board": () => , - "/abdm/health-information/:id": ({ id }: { id: string }) => ( + "/abdm/health-information/:id": ({ id }) => ( ), - "/facility/:facilityId/abdm": ({ facilityId }: any) => ( + "/facility/:facilityId/abdm": ({ facilityId }) => ( ), diff --git a/src/Routers/routes/AssetRoutes.tsx b/src/Routers/routes/AssetRoutes.tsx index d3bd96ca437..ee0537d6c58 100644 --- a/src/Routers/routes/AssetRoutes.tsx +++ b/src/Routers/routes/AssetRoutes.tsx @@ -2,20 +2,23 @@ import AssetConfigure from "../../Components/Assets/AssetConfigure"; import AssetManage from "../../Components/Assets/AssetManage"; import AssetsList from "../../Components/Assets/AssetsList"; import AssetCreate from "../../Components/Facility/AssetCreate"; +import { AppRoutes } from "../AppRouter"; -export default { +const AssetRoutes: AppRoutes = { "/assets": () => , - - "/facility/:facilityId/assets/new": (params: any) => ( - - ), - "/facility/:facilityId/assets/:assetId/update": (params: any) => ( - + "/facility/:facilityId/assets/new": ({ facilityId }) => ( + ), - "/facility/:facilityId/assets/:assetId": (params: any) => ( - + "/facility/:facilityId/assets/:assetId/update": ({ facilityId, assetId }) => ( + ), - "/facility/:facilityId/assets/:assetId/configure": (params: any) => ( - + "/facility/:facilityId/assets/:assetId": ({ facilityId, assetId }) => ( + ), + "/facility/:facilityId/assets/:assetId/configure": ({ + facilityId, + assetId, + }) => , }; + +export default AssetRoutes; diff --git a/src/Routers/routes/ConsultationRoutes.tsx b/src/Routers/routes/ConsultationRoutes.tsx index 598fd06adc3..77efe1081bc 100644 --- a/src/Routers/routes/ConsultationRoutes.tsx +++ b/src/Routers/routes/ConsultationRoutes.tsx @@ -5,30 +5,29 @@ import ManagePrescriptions from "../../Components/Medicine/ManagePrescriptions"; import { DailyRoundListDetails } from "../../Components/Patient/DailyRoundListDetails"; import { DailyRounds } from "../../Components/Patient/DailyRounds"; import { ConsultationDetails } from "../../Components/Facility/ConsultationDetails"; -import TreatmentSummary, { - ITreatmentSummaryProps, -} from "../../Components/Facility/TreatmentSummary"; +import TreatmentSummary from "../../Components/Facility/TreatmentSummary"; import ConsultationDoctorNotes from "../../Components/Facility/ConsultationDoctorNotes"; import PatientConsentRecords from "../../Components/Patient/PatientConsentRecords"; import CriticalCareEditor from "../../Components/LogUpdate/CriticalCareEditor"; import PrescriptionsPrintPreview from "../../Components/Medicine/PrintPreview"; import CriticalCarePreview from "../../Components/LogUpdate/CriticalCarePreview"; import FileUploadPage from "../../Components/Patient/FileUploadPage"; +import { AppRoutes } from "../AppRouter"; -export default { +const consultationRoutes: AppRoutes = { "/facility/:facilityId/patient/:patientId/consultation": ({ facilityId, patientId, - }: any) => , + }) => , "/facility/:facilityId/patient/:patientId/consultation/:id/update": ({ facilityId, patientId, id, - }: any) => ( + }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:id/consent-records": - ({ facilityId, patientId, id }: any) => ( + ({ facilityId, patientId, id }) => ( ( + }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/prescriptions": - (path: any) => , + (path) => , "/facility/:facilityId/patient/:patientId/consultation/:consultationId/prescriptions/print": () => , "/facility/:facilityId/patient/:patientId/consultation/:id/investigation": ({ facilityId, patientId, id, - }: any) => ( + }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:id/investigation/:sessionId": - ({ facilityId, patientId, id, sessionId }: any) => ( + ({ facilityId, patientId, id, sessionId }) => ( ( + }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily-rounds/:id/update": - ({ facilityId, patientId, consultationId, id }: any) => ( + ({ facilityId, patientId, consultationId, id }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily-rounds/:id": - ({ facilityId, patientId, consultationId, id }: any) => ( + ({ facilityId, patientId, consultationId, id }) => ( ), - "/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily_rounds/:id": - (params: { - facilityId: string; - patientId: string; - consultationId: string; - id: string; - }) => , + ({ facilityId, patientId, consultationId, id }) => ( + + ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily_rounds/:id/update": - (params: { - facilityId: string; - patientId: string; - consultationId: string; - id: string; - }) => , + ({ facilityId, patientId, consultationId, id }) => ( + + ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId": ({ facilityId, patientId, consultationId, - }: any) => ( + }) => ( ), - "/consultation/:consultationId": ({ consultationId }: any) => ( + "/consultation/:consultationId": ({ consultationId }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/treatment-summary": - ({ facilityId, patientId, consultationId }: ITreatmentSummaryProps) => ( + ({ facilityId, patientId, consultationId }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/notes": - ({ facilityId, patientId, consultationId }: any) => ( + ({ facilityId, patientId, consultationId }) => ( ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/:tab": - ({ facilityId, patientId, consultationId, tab }: any) => ( + ({ facilityId, patientId, consultationId, tab }) => ( ), }; + +export default consultationRoutes; diff --git a/src/Routers/routes/ExternalResultRoutes.tsx b/src/Routers/routes/ExternalResultRoutes.tsx index b6bc71a2808..1932f48ad66 100644 --- a/src/Routers/routes/ExternalResultRoutes.tsx +++ b/src/Routers/routes/ExternalResultRoutes.tsx @@ -1,12 +1,12 @@ import ResultItem from "../../Components/ExternalResult/ResultItem"; import ResultList from "../../Components/ExternalResult/ResultList"; import ResultUpdate from "../../Components/ExternalResult/ResultUpdate"; -import { DetailRoute } from "../types"; +import { AppRoutes } from "../AppRouter"; -export default { +const ExternalResultRoutes: AppRoutes = { "/external_results": () => , - "/external_results/:id": ({ id }: DetailRoute) => , - "/external_results/:id/update": ({ id }: DetailRoute) => ( - - ), + "/external_results/:id": ({ id }) => , + "/external_results/:id/update": ({ id }) => , }; + +export default ExternalResultRoutes; diff --git a/src/Routers/routes/FacilityInventoryRoutes.tsx b/src/Routers/routes/FacilityInventoryRoutes.tsx index 17e93b2bc60..99123d8f737 100644 --- a/src/Routers/routes/FacilityInventoryRoutes.tsx +++ b/src/Routers/routes/FacilityInventoryRoutes.tsx @@ -3,22 +3,25 @@ import InventoryList from "../../Components/Facility/InventoryList"; import InventoryLog from "../../Components/Facility/InventoryLog"; import MinQuantityList from "../../Components/Facility/MinQuantityList"; import { SetInventoryForm } from "../../Components/Facility/SetInventoryForm"; +import { AppRoutes } from "../AppRouter"; -export default { - "/facility/:facilityId/inventory": ({ facilityId }: any) => ( +const FacilityInventoryRoutes: AppRoutes = { + "/facility/:facilityId/inventory": ({ facilityId }) => ( ), - "/facility/:facilityId/inventory/min_quantity/set": ({ facilityId }: any) => ( + "/facility/:facilityId/inventory/min_quantity/set": ({ facilityId }) => ( ), - "/facility/:facilityId/inventory/min_quantity/list": ({ - facilityId, - }: any) => , - "/facility/:facilityId/inventory/min_quantity": ({ facilityId }: any) => ( + "/facility/:facilityId/inventory/min_quantity/list": ({ facilityId }) => ( + + ), + "/facility/:facilityId/inventory/min_quantity": ({ facilityId }) => ( ), "/facility/:facilityId/inventory/:inventoryId": ({ facilityId, inventoryId, - }: any) => , + }) => , }; + +export default FacilityInventoryRoutes; diff --git a/src/Routers/routes/FacilityLocationRoutes.tsx b/src/Routers/routes/FacilityLocationRoutes.tsx index 5d547ebd466..c2e1add4b10 100644 --- a/src/Routers/routes/FacilityLocationRoutes.tsx +++ b/src/Routers/routes/FacilityLocationRoutes.tsx @@ -6,41 +6,42 @@ import LocationManagement from "../../Components/Facility/LocationManagement"; import CentralLiveMonitoring from "../../Components/CameraFeed/CentralLiveMonitoring"; import { AuthorizeUserRoute } from "../../Utils/AuthorizeFor"; import { CameraFeedPermittedUserTypes } from "../../Utils/permissions"; +import { AppRoutes } from "../AppRouter"; -export default { - "/facility/:facilityId/location": ({ facilityId }: any) => ( +const FacilityLocationRoutes: AppRoutes = { + "/facility/:facilityId/location": ({ facilityId }) => ( ), "/facility/:facilityId/location/:locationId/beds": ({ facilityId, locationId, - }: any) => , - "/facility/:facilityId/inventory/add": ({ facilityId }: any) => ( + }) => , + "/facility/:facilityId/inventory/add": ({ facilityId }) => ( ), - "/facility/:facilityId/location/add": ({ facilityId }: any) => ( + "/facility/:facilityId/location/add": ({ facilityId }) => ( ), "/facility/:facilityId/location/:locationId/update": ({ facilityId, locationId, - }: any) => ( - - ), + }) => , "/facility/:facilityId/location/:locationId/beds/add": ({ facilityId, locationId, - }: any) => , + }) => , "/facility/:facilityId/location/:locationId/beds/:bedId/update": ({ facilityId, locationId, bedId, - }: any) => ( + }) => ( ), - "/facility/:facilityId/live-monitoring": (props: any) => ( + "/facility/:facilityId/live-monitoring": ({ facilityId }) => ( - + ), }; + +export default FacilityLocationRoutes; diff --git a/src/Routers/routes/FacilityRoutes.tsx b/src/Routers/routes/FacilityRoutes.tsx index 2c711cf48cb..220a90a65ed 100644 --- a/src/Routers/routes/FacilityRoutes.tsx +++ b/src/Routers/routes/FacilityRoutes.tsx @@ -9,41 +9,40 @@ import CentralNursingStation from "../../Components/Facility/CentralNursingStati import FacilityLocationRoutes from "./FacilityLocationRoutes"; import FacilityInventoryRoutes from "./FacilityInventoryRoutes"; import DischargedPatientsList from "../../Components/Facility/DischargedPatientsList"; +import { AppRoutes } from "../AppRouter"; -export default { +const FacilityRoutes: AppRoutes = { "/facility": () => , "/facility/create": () => , - "/facility/:facilityId/update": ({ facilityId }: any) => ( + "/facility/:facilityId/update": ({ facilityId }) => ( ), - "/facility/:facilityId/configure": ({ facilityId }: any) => ( + "/facility/:facilityId/configure": ({ facilityId }) => ( ), - "/facility/:facilityId/cns": ({ facilityId }: any) => ( + "/facility/:facilityId/cns": ({ facilityId }) => ( ), - "/facility/:facilityId": ({ facilityId }: any) => ( + "/facility/:facilityId": ({ facilityId }) => ( ), - "/facility/:id/discharged-patients": ({ id }: any) => ( + "/facility/:id/discharged-patients": ({ id }) => ( ), - - "/facility/:facilityId/users": ({ facilityId }: any) => ( + "/facility/:facilityId/users": ({ facilityId }) => ( ), - "/facility/:facilityId/resource/new": ({ facilityId }: any) => ( + "/facility/:facilityId/resource/new": ({ facilityId }) => ( ), - - // Triage related routes - "/facility/:facilityId/triage": ({ facilityId }: any) => ( + "/facility/:facilityId/triage": ({ facilityId }) => ( ), - "/facility/:facilityId/triage/:id": ({ facilityId, id }: any) => ( + "/facility/:facilityId/triage/:id": ({ facilityId, id }) => ( ), - ...FacilityLocationRoutes, ...FacilityInventoryRoutes, }; + +export default FacilityRoutes; diff --git a/src/Routers/routes/HCXRoutes.tsx b/src/Routers/routes/HCXRoutes.tsx index 80378b24621..929cc3f12bb 100644 --- a/src/Routers/routes/HCXRoutes.tsx +++ b/src/Routers/routes/HCXRoutes.tsx @@ -1,10 +1,15 @@ -import ConsultationClaims, { - IConsultationClaimsProps, -} from "../../Components/Facility/ConsultationClaims"; +import ConsultationClaims from "../../Components/Facility/ConsultationClaims"; +import { AppRoutes } from "../AppRouter"; -export default { +const HCXRoutes: AppRoutes = { "/facility/:facilityId/patient/:patientId/consultation/:consultationId/claims": - (pathParams: IConsultationClaimsProps) => ( - + ({ facilityId, patientId, consultationId }) => ( + ), }; + +export default HCXRoutes; diff --git a/src/Routers/routes/PatientRoutes.tsx b/src/Routers/routes/PatientRoutes.tsx index fcfc9b04e37..45ff044e4d2 100644 --- a/src/Routers/routes/PatientRoutes.tsx +++ b/src/Routers/routes/PatientRoutes.tsx @@ -3,44 +3,44 @@ import { PatientManager } from "../../Components/Patient/ManagePatients"; import { PatientHome } from "../../Components/Patient/PatientHome"; import PatientNotes from "../../Components/Patient/PatientNotes"; import { PatientRegister } from "../../Components/Patient/PatientRegister"; -import { DetailRoute } from "../types"; import DeathReport from "../../Components/DeathReport/DeathReport"; import { InsuranceDetails } from "../../Components/Patient/InsuranceDetails"; import FileUploadPage from "../../Components/Patient/FileUploadPage"; +import { AppRoutes } from "../AppRouter"; -export default { +const PatientRoutes: AppRoutes = { "/patients": () => , - "/patient/:id": ({ id }: DetailRoute) => , - "/patient/:id/investigation_reports": ({ id }: DetailRoute) => ( + "/patient/:id": ({ id }) => , + "/patient/:id/investigation_reports": ({ id }) => ( ), - - // Facility Scoped Routes - "/facility/:facilityId/patient": ({ facilityId }: any) => ( + "/facility/:facilityId/patient": ({ facilityId }) => ( ), - "/facility/:facilityId/patient/:id": ({ facilityId, id }: any) => ( + "/facility/:facilityId/patient/:id": ({ facilityId, id }) => ( ), - "/facility/:facilityId/patient/:id/insurance": ({ facilityId, id }: any) => ( + "/facility/:facilityId/patient/:id/insurance": ({ facilityId, id }) => ( ), - "/facility/:facilityId/patient/:id/update": ({ facilityId, id }: any) => ( + "/facility/:facilityId/patient/:id/update": ({ facilityId, id }) => ( ), "/facility/:facilityId/patient/:patientId/notes": ({ facilityId, patientId, - }: any) => , + }) => , "/facility/:facilityId/patient/:patientId/files": ({ facilityId, patientId, - }: any) => ( + }) => ( ), - "/death_report/:id": ({ id }: any) => , + "/death_report/:id": ({ id }) => , }; + +export default PatientRoutes; diff --git a/src/Routers/routes/ResourceRoutes.tsx b/src/Routers/routes/ResourceRoutes.tsx index 8408ab4d79d..4ffa5bd94ad 100644 --- a/src/Routers/routes/ResourceRoutes.tsx +++ b/src/Routers/routes/ResourceRoutes.tsx @@ -5,12 +5,12 @@ import { ResourceDetailsUpdate } from "../../Components/Resource/ResourceDetails import ListView from "../../Components/Resource/ListView"; import BoardView from "../../Components/Resource/ResourceBoardView"; import { Redirect } from "raviger"; -import { DetailRoute } from "../types"; +import { AppRoutes } from "../AppRouter"; const getDefaultView = () => localStorage.getItem("defaultResourceView") === "list" ? "list" : "board"; -export default { +const ResourceRoutes: AppRoutes = { "/resource": () => , "/resource/board": () => ( @@ -18,8 +18,8 @@ export default { ), "/resource/list": () => , - "/resource/:id": ({ id }: DetailRoute) => , - "/resource/:id/update": ({ id }: DetailRoute) => ( - - ), + "/resource/:id": ({ id }) => , + "/resource/:id/update": ({ id }) => , }; + +export default ResourceRoutes; diff --git a/src/Routers/routes/SampleRoutes.tsx b/src/Routers/routes/SampleRoutes.tsx index 290a34fd4eb..cf296790a81 100644 --- a/src/Routers/routes/SampleRoutes.tsx +++ b/src/Routers/routes/SampleRoutes.tsx @@ -2,24 +2,22 @@ import { SampleDetails } from "../../Components/Patient/SampleDetails"; import SampleReport from "../../Components/Patient/SamplePreview"; import { SampleTest } from "../../Components/Patient/SampleTest"; import SampleViewAdmin from "../../Components/Patient/SampleViewAdmin"; -import { DetailRoute, RouteParams } from "../types"; +import { AppRoutes } from "../AppRouter"; -export default { +const SampleRoutes: AppRoutes = { "/sample": () => , - "/sample/:id": ({ id }: DetailRoute) => , + "/sample/:id": ({ id }) => , "/patient/:patientId/test_sample/:sampleId/icmr_sample": ({ patientId, sampleId, - }: RouteParams<"patientId" | "sampleId">) => ( - - ), + }) => , "/facility/:facilityId/patient/:patientId/sample-test": ({ facilityId, patientId, - }: RouteParams<"facilityId" | "patientId">) => ( - + }) => , + "/facility/:facilityId/patient/:patientId/sample/:id": ({ id }) => ( + ), - "/facility/:facilityId/patient/:patientId/sample/:id": ({ - id, - }: DetailRoute) => , }; + +export default SampleRoutes; diff --git a/src/Routers/routes/ShiftingRoutes.tsx b/src/Routers/routes/ShiftingRoutes.tsx index 9b20b4a1a0b..5118b246430 100644 --- a/src/Routers/routes/ShiftingRoutes.tsx +++ b/src/Routers/routes/ShiftingRoutes.tsx @@ -6,11 +6,12 @@ import { ShiftDetailsUpdate } from "../../Components/Shifting/ShiftDetailsUpdate import ListView from "../../Components/Shifting/ListView"; import BoardView from "../../Components/Shifting/BoardView"; import { Redirect } from "raviger"; +import { AppRoutes } from "../AppRouter"; const getDefaultView = () => localStorage.getItem("defaultShiftView") === "list" ? "list" : "board"; -export default { +const ShiftingRoutes: AppRoutes = { "/shifting": () => , "/shifting/board": () => ( @@ -18,10 +19,12 @@ export default { ), "/shifting/list": () => , - "/shifting/:id": ({ id }: any) => , - "/shifting/:id/update": ({ id }: any) => , + "/shifting/:id": ({ id }) => , + "/shifting/:id/update": ({ id }) => , "/facility/:facilityId/patient/:patientId/shift/new": ({ facilityId, patientId, - }: any) => , + }) => , }; + +export default ShiftingRoutes; diff --git a/src/Routers/routes/UserRoutes.tsx b/src/Routers/routes/UserRoutes.tsx index 56877ca4c78..24f355b201b 100644 --- a/src/Routers/routes/UserRoutes.tsx +++ b/src/Routers/routes/UserRoutes.tsx @@ -1,9 +1,12 @@ import ManageUsers from "../../Components/Users/ManageUsers"; import { UserAdd } from "../../Components/Users/UserAdd"; import UserProfile from "../../Components/Users/UserProfile"; +import { AppRoutes } from "../AppRouter"; -export default { +const UserRoutes: AppRoutes = { "/users": () => , "/users/add": () => , "/user/profile": () => , }; + +export default UserRoutes;