From 544e22647031c8bd91de9db98a2bd79d2bd3145a Mon Sep 17 00:00:00 2001 From: Madhura Pabudanan Date: Sat, 24 Dec 2022 00:01:16 +0530 Subject: [PATCH 1/5] feat(ui): :zap: doctorDashboard/viewSession --- apps/frontend/doctor/pages/index.tsx | 185 +++--------------- .../apps/channeling/channeling.controller.ts | 11 ++ .../src/apps/channeling/channeling.service.ts | 4 + libs/next/src/api/doctor.ts | 11 +- .../components/doctor/doctorDetailCard.tsx | 11 +- .../doctor/upcomingDetails.stories.tsx | 42 +--- .../lib/components/doctor/upcomingDetails.tsx | 119 ++--------- 7 files changed, 68 insertions(+), 315 deletions(-) diff --git a/apps/frontend/doctor/pages/index.tsx b/apps/frontend/doctor/pages/index.tsx index 4ca0a6b..1f122ba 100644 --- a/apps/frontend/doctor/pages/index.tsx +++ b/apps/frontend/doctor/pages/index.tsx @@ -1,4 +1,5 @@ -import { PatientDetails, UpcomingDetails, CreateSession } from '@hospe/ui'; +import { UpcomingDetails } from '@hospe/ui'; +import { Api } from '@hospe/next'; import { Paper, SimpleGrid, @@ -7,9 +8,28 @@ import { Text, Group, } from '@mantine/core'; -import { Users, Report, ReportMedical } from 'tabler-icons-react'; +import { Report } from 'tabler-icons-react'; +import { useEffect, useState } from 'react'; + +interface Session { + __v: string; + docId: string; + _id: string; + date: string; + time: string; + maximumPatients: number; + doctorFee: number; +} export function Index() { + const [session, setSession] = useState([]); + + useEffect(() => { + Api.Doctor.GetAll().then((res) => { + setSession(res); + }); + }, []); + return ( <> - {/* Patients Details */} -
- ({ - backgroundColor: - theme.colorScheme === 'dark' - ? theme.colors.dark[8] - : theme.white, - })} - > - - Today Appointments - - - - - 10 Active Patients - - - - - - -
- {/* Upcoming Appointments */}
- +
diff --git a/apps/services/api/src/apps/channeling/channeling.controller.ts b/apps/services/api/src/apps/channeling/channeling.controller.ts index 12a1c3b..0207b8d 100644 --- a/apps/services/api/src/apps/channeling/channeling.controller.ts +++ b/apps/services/api/src/apps/channeling/channeling.controller.ts @@ -6,6 +6,7 @@ import { FindOneChanneling, UpdateChanneling, FindAllChanneling, + FindAllChannelingByDocId, } from './channeling.service'; export const router = Router(); @@ -30,6 +31,16 @@ router.get('/', async (req, res) => { ExpressErrorResponseHandler(res, error); } }); + +router.get('/:docId', async (req, res) => { + try { + const data = await FindAllChannelingByDocId(req.params.docId); + res.status(200).json(data); + } catch (error) { + ExpressErrorResponseHandler(res, error); + } +}); + /* delete channeling session by id */ router.delete('/:id', async (req, res) => { try { diff --git a/apps/services/api/src/apps/channeling/channeling.service.ts b/apps/services/api/src/apps/channeling/channeling.service.ts index 8105fb2..ac81f58 100644 --- a/apps/services/api/src/apps/channeling/channeling.service.ts +++ b/apps/services/api/src/apps/channeling/channeling.service.ts @@ -12,6 +12,10 @@ export const FindOneChanneling = async (id: string) => { return await ChannelingModel.findOne({ _id: id }); }; +export const FindAllChannelingByDocId = async (docId: string) => { + return await ChannelingModel.find({ docId }); +}; + export const FindAllChanneling = async () => { return await ChannelingModel.find(); }; diff --git a/libs/next/src/api/doctor.ts b/libs/next/src/api/doctor.ts index 41d6a14..6de7aa1 100644 --- a/libs/next/src/api/doctor.ts +++ b/libs/next/src/api/doctor.ts @@ -10,9 +10,16 @@ interface CreateSessionProps { } const CreateSession = (props: CreateSessionProps) => { - return instance.post('/channeling/create-channeling', props).then((res) => res.data); + return instance + .post('/channeling/create-channeling', props) + .then((res) => res.data); +}; + +const GetAll = () => { + return instance.get('/channeling/').then((res) => res.data); }; export const Doctor = { - CreateSession + CreateSession, + GetAll, }; diff --git a/libs/ui/src/lib/components/doctor/doctorDetailCard.tsx b/libs/ui/src/lib/components/doctor/doctorDetailCard.tsx index 3288d12..fa7ea12 100644 --- a/libs/ui/src/lib/components/doctor/doctorDetailCard.tsx +++ b/libs/ui/src/lib/components/doctor/doctorDetailCard.tsx @@ -1,14 +1,5 @@ import { FC } from 'react'; -import { - Text, - Table, - ScrollArea, - Avatar, - Group, - createStyles, - Card, -} from '@mantine/core'; -import { At, ReportMedical } from 'tabler-icons-react'; +import { Text, Table, ScrollArea } from '@mantine/core'; interface RowDetailsProps { _id: string; diff --git a/libs/ui/src/lib/components/doctor/upcomingDetails.stories.tsx b/libs/ui/src/lib/components/doctor/upcomingDetails.stories.tsx index 2d9b779..3b6d588 100644 --- a/libs/ui/src/lib/components/doctor/upcomingDetails.stories.tsx +++ b/libs/ui/src/lib/components/doctor/upcomingDetails.stories.tsx @@ -10,45 +10,13 @@ export default { const mockdata: UpcomingDetailsProps = { upcomingDetailsdata: [ { + __v: '1', + docId: '1', + _id: '1', time: '8.30 PM', date: '2022-08-15', - patientsNumber: 12, - location: 'Room 06', - }, - - { - time: '10.30 PM', - date: '2022-08-16', - patientsNumber: 25, - location: 'Room 08', - }, - - { - time: '8.30 PM', - date: '2022-08-16', - patientsNumber: 32, - location: 'Room 10', - }, - - { - time: '8.30 PM', - date: '2022-08-15', - patientsNumber: 12, - location: 'Room 06', - }, - - { - time: '8.30 PM', - date: '2022-08-15', - patientsNumber: 12, - location: 'Room 06', - }, - - { - time: '8.30 PM', - date: '2022-08-15', - patientsNumber: 12, - location: 'Room 06', + maximumPatients: 12, + doctorFee: 1000, }, ], }; diff --git a/libs/ui/src/lib/components/doctor/upcomingDetails.tsx b/libs/ui/src/lib/components/doctor/upcomingDetails.tsx index 01e71b9..700c3f6 100644 --- a/libs/ui/src/lib/components/doctor/upcomingDetails.tsx +++ b/libs/ui/src/lib/components/doctor/upcomingDetails.tsx @@ -1,20 +1,14 @@ -import { FC, useState } from 'react'; -import { - Text, - Table, - ScrollArea, - Group, - Center, - Button, - Modal, - Box, -} from '@mantine/core'; -import { Clock, Calendar, User, Location } from 'tabler-icons-react'; +import { FC } from 'react'; +import { Text, Table, ScrollArea, Group, Center } from '@mantine/core'; +import { Clock, Calendar, User } from 'tabler-icons-react'; interface RowDetailsProps { - time: string; + __v: string; + _id: string; + docId: string; date: string; - patientsNumber: number; - location: string; + time: string; + maximumPatients: number; + doctorFee: number; } export interface UpcomingDetailsProps { @@ -24,82 +18,21 @@ export interface UpcomingDetailsProps { export const UpcomingDetails: FC = ({ upcomingDetailsdata, }) => { - const [opened, setOpened] = useState(false); - const rows = upcomingDetailsdata.map((item) => ( - - {/* Appointment Date and time */} - - - - {item.date} - - - - - {item.time} - - - - - - {/* Number of active patients */} -
- - Active Patients - -
-
- - - - {item.patientsNumber} - - -
- - - -
- - - - {item.location} - - -
- - -
- - - -
- - - )); - const newRows = upcomingDetailsdata.map((item) => ( {/* Appointment Date and time */} - {item.date} + {item.date.slice(0, 10)} - {item.time} + {item.time.slice(11, -8)} - {/* Number of active patients */}
@@ -111,7 +44,7 @@ export const UpcomingDetails: FC = ({ - {item.patientsNumber} + {item.maximumPatients}
@@ -120,28 +53,7 @@ export const UpcomingDetails: FC = ({ )); return ( - - setOpened ? - setOpened(false)} - title="Introduce yourself!" - > - - - - - - - - - - {newRows} -
-
-
- : +
@@ -149,12 +61,11 @@ export const UpcomingDetails: FC = ({ - - {rows} + {newRows}
- +
); }; From 0a12f265b03017df6fbcab00fbeac98806ad000d Mon Sep 17 00:00:00 2001 From: Madhura Pabudanan Date: Sat, 24 Dec 2022 04:55:45 +0530 Subject: [PATCH 2/5] feat(ui): :zap: feat/doctor dashboard --- apps/frontend/doctor/pages/index.tsx | 15 +++++++++- .../management/pages/doctorRegistration.tsx | 3 +- libs/next/src/api/doctor.ts | 5 ++++ .../lib/components/doctor/upcomingDetails.tsx | 28 ++++++++++++++++++- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/apps/frontend/doctor/pages/index.tsx b/apps/frontend/doctor/pages/index.tsx index 1f122ba..2df77ac 100644 --- a/apps/frontend/doctor/pages/index.tsx +++ b/apps/frontend/doctor/pages/index.tsx @@ -21,6 +21,9 @@ interface Session { doctorFee: number; } +export interface Formdata { + _id: string; +} export function Index() { const [session, setSession] = useState([]); @@ -30,6 +33,13 @@ export function Index() { }); }, []); + const onSubmit = async (values: Formdata) => { + await Api.Doctor.Delete(values._id); + Api.Doctor.GetAll().then((res) => { + setSession(res); + }); + }; + return ( <> - + diff --git a/apps/frontend/management/pages/doctorRegistration.tsx b/apps/frontend/management/pages/doctorRegistration.tsx index 660f0a9..0fcf514 100644 --- a/apps/frontend/management/pages/doctorRegistration.tsx +++ b/apps/frontend/management/pages/doctorRegistration.tsx @@ -13,8 +13,7 @@ const doctorRegistration = () => { ]; const onSubmit = async (values: IDoctorCreate) => { - const res = await Api.Employee.CreateDoctor(values); - console.log(res); + await Api.Employee.CreateDoctor(values); }; return ( diff --git a/libs/next/src/api/doctor.ts b/libs/next/src/api/doctor.ts index 6de7aa1..af0f9b0 100644 --- a/libs/next/src/api/doctor.ts +++ b/libs/next/src/api/doctor.ts @@ -19,7 +19,12 @@ const GetAll = () => { return instance.get('/channeling/').then((res) => res.data); }; +const Delete = (props: string) => { + return instance.delete(`/channeling/${props}`).then((res) => res.data); +}; + export const Doctor = { CreateSession, GetAll, + Delete, }; diff --git a/libs/ui/src/lib/components/doctor/upcomingDetails.tsx b/libs/ui/src/lib/components/doctor/upcomingDetails.tsx index 700c3f6..ab7876f 100644 --- a/libs/ui/src/lib/components/doctor/upcomingDetails.tsx +++ b/libs/ui/src/lib/components/doctor/upcomingDetails.tsx @@ -1,6 +1,7 @@ import { FC } from 'react'; -import { Text, Table, ScrollArea, Group, Center } from '@mantine/core'; +import { Text, Table, ScrollArea, Group, Center, Button } from '@mantine/core'; import { Clock, Calendar, User } from 'tabler-icons-react'; +import { useForm } from '@mantine/hooks'; interface RowDetailsProps { __v: string; _id: string; @@ -11,13 +12,25 @@ interface RowDetailsProps { doctorFee: number; } +export interface Formdata { + _id: string; +} + export interface UpcomingDetailsProps { upcomingDetailsdata: RowDetailsProps[]; + onSubmit: (values: Formdata) => void; } export const UpcomingDetails: FC = ({ upcomingDetailsdata, + onSubmit, }) => { + const form = useForm({ + initialValues: { + _id: '', + }, + }); + const newRows = upcomingDetailsdata.map((item) => ( {/* Appointment Date and time */} @@ -49,6 +62,19 @@ export const UpcomingDetails: FC = ({ + + + {/* Button */} +
+ +
+ )); From 895e6aea41753cc4be8e30890914fa165335ee45 Mon Sep 17 00:00:00 2001 From: Madhura Pabudanan Date: Sat, 24 Dec 2022 07:29:25 +0530 Subject: [PATCH 3/5] wip --- apps/frontend/user/pages/index.tsx | 27 +++-- .../apps/channeling/channeling.controller.ts | 16 ++- .../api/src/apps/channeling/channeling.dto.ts | 2 + .../src/apps/channeling/channeling.schema.ts | 1 + .../src/apps/channeling/channeling.service.ts | 7 +- libs/next/src/api/doctor.ts | 6 ++ libs/types/src/forms/session.form.ts | 7 +- .../searching/searchBar.stories.tsx | 3 + .../channeling/searching/searchBar.tsx | 100 +++++++----------- 9 files changed, 97 insertions(+), 72 deletions(-) diff --git a/apps/frontend/user/pages/index.tsx b/apps/frontend/user/pages/index.tsx index 7020420..1e40042 100644 --- a/apps/frontend/user/pages/index.tsx +++ b/apps/frontend/user/pages/index.tsx @@ -1,14 +1,25 @@ import { useAuthStore } from '@hospe/next'; import { ResultCard, SearchBar } from '@hospe/ui'; import { Center, SimpleGrid } from '@mantine/core'; +import { Api } from '@hospe/next'; + +export interface Formdata { + Doctype: string; +} const IndexPage = () => { const { displayName } = useAuthStore(); + const onSubmit = async (values: Formdata) => { + console.log(values.Doctype); + const data = await Api.Doctor.GetTypes(values.Doctype); + console.log(data); + }; + const mockDataSearch = { searchData: [ { - specializations: ['General Physician', 'Dentist', 'Cardiologist'], + specializations: ['Surgeon', 'Dentist', 'Cardiologist'], time: ['Any', 'Morning', 'Afternoon', 'Evening'], gender: ['Any', 'Male', 'Female'], }, @@ -41,16 +52,16 @@ const IndexPage = () => { ], }; - const items = mockDataResult.data.map((item) => ( -
- -
- )); + // const items = mockDataResult.data.map((item) => ( + //
+ // + //
+ // )); return ( <>
- +
{ { maxWidth: 755, cols: 1, spacing: 'sm' }, ]} > - {items} + {/* {items} */}
diff --git a/apps/services/api/src/apps/channeling/channeling.controller.ts b/apps/services/api/src/apps/channeling/channeling.controller.ts index 0207b8d..c5a478f 100644 --- a/apps/services/api/src/apps/channeling/channeling.controller.ts +++ b/apps/services/api/src/apps/channeling/channeling.controller.ts @@ -7,8 +7,11 @@ import { UpdateChanneling, FindAllChanneling, FindAllChannelingByDocId, + FindAllChannelingByDocType, } from './channeling.service'; +import { FindOneEmployee } from '../employee/employee.service'; + export const router = Router(); /* find channeling session by id */ @@ -41,6 +44,15 @@ router.get('/:docId', async (req, res) => { } }); +router.get('/:docType', async (req, res) => { + try { + const data = await FindAllChannelingByDocType(req.params.docType); + res.status(200).json(data); + } catch (error) { + ExpressErrorResponseHandler(res, error); + } +}); + /* delete channeling session by id */ router.delete('/:id', async (req, res) => { try { @@ -55,7 +67,9 @@ router.delete('/:id', async (req, res) => { /* create channeling session */ router.post('/create-channeling', async (req, res) => { try { - const data = await CreateChanneling(req.user.id, req.body); + const docData = await FindOneEmployee(req.user.id); + const docType = docData.specialization; + const data = await CreateChanneling(req.user.id, docType, req.body); res.status(200).json(data); } catch (error) { ExpressErrorResponseHandler(res, error); diff --git a/apps/services/api/src/apps/channeling/channeling.dto.ts b/apps/services/api/src/apps/channeling/channeling.dto.ts index 491e62d..5f2696e 100644 --- a/apps/services/api/src/apps/channeling/channeling.dto.ts +++ b/apps/services/api/src/apps/channeling/channeling.dto.ts @@ -1,4 +1,6 @@ export interface CreateChannelingDto { + readonly docId: string; + readonly docType: string; readonly date: Date; readonly time: string; readonly maximumPatients: number; diff --git a/apps/services/api/src/apps/channeling/channeling.schema.ts b/apps/services/api/src/apps/channeling/channeling.schema.ts index 0549851..8892580 100644 --- a/apps/services/api/src/apps/channeling/channeling.schema.ts +++ b/apps/services/api/src/apps/channeling/channeling.schema.ts @@ -2,6 +2,7 @@ import { model, Schema } from 'mongoose'; const ChannelingSchema = new Schema({ docId: { type: String, required: true }, + docType: { type: String, required: true }, date: { type: Date, required: true, index: -1, default: Date.now }, time: { type: String, required: true, index: -1 }, maximumPatients: { type: Number, required: true }, diff --git a/apps/services/api/src/apps/channeling/channeling.service.ts b/apps/services/api/src/apps/channeling/channeling.service.ts index ac81f58..f5557e2 100644 --- a/apps/services/api/src/apps/channeling/channeling.service.ts +++ b/apps/services/api/src/apps/channeling/channeling.service.ts @@ -3,9 +3,10 @@ import { ChannelingModel } from './channeling.schema'; export const CreateChanneling = async ( docId: string, + docType: string, params: CreateChannelingDto ) => { - return await ChannelingModel.create({ ...params, docId }); + return await ChannelingModel.create({ ...params, docId, docType }); }; export const FindOneChanneling = async (id: string) => { @@ -16,6 +17,10 @@ export const FindAllChannelingByDocId = async (docId: string) => { return await ChannelingModel.find({ docId }); }; +export const FindAllChannelingByDocType = async (docType: string) => { + return await ChannelingModel.find({ docType }); +}; + export const FindAllChanneling = async () => { return await ChannelingModel.find(); }; diff --git a/libs/next/src/api/doctor.ts b/libs/next/src/api/doctor.ts index af0f9b0..7e43981 100644 --- a/libs/next/src/api/doctor.ts +++ b/libs/next/src/api/doctor.ts @@ -3,6 +3,7 @@ import { instance } from './axios'; interface CreateSessionProps { docId: string; docName: string; + docType: string; date: string; time: string; maximumPatients: number; @@ -23,8 +24,13 @@ const Delete = (props: string) => { return instance.delete(`/channeling/${props}`).then((res) => res.data); }; +const GetTypes = (props: string) => { + return instance.get(`/channeling/${props}`).then((res) => res.data); +}; + export const Doctor = { CreateSession, GetAll, Delete, + GetTypes, }; diff --git a/libs/types/src/forms/session.form.ts b/libs/types/src/forms/session.form.ts index e3c8a2e..e97a505 100644 --- a/libs/types/src/forms/session.form.ts +++ b/libs/types/src/forms/session.form.ts @@ -1,7 +1,8 @@ export interface ISessionForm { - docId: string, - docName: string, - date: string, + docId: string; + docType: string; + docName: string; + date: string; time: string; maximumPatients: number; doctorFee: number; diff --git a/libs/ui/src/lib/components/channeling/searching/searchBar.stories.tsx b/libs/ui/src/lib/components/channeling/searching/searchBar.stories.tsx index 6067dcc..14ef96f 100644 --- a/libs/ui/src/lib/components/channeling/searching/searchBar.stories.tsx +++ b/libs/ui/src/lib/components/channeling/searching/searchBar.stories.tsx @@ -15,6 +15,9 @@ const mockData: SearchDetailsProps = { gender: ['Any', 'Male', 'Female'], }, ], + onSubmit: (values) => { + console.log(values); + }, }; const Template: ComponentStory = () => ( diff --git a/libs/ui/src/lib/components/channeling/searching/searchBar.tsx b/libs/ui/src/lib/components/channeling/searching/searchBar.tsx index 984d4d3..9a923ba 100644 --- a/libs/ui/src/lib/components/channeling/searching/searchBar.tsx +++ b/libs/ui/src/lib/components/channeling/searching/searchBar.tsx @@ -10,6 +10,7 @@ import { Center, } from '@mantine/core'; import { DatePicker } from '@mantine/dates'; +import { useForm } from '@mantine/hooks'; interface SearchBarProps { specializations: string[]; @@ -17,73 +18,54 @@ interface SearchBarProps { gender: string[]; } +export interface Formdata { + Doctype: string; +} + export interface SearchDetailsProps { searchData: SearchBarProps[]; + onSubmit: (values: Formdata) => void; } -export const SearchBar: FC = ({ searchData }) => { +export const SearchBar: FC = (props) => { + const form = useForm({ + initialValues: { + Doctype: '', + }, + }); return ( - ({ - backgroundColor: '#e6f3fa', - padding: theme.spacing.xl, - borderRadius: theme.radius.md, - })} +
{ + evt.preventDefault(); + props.onSubmit(form.values); + }} > - - + + +
+ + + +
+
); From ca9b6fbc440e7be9afe0ae31327160d73fdc6b4f Mon Sep 17 00:00:00 2001 From: Charuka Samarakoon Date: Sat, 24 Dec 2022 07:44:11 +0530 Subject: [PATCH 4/5] fix: :bug: duplicate get types --- apps/frontend/user/pages/index.tsx | 39 +------------------ .../apps/channeling/channeling.controller.ts | 4 +- .../src/apps/channeling/channeling.service.ts | 1 + libs/next/src/api/doctor.ts | 4 +- 4 files changed, 6 insertions(+), 42 deletions(-) diff --git a/apps/frontend/user/pages/index.tsx b/apps/frontend/user/pages/index.tsx index 1e40042..33bef6f 100644 --- a/apps/frontend/user/pages/index.tsx +++ b/apps/frontend/user/pages/index.tsx @@ -1,5 +1,4 @@ -import { useAuthStore } from '@hospe/next'; -import { ResultCard, SearchBar } from '@hospe/ui'; +import { SearchBar } from '@hospe/ui'; import { Center, SimpleGrid } from '@mantine/core'; import { Api } from '@hospe/next'; @@ -8,12 +7,8 @@ export interface Formdata { } const IndexPage = () => { - const { displayName } = useAuthStore(); - const onSubmit = async (values: Formdata) => { - console.log(values.Doctype); const data = await Api.Doctor.GetTypes(values.Doctype); - console.log(data); }; const mockDataSearch = { @@ -26,38 +21,6 @@ const IndexPage = () => { ], }; - const mockDataResult = { - data: [ - { - name: 'John Doe', - specialization: 'General Physician', - patientCount: 10, - time: 10, - fee: 100, - }, - { - name: 'John Doe', - specialization: 'General Physician', - patientCount: 10, - time: 10, - fee: 100, - }, - { - name: 'John Doe', - specialization: 'General Physician', - patientCount: 10, - time: 10, - fee: 100, - }, - ], - }; - - // const items = mockDataResult.data.map((item) => ( - //
- // - //
- // )); - return ( <>
diff --git a/apps/services/api/src/apps/channeling/channeling.controller.ts b/apps/services/api/src/apps/channeling/channeling.controller.ts index c5a478f..b6919f0 100644 --- a/apps/services/api/src/apps/channeling/channeling.controller.ts +++ b/apps/services/api/src/apps/channeling/channeling.controller.ts @@ -35,7 +35,7 @@ router.get('/', async (req, res) => { } }); -router.get('/:docId', async (req, res) => { +router.get('/doctor/:docId', async (req, res) => { try { const data = await FindAllChannelingByDocId(req.params.docId); res.status(200).json(data); @@ -44,7 +44,7 @@ router.get('/:docId', async (req, res) => { } }); -router.get('/:docType', async (req, res) => { +router.get('/type/:docType', async (req, res) => { try { const data = await FindAllChannelingByDocType(req.params.docType); res.status(200).json(data); diff --git a/apps/services/api/src/apps/channeling/channeling.service.ts b/apps/services/api/src/apps/channeling/channeling.service.ts index f5557e2..8bab1df 100644 --- a/apps/services/api/src/apps/channeling/channeling.service.ts +++ b/apps/services/api/src/apps/channeling/channeling.service.ts @@ -18,6 +18,7 @@ export const FindAllChannelingByDocId = async (docId: string) => { }; export const FindAllChannelingByDocType = async (docType: string) => { + console.log(docType); return await ChannelingModel.find({ docType }); }; diff --git a/libs/next/src/api/doctor.ts b/libs/next/src/api/doctor.ts index 7e43981..9a90367 100644 --- a/libs/next/src/api/doctor.ts +++ b/libs/next/src/api/doctor.ts @@ -24,8 +24,8 @@ const Delete = (props: string) => { return instance.delete(`/channeling/${props}`).then((res) => res.data); }; -const GetTypes = (props: string) => { - return instance.get(`/channeling/${props}`).then((res) => res.data); +const GetTypes = (type: string) => { + return instance.get(`/channeling/type/${type}`).then((res) => res.data); }; export const Doctor = { From 9b7dcac355d1241e27cae1607c3f2a1cfac91383 Mon Sep 17 00:00:00 2001 From: Madhura Pabudanan Date: Sat, 24 Dec 2022 09:13:06 +0530 Subject: [PATCH 5/5] feat(ui): :zap: session-search --- apps/frontend/user/pages/index.tsx | 29 ++++++- .../apps/channeling/channeling.controller.ts | 8 +- .../api/src/apps/channeling/channeling.dto.ts | 1 + .../src/apps/channeling/channeling.schema.ts | 1 + .../src/apps/channeling/channeling.service.ts | 3 +- .../components/channeling/searching/index.tsx | 1 + .../channeling/searching/searchBar.tsx | 57 ++++++++------ .../searching/searchres.stories.tsx | 29 +++++++ .../channeling/searching/searchres.tsx | 77 +++++++++++++++++++ libs/ui/src/lib/components/common/payment.tsx | 7 +- 10 files changed, 182 insertions(+), 31 deletions(-) create mode 100644 libs/ui/src/lib/components/channeling/searching/searchres.stories.tsx create mode 100644 libs/ui/src/lib/components/channeling/searching/searchres.tsx diff --git a/apps/frontend/user/pages/index.tsx b/apps/frontend/user/pages/index.tsx index 33bef6f..71d1622 100644 --- a/apps/frontend/user/pages/index.tsx +++ b/apps/frontend/user/pages/index.tsx @@ -1,20 +1,44 @@ -import { SearchBar } from '@hospe/ui'; +import { SearchBar, SearchRes } from '@hospe/ui'; import { Center, SimpleGrid } from '@mantine/core'; import { Api } from '@hospe/next'; +import { useEffect, useState } from 'react'; export interface Formdata { Doctype: string; } +interface SearchData { + _id: string; + docType: string; + docFee: number; + time: string; + maximumPatients: number; + date: string; + docName: string; +} + +interface docFee { + docFee: number; +} + const IndexPage = () => { + const [session, setSession] = useState([]); + const [fee, setFee] = useState([]); + + useEffect(() => { + setSession([]); + }, []); + const onSubmit = async (values: Formdata) => { const data = await Api.Doctor.GetTypes(values.Doctype); + setSession(data); + setFee(data.docFee); }; const mockDataSearch = { searchData: [ { - specializations: ['Surgeon', 'Dentist', 'Cardiologist'], + specializations: ['Surgeon', 'ENT', 'VOG'], time: ['Any', 'Morning', 'Afternoon', 'Evening'], gender: ['Any', 'Male', 'Female'], }, @@ -38,6 +62,7 @@ const IndexPage = () => { {/* {items} */} +
); diff --git a/apps/services/api/src/apps/channeling/channeling.controller.ts b/apps/services/api/src/apps/channeling/channeling.controller.ts index b6919f0..0cc9939 100644 --- a/apps/services/api/src/apps/channeling/channeling.controller.ts +++ b/apps/services/api/src/apps/channeling/channeling.controller.ts @@ -69,7 +69,13 @@ router.post('/create-channeling', async (req, res) => { try { const docData = await FindOneEmployee(req.user.id); const docType = docData.specialization; - const data = await CreateChanneling(req.user.id, docType, req.body); + const docName = docData.name; + const data = await CreateChanneling( + req.user.id, + docType, + docName, + req.body + ); res.status(200).json(data); } catch (error) { ExpressErrorResponseHandler(res, error); diff --git a/apps/services/api/src/apps/channeling/channeling.dto.ts b/apps/services/api/src/apps/channeling/channeling.dto.ts index 5f2696e..1dd6266 100644 --- a/apps/services/api/src/apps/channeling/channeling.dto.ts +++ b/apps/services/api/src/apps/channeling/channeling.dto.ts @@ -5,6 +5,7 @@ export interface CreateChannelingDto { readonly time: string; readonly maximumPatients: number; readonly doctorFee: number; + readonly docName: string; } export type UpdateChannelingDto = Partial; diff --git a/apps/services/api/src/apps/channeling/channeling.schema.ts b/apps/services/api/src/apps/channeling/channeling.schema.ts index 8892580..7387f23 100644 --- a/apps/services/api/src/apps/channeling/channeling.schema.ts +++ b/apps/services/api/src/apps/channeling/channeling.schema.ts @@ -7,6 +7,7 @@ const ChannelingSchema = new Schema({ time: { type: String, required: true, index: -1 }, maximumPatients: { type: Number, required: true }, doctorFee: { type: Number, required: true }, + docName: { type: String, required: true }, }); export const ChannelingModel = model('Channeling', ChannelingSchema); diff --git a/apps/services/api/src/apps/channeling/channeling.service.ts b/apps/services/api/src/apps/channeling/channeling.service.ts index 8bab1df..c0fdc36 100644 --- a/apps/services/api/src/apps/channeling/channeling.service.ts +++ b/apps/services/api/src/apps/channeling/channeling.service.ts @@ -4,9 +4,10 @@ import { ChannelingModel } from './channeling.schema'; export const CreateChanneling = async ( docId: string, docType: string, + docName: string, params: CreateChannelingDto ) => { - return await ChannelingModel.create({ ...params, docId, docType }); + return await ChannelingModel.create({ ...params, docId, docType, docName }); }; export const FindOneChanneling = async (id: string) => { diff --git a/libs/ui/src/lib/components/channeling/searching/index.tsx b/libs/ui/src/lib/components/channeling/searching/index.tsx index d393228..42aa67f 100644 --- a/libs/ui/src/lib/components/channeling/searching/index.tsx +++ b/libs/ui/src/lib/components/channeling/searching/index.tsx @@ -1,3 +1,4 @@ export * from './profileCard'; export * from './resultCard'; export * from './searchBar'; +export * from './searchres'; diff --git a/libs/ui/src/lib/components/channeling/searching/searchBar.tsx b/libs/ui/src/lib/components/channeling/searching/searchBar.tsx index 9a923ba..8594dcd 100644 --- a/libs/ui/src/lib/components/channeling/searching/searchBar.tsx +++ b/libs/ui/src/lib/components/channeling/searching/searchBar.tsx @@ -8,6 +8,8 @@ import { NativeSelect, Select, Center, + Paper, + Group, } from '@mantine/core'; import { DatePicker } from '@mantine/dates'; import { useForm } from '@mantine/hooks'; @@ -42,29 +44,38 @@ export const SearchBar: FC = (props) => { props.onSubmit(form.values); }} > -
- ({ - backgroundColor: '#e6f3fa', - padding: theme.spacing.xl, - borderRadius: theme.radius.md, - })} - > - + +
+
+ + + +
+
diff --git a/libs/ui/src/lib/components/channeling/searching/searchres.stories.tsx b/libs/ui/src/lib/components/channeling/searching/searchres.stories.tsx new file mode 100644 index 0000000..0fb52f6 --- /dev/null +++ b/libs/ui/src/lib/components/channeling/searching/searchres.stories.tsx @@ -0,0 +1,29 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { SearchRes } from './searchres'; +import { searchDataProps } from './searchres'; + +export default { + component: SearchRes, + title: 'channeling/searching/SearchRes', +} as ComponentMeta; + +const mockdata: searchDataProps = { + searchData: [ + { + _id: '1', + docType: 'General', + docFee: 100, + time: '8.30 PM', + maximumPatients: 12, + date: '2022-08-15', + docName: 'Dr. John', + }, + ], +}; + +const Template: ComponentStory = () => ( + +); + +export const Primary = Template.bind({}); +Primary.args = {}; diff --git a/libs/ui/src/lib/components/channeling/searching/searchres.tsx b/libs/ui/src/lib/components/channeling/searching/searchres.tsx new file mode 100644 index 0000000..bb57312 --- /dev/null +++ b/libs/ui/src/lib/components/channeling/searching/searchres.tsx @@ -0,0 +1,77 @@ +import { Center, Group, ScrollArea, Text, Table } from '@mantine/core'; +import { FC } from 'react'; +import { Calendar, Clock, User } from 'tabler-icons-react'; +import { Payment } from '../../common/payment'; + +interface RowDetailsProps { + _id: string; + docType: string; + docFee: number; + time: string; + maximumPatients: number; + date: string; + docName: string; +} + +export interface searchDataProps { + searchData: RowDetailsProps[]; +} + +export const SearchRes: FC = ({ searchData }, doctorfee) => { + const rows = searchData.map((item) => ( + + {/* Appointment Date and time */} + + + + {item.date.slice(0, 10)} + + + + + {item.time.slice(11, -8)} + + + + + + {/* Doctor's name */} +
+ + {item.docName} + +
+
+ + + {item.docType} + +
+ + + + {/* View button */} +
+ + + +
+ + + )); + return ( + + + + + + + + + + + {rows} +
+
+ ); +}; diff --git a/libs/ui/src/lib/components/common/payment.tsx b/libs/ui/src/lib/components/common/payment.tsx index ebd16df..b09a1e3 100644 --- a/libs/ui/src/lib/components/common/payment.tsx +++ b/libs/ui/src/lib/components/common/payment.tsx @@ -1,5 +1,4 @@ import { FC, useState } from 'react'; -import { useForm } from '@mantine/form'; import { Text, Modal, @@ -10,7 +9,7 @@ import { TextInput, Image, } from '@mantine/core'; -import { BrandPaypal, Icons } from 'tabler-icons-react'; +import { BrandPaypal } from 'tabler-icons-react'; interface RowDetailsProps { amount: number; @@ -28,7 +27,7 @@ export const Payment: FC = ({ paymentData }) => { setOpened(false)}>
- ; + Checkout @@ -77,7 +76,7 @@ export const Payment: FC = ({ paymentData }) => { - + );