From a1d8c7b64ebc050ccff77ed956401a1c2ea26ec1 Mon Sep 17 00:00:00 2001 From: "Kipchumba C. Bett" Date: Wed, 31 May 2023 11:57:13 +0300 Subject: [PATCH] [chores]: clean up & re-arrange dirs structure --- src/App.tsx | 28 +++++-------------- src/app/Session.ts | 2 -- .../csv-uploads}/CsvUpload.tsx | 6 ++-- .../csv-uploads}/DisplayCSV.tsx | 4 +-- .../csv-uploads}/csv.resource.ts | 0 .../rde-sync}/AddPatients.component.tsx | 10 +++---- .../rde-sync}/AddPatients.resource.tsx | 0 .../rde-sync}/Moh731Sync.component.tsx | 6 ++-- .../rde-sync}/Moh731Sync.resource.ts | 2 +- src/context/AppContext.ts | 9 ------ 10 files changed, 21 insertions(+), 46 deletions(-) rename src/{components/csvUploads => app/csv-uploads}/CsvUpload.tsx (98%) rename src/{components/csvUploads => app/csv-uploads}/DisplayCSV.tsx (99%) rename src/{components/csvUploads => app/csv-uploads}/csv.resource.ts (100%) rename src/{components/RdeSync => app/rde-sync}/AddPatients.component.tsx (95%) rename src/{components/RdeSync => app/rde-sync}/AddPatients.resource.tsx (100%) rename src/{components/RdeSync => app/rde-sync}/Moh731Sync.component.tsx (98%) rename src/{components/RdeSync => app/rde-sync}/Moh731Sync.resource.ts (97%) delete mode 100644 src/context/AppContext.ts diff --git a/src/App.tsx b/src/App.tsx index 4017d7e..28dea83 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,6 @@ import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; -// import Layout from './components/layout/Layout'; import Home from './app/main/Home'; -// import PatientSearch from './components/patientSearch/Patient'; -// import PatientInformation from './app/patient-dashboard/patient-info/PatientInformation'; -// import Orders from './components/Orders/Orders.component'; -// import Observation from './components/observations/Observation'; import Login from './app/authentication/Login'; import PatientInfo from './app/patient-dashboard/info/PatientInfo'; import PatientSearch from './app/patient-search/Patient'; @@ -14,6 +9,9 @@ import { AppContextProvider } from './app/AppContextProvider'; import Observation from './app/patient-dashboard/observations/Observation'; import { useEffect } from 'react'; import { getSession } from './app/Session'; +import CsvUpload from './app/csv-uploads/CsvUpload'; +import Moh731SyncQueueComponent from './app/rde-sync/Moh731Sync.component'; +import AddPatientIdentifier from './app/rde-sync/AddPatients.component'; const App = () => { useEffect(() => { @@ -33,24 +31,12 @@ const App = () => { } /> } /> } /> - - {/* - } /> - }> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - */} + } /> + } /> + } /> + - {/* div below is for testing purposes */} - {/*
{JSON.stringify(contextValue)}
*/} ); }; diff --git a/src/app/Session.ts b/src/app/Session.ts index f199c5a..f618246 100644 --- a/src/app/Session.ts +++ b/src/app/Session.ts @@ -5,7 +5,6 @@ export const getSession = async (): Promise => { }); const userInfo = await response.json(); - console.log('userInfo', userInfo); const { authenticated } = userInfo; return authenticated; }; @@ -17,7 +16,6 @@ export const clearSession = async () => { Authorization: 'Basic ' + localStorage.getItem('auth-token'), }, }).then((data) => { - console.log('data', data); if (data?.status === 204 && data?.ok === true) { localStorage.removeItem('userInformation'); localStorage.removeItem('authenticated'); diff --git a/src/components/csvUploads/CsvUpload.tsx b/src/app/csv-uploads/CsvUpload.tsx similarity index 98% rename from src/components/csvUploads/CsvUpload.tsx rename to src/app/csv-uploads/CsvUpload.tsx index 6fbd342..f76cd26 100644 --- a/src/components/csvUploads/CsvUpload.tsx +++ b/src/app/csv-uploads/CsvUpload.tsx @@ -3,10 +3,10 @@ import { useEffect, useState } from 'react'; import { CsvUploadData, uploadCsvFile } from './csv.resource'; import { toast, ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; -import storage from '../../app/localStorage'; +import storage from '../localStorage'; import DisplayCSV from './DisplayCSV'; -import Header from '../layout/headers/HeaderWithLogo'; -import Footer from '../layout/Footer'; +import Header from '../../components/layout/headers/HeaderWithLogo'; +import Footer from '../../components/layout/Footer'; const CsvUpload = () => { const [csvFile, setCsvFile] = useState(new File([], '')); diff --git a/src/components/csvUploads/DisplayCSV.tsx b/src/app/csv-uploads/DisplayCSV.tsx similarity index 99% rename from src/components/csvUploads/DisplayCSV.tsx rename to src/app/csv-uploads/DisplayCSV.tsx index b2a69c7..2cfa92f 100644 --- a/src/components/csvUploads/DisplayCSV.tsx +++ b/src/app/csv-uploads/DisplayCSV.tsx @@ -6,8 +6,8 @@ import Modal from 'react-modal'; import { getCsvFiles, deleteCsvFile, syncCsvFile, getErrorLogs } from './csv.resource'; import { ToastContainer, toast } from 'react-toastify'; import swal from 'sweetalert'; -import storage from '../../app/localStorage'; -import Pagination from '../pagination/Pagination'; +import storage from '../localStorage'; +import Pagination from '../../components/pagination/Pagination'; const customStyles = { content: { diff --git a/src/components/csvUploads/csv.resource.ts b/src/app/csv-uploads/csv.resource.ts similarity index 100% rename from src/components/csvUploads/csv.resource.ts rename to src/app/csv-uploads/csv.resource.ts diff --git a/src/components/RdeSync/AddPatients.component.tsx b/src/app/rde-sync/AddPatients.component.tsx similarity index 95% rename from src/components/RdeSync/AddPatients.component.tsx rename to src/app/rde-sync/AddPatients.component.tsx index 20838b0..e586d94 100644 --- a/src/components/RdeSync/AddPatients.component.tsx +++ b/src/app/rde-sync/AddPatients.component.tsx @@ -1,13 +1,13 @@ import { useState } from 'react'; import { AiOutlineDelete } from 'react-icons/ai'; -import storage from '../../app/localStorage'; +import storage from '../localStorage'; import { FaPlus } from 'react-icons/fa'; -import Header from '../layout/headers/HeaderWithLogo'; -import Footer from '../layout/Footer'; +import Header from '../../components/layout/headers/HeaderWithLogo'; +import Footer from '../../components/layout/Footer'; import { useNavigate } from 'react-router-dom'; import { queuePatients, setReportingMonth } from './AddPatients.resource'; -import ErrorToast from '../toasts/ErrorToast'; -import SuccessToast from '../toasts/SuccessToast'; +import ErrorToast from '../../components/toasts/ErrorToast'; +import SuccessToast from '../../components/toasts/SuccessToast'; const AddPatientIdentifier = () => { const [patientIdentifier, setPatientIdentifier] = useState({ diff --git a/src/components/RdeSync/AddPatients.resource.tsx b/src/app/rde-sync/AddPatients.resource.tsx similarity index 100% rename from src/components/RdeSync/AddPatients.resource.tsx rename to src/app/rde-sync/AddPatients.resource.tsx diff --git a/src/components/RdeSync/Moh731Sync.component.tsx b/src/app/rde-sync/Moh731Sync.component.tsx similarity index 98% rename from src/components/RdeSync/Moh731Sync.component.tsx rename to src/app/rde-sync/Moh731Sync.component.tsx index 35185d6..2befed9 100644 --- a/src/components/RdeSync/Moh731Sync.component.tsx +++ b/src/app/rde-sync/Moh731Sync.component.tsx @@ -2,10 +2,10 @@ import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Patient } from '../../types/Patient'; import { formatDate } from '../../utils/DateUtil'; -import Footer from '../layout/Footer'; -import Header from '../layout/headers/HeaderWithLogo'; +import Footer from '../../components/layout/Footer'; +import Header from '../../components/layout/headers/HeaderWithLogo'; import { fetchMoh731SyncQueue, freezeProcessedPatients, processQueuedPatients } from './Moh731Sync.resource'; -import storage from '../../app/localStorage'; +import storage from '../localStorage'; interface searchProps { handleSearch: React.ChangeEventHandler; diff --git a/src/components/RdeSync/Moh731Sync.resource.ts b/src/app/rde-sync/Moh731Sync.resource.ts similarity index 97% rename from src/components/RdeSync/Moh731Sync.resource.ts rename to src/app/rde-sync/Moh731Sync.resource.ts index aafd17f..b06edee 100644 --- a/src/components/RdeSync/Moh731Sync.resource.ts +++ b/src/app/rde-sync/Moh731Sync.resource.ts @@ -1,4 +1,4 @@ -import storage from '../../app/localStorage'; +import storage from '../localStorage'; import { Patient } from '../../types/Patient'; import { ProcessQueuePayload } from '../../types/Payloads'; diff --git a/src/context/AppContext.ts b/src/context/AppContext.ts deleted file mode 100644 index f90d92d..0000000 --- a/src/context/AppContext.ts +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -export interface AppContextType { - // eslint-disable-next-line @typescript-eslint/ban-types - currentPatient: Object[]; -} - -export const AppContext = React.createContext({ - currentPatient: [], -});