Skip to content

Commit

Permalink
(chore) Remove duplicated SWR config (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Feb 18, 2024
1 parent 4f49e0a commit b17a4bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 42 deletions.
11 changes: 1 addition & 10 deletions packages/esm-appointments-app/src/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import React from 'react';
import { SWRConfig } from 'swr';

import AppointmentsBaseTable from './appointments-base-table.component';

const swrConfiguration = {
errorRetryCount: 3,
};

const HomeAppointments = () => {
return (
<SWRConfig value={swrConfiguration}>
<AppointmentsBaseTable />
</SWRConfig>
);
return <AppointmentsBaseTable />;
};

export default HomeAppointments;
21 changes: 7 additions & 14 deletions packages/esm-appointments-app/src/root.component.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
import React from 'react';
import { SWRConfig } from 'swr';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import AppointmentsCalendarView from './calendar/appointments-calendar-view.component';
import Appointments from './appointments.component';
import CalendarPatientList from './calendar/patient-list/calendar-patient-list.component';

const swrConfiguration = {
errorRetryCount: 3,
};

const RootComponent: React.FC = () => {
const appointmentsBasename = window.getOpenmrsSpaBase() + 'home/appointments';

return (
<main>
<SWRConfig value={swrConfiguration}>
<BrowserRouter basename={appointmentsBasename}>
<Routes>
<Route path="/" element={<Appointments />} />
<Route path="/calendar" element={<AppointmentsCalendarView />} />
<Route path="/list/:dateTime/:serviceName" element={<CalendarPatientList />} />
</Routes>
</BrowserRouter>
</SWRConfig>
<BrowserRouter basename={appointmentsBasename}>
<Routes>
<Route path="/" element={<Appointments />} />
<Route path="/calendar" element={<AppointmentsCalendarView />} />
<Route path="/list/:dateTime/:serviceName" element={<CalendarPatientList />} />
</Routes>
</BrowserRouter>
</main>
);
};
Expand Down
28 changes: 10 additions & 18 deletions packages/esm-service-queues-app/src/root.component.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
import React from 'react';
import { SWRConfig } from 'swr';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import AppointmentsTable from './queue-patient-linelists/scheduled-appointments-table.component';
import Home from './home.component';
import ServicesTable from './queue-patient-linelists/queue-services-table.component';
import QueueScreen from './queue-screen/queue-screen.component';
import QueueTableByStatusView from './views/queue-table-by-status-view.component';

const swrConfiguration = {
// Maximum number of retries when the backend returns an error
errorRetryCount: 3,
};

const Root: React.FC = () => {
const serviceQueuesBasename = window.getOpenmrsSpaBase() + 'home/service-queues';

return (
<main>
<SWRConfig value={swrConfiguration}>
<BrowserRouter basename={serviceQueuesBasename}>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/queue-table-by-status/:queueUuid" element={<QueueTableByStatusView />} />
<Route path="/queue-table-by-status/:queueUuid/:statusUuid" element={<QueueTableByStatusView />} />
<Route path="/screen" element={<QueueScreen />} />
<Route path="/appointments-list/:value/" element={<AppointmentsTable />} />
<Route path="/queue-list/:service/:serviceUuid/:locationUuid" element={<ServicesTable />} />
</Routes>
</BrowserRouter>
</SWRConfig>
<BrowserRouter basename={serviceQueuesBasename}>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/queue-table-by-status/:queueUuid" element={<QueueTableByStatusView />} />
<Route path="/queue-table-by-status/:queueUuid/:statusUuid" element={<QueueTableByStatusView />} />
<Route path="/screen" element={<QueueScreen />} />
<Route path="/appointments-list/:value/" element={<AppointmentsTable />} />
<Route path="/queue-list/:service/:serviceUuid/:locationUuid" element={<ServicesTable />} />
</Routes>
</BrowserRouter>
</main>
);
};
Expand Down

0 comments on commit b17a4bd

Please sign in to comment.