diff --git a/client/components/models/NotificationModel.tsx b/client/components/models/NotificationModel.tsx index 75df1ea8..ff224e5c 100644 --- a/client/components/models/NotificationModel.tsx +++ b/client/components/models/NotificationModel.tsx @@ -24,7 +24,7 @@ type Props = { notifications: Notification[]; }; -export default function NotificationModal({ open, setOpen, notifications }: Props) { +const NotificationModal = ({ open, setOpen, notifications }: Props)=> { const closeModal = () => { setOpen(false); }; @@ -72,4 +72,6 @@ export default function NotificationModal({ open, setOpen, notifications }: Prop ); -} \ No newline at end of file +} + +export default NotificationModal \ No newline at end of file diff --git a/client/components/models/admin/PatientProfileModel.tsx b/client/components/models/admin/PatientProfileModel.tsx index 4107106a..d174f755 100644 --- a/client/components/models/admin/PatientProfileModel.tsx +++ b/client/components/models/admin/PatientProfileModel.tsx @@ -12,7 +12,7 @@ import { } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; -import { IPatient } from "@/types"; +import IPatient from "@/types"; import { useChangeStatusAdmin } from "@/lib/hooks/admin/useAdminPatients"; import { toast } from "@/components/ui/use-toast"; import { Badge } from "@/components/ui/badge"; diff --git a/client/components/models/patient/UpdateProfilePatient.tsx b/client/components/models/patient/UpdateProfilePatient.tsx index 216713bf..14eb74f3 100644 --- a/client/components/models/patient/UpdateProfilePatient.tsx +++ b/client/components/models/patient/UpdateProfilePatient.tsx @@ -8,7 +8,7 @@ import { z } from "zod"; import { updateProfileFormValidation } from "@/components/forms/actions/userValidation"; import { zodResolver } from "@hookform/resolvers/zod"; import SubmitButton from "../../common/SubmitButton"; -import { IPatient } from "@/types"; +import IPatient from "@/types"; import CustomFormField from "../../common/CustomFormField"; import { FormFieldType } from "@/types/fromTypes"; import { BloodGroups, GenderOptions } from "@/constants"; diff --git a/client/components/models/patient/UploadProfileModel.tsx b/client/components/models/patient/UploadProfileModel.tsx index b3e40084..daf051b5 100644 --- a/client/components/models/patient/UploadProfileModel.tsx +++ b/client/components/models/patient/UploadProfileModel.tsx @@ -8,7 +8,7 @@ import { useForm, SubmitHandler } from "react-hook-form"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import SubmitButton from "../../common/SubmitButton"; -import { IPatient } from "@/types"; +import IPatient from "@/types"; import { Input } from "../../ui/input"; import { toast } from "../../ui/use-toast"; import getCroppedImg from "@/lib/utils/cropImage"; diff --git a/client/components/patient/profile/NavSection.tsx b/client/components/patient/profile/NavSection.tsx index 51504884..50ed8df6 100644 --- a/client/components/patient/profile/NavSection.tsx +++ b/client/components/patient/profile/NavSection.tsx @@ -3,7 +3,7 @@ import { useState } from "react"; import Image from "next/image"; import { Card, CardContent } from "@/components/ui/card"; -import { IPatient } from "@/types"; +import IPatient from "@/types"; import UploadProfileModel from "@/components/models/patient/UploadProfileModel"; import { ButtonV2 } from "@/components/common/ButtonV2"; diff --git a/client/components/view/table/PatientsTable.tsx b/client/components/view/table/PatientsTable.tsx index e2029a89..a09c9829 100644 --- a/client/components/view/table/PatientsTable.tsx +++ b/client/components/view/table/PatientsTable.tsx @@ -7,7 +7,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { useGetPatientsAdmin } from "@/lib/hooks/admin/useAdminPatients"; import Pagination from "@/components/navigation/Pagination"; -import { IPatient } from "@/types"; +import IPatient from "@/types"; import AdminPatientProfileModel from "@/components/models/admin/PatientProfileModel"; import { useRouter } from "next/navigation"; import TableSkeleton from "@/components/skeletons/TableSkelton"; diff --git a/client/lib/api/patient/authenticationRoutes.ts b/client/lib/api/patient/authenticationRoutes.ts index 9b667020..6aab8c5b 100644 --- a/client/lib/api/patient/authenticationRoutes.ts +++ b/client/lib/api/patient/authenticationRoutes.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { IPatient } from "@/types"; +import IPatient from "@/types"; const axiosInstance = axios.create({ baseURL: `${process.env.NEXT_PUBLIC_API_URL}/patient/auth`, diff --git a/client/lib/api/patient/authorizedRoutes.ts b/client/lib/api/patient/authorizedRoutes.ts index 05975806..dd4b0693 100644 --- a/client/lib/api/patient/authorizedRoutes.ts +++ b/client/lib/api/patient/authorizedRoutes.ts @@ -1,4 +1,4 @@ -import { IPatient } from "@/types"; +import IPatient from "@/types"; import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"; const getAuthTokens = () => { diff --git a/server/src/domain/entities/CustomError.ts b/server/src/domain/entities/CustomError.ts index 333cb86d..fa2e577a 100644 --- a/server/src/domain/entities/CustomError.ts +++ b/server/src/domain/entities/CustomError.ts @@ -1,6 +1,6 @@ import { StatusCode } from "../../types"; -export default class AppError extends Error { +export default class CustomError extends Error { public statusCode: StatusCode; public code?: string; public details?: any; diff --git a/server/src/domain/entities/IAppointment.ts b/server/src/domain/entities/IAppointment.ts index ebd0fd37..d096d751 100644 --- a/server/src/domain/entities/IAppointment.ts +++ b/server/src/domain/entities/IAppointment.ts @@ -1,5 +1,5 @@ import IDoctor from "./IDoctor"; -import { IPatient } from "./IPatient"; +import IPatient from "./IPatient"; import ISlot from "./ISlot"; export enum AppointmentStatus { diff --git a/server/src/domain/entities/INotification.ts b/server/src/domain/entities/INotification.ts new file mode 100644 index 00000000..3f26ce07 --- /dev/null +++ b/server/src/domain/entities/INotification.ts @@ -0,0 +1,21 @@ +export enum NotificationStatus { + READ = 'read', + UNREAD = 'unread' +} +export enum NotificationTypes { + APPOINTMENT_CANCELED = 'appointment_canceled', + APPOINTMENT_CONFIRMED = 'appointment_confirmed', + APPOINTMENT_REMINDER = 'appointment_reminder', +} + +export default interface INotification { + readonly _id?: string; + readonly patientId?: string; + readonly doctorId?: string; + readonly type?: string; + readonly message?: string; + readonly createdAt?: Date; + readonly updatedAt?: Date; + readonly appointmentId?:string + status?: NotificationStatus, +} diff --git a/server/src/domain/entities/IPatient.ts b/server/src/domain/entities/IPatient.ts index 0d8bc2f5..765dc8fc 100644 --- a/server/src/domain/entities/IPatient.ts +++ b/server/src/domain/entities/IPatient.ts @@ -1,4 +1,4 @@ -export interface IPatient { +export default interface IPatient { readonly _id?: string; readonly createdAt?: string; readonly updatedAt?: string; diff --git a/server/src/domain/interface/repositories/IPatientRepository.ts b/server/src/domain/interface/repositories/IPatientRepository.ts index 686dfb1a..7316b8ec 100644 --- a/server/src/domain/interface/repositories/IPatientRepository.ts +++ b/server/src/domain/interface/repositories/IPatientRepository.ts @@ -1,4 +1,4 @@ -import { IPatient } from "../../entities/IPatient"; +import IPatient from "../../entities/IPatient"; import { PaginatedResult } from "../../../types"; export default interface IPatientRepository { diff --git a/server/src/infrastructure/database/NotificationMode.ts b/server/src/infrastructure/database/NotificationMode.ts new file mode 100644 index 00000000..1e9b6eda --- /dev/null +++ b/server/src/infrastructure/database/NotificationMode.ts @@ -0,0 +1,44 @@ +import { model, Schema } from "mongoose"; +import INotification, { NotificationStatus, NotificationTypes } from "../../domain/entities/INotification"; + +const notificationSchema = new Schema( + { + patientId: { + type: Schema.Types.ObjectId, + ref: "Patient", + index: true, + }, + doctorId: { + type: Schema.Types.ObjectId, + ref: "Doctor", + index: true, + }, + type: { + type: String, + enum: Object.values(NotificationTypes), + required: true, + }, + message: { + type: String, + required: true, + }, + status: { + type: String, + enum: Object.values(NotificationStatus), + default: NotificationStatus.UNREAD, + }, + appointmentId: { + type: Schema.Types.ObjectId, + ref: "Appointment", + required: false, + }, + }, + { + timestamps: true, + versionKey: false, + minimize: false + } +); + +const NotificationModel = model("Notification", notificationSchema); +export default NotificationModel; \ No newline at end of file diff --git a/server/src/infrastructure/database/PatientModel.ts b/server/src/infrastructure/database/PatientModel.ts index 792657a1..99d01694 100644 --- a/server/src/infrastructure/database/PatientModel.ts +++ b/server/src/infrastructure/database/PatientModel.ts @@ -1,5 +1,5 @@ import { model, Schema } from "mongoose"; -import { IPatient } from "../../domain/entities/IPatient"; +import IPatient from "../../domain/entities/IPatient"; const patientSchema = new Schema( { diff --git a/server/src/infrastructure/repositories/PatientRepository.ts b/server/src/infrastructure/repositories/PatientRepository.ts index 17f8d68a..54e812be 100644 --- a/server/src/infrastructure/repositories/PatientRepository.ts +++ b/server/src/infrastructure/repositories/PatientRepository.ts @@ -1,5 +1,5 @@ import CustomError from "../../domain/entities/CustomError"; -import { IPatient } from "../../domain/entities/IPatient"; +import IPatient from "../../domain/entities/IPatient"; import IPatientRepository from "../../domain/interface/repositories/IPatientRepository"; import { PaginatedResult, StatusCode } from "../../types"; import PatientModel from "../database/PatientModel"; diff --git a/server/src/use_case/admin/PatientUseCase.ts b/server/src/use_case/admin/PatientUseCase.ts index 03c0488f..4e06c087 100644 --- a/server/src/use_case/admin/PatientUseCase.ts +++ b/server/src/use_case/admin/PatientUseCase.ts @@ -1,5 +1,5 @@ import IPatientRepository from "../../domain/interface/repositories/IPatientRepository"; -import { IPatient } from "../../domain/entities/IPatient"; +import IPatient from "../../domain/entities/IPatient"; import { PaginatedResult } from "../../types"; import IValidatorService from "../../domain/interface/services/IValidatorService"; diff --git a/server/src/use_case/patient/AuthenticationUseCase.ts b/server/src/use_case/patient/AuthenticationUseCase.ts index bb0d1bf0..0a49c550 100644 --- a/server/src/use_case/patient/AuthenticationUseCase.ts +++ b/server/src/use_case/patient/AuthenticationUseCase.ts @@ -2,7 +2,7 @@ import ITokenService from "../../domain/interface/services/ITokenService"; import IOtpRepository from "../../domain/interface/repositories/IOtpRepository"; import IPatientRepository from "../../domain/interface/repositories/IPatientRepository"; import IEmailService from "../../domain/interface/services/IEmailService"; -import { IPatient } from "../../domain/entities/IPatient"; +import IPatient from "../../domain/entities/IPatient"; import { IPasswordServiceRepository } from "../../domain/interface/services/IPasswordServiceRepository"; import { StatusCode, UserRole } from "../../types"; import IValidatorService from "../../domain/interface/services/IValidatorService"; diff --git a/server/src/use_case/patient/PatientUseCases.ts b/server/src/use_case/patient/PatientUseCases.ts index bd094e4a..5f30e734 100644 --- a/server/src/use_case/patient/PatientUseCases.ts +++ b/server/src/use_case/patient/PatientUseCases.ts @@ -1,6 +1,6 @@ import IPatientRepository from "../../domain/interface/repositories/IPatientRepository"; import ICloudStorageService from "../../domain/interface/services/ICloudStorageService"; -import { IPatient } from "../../domain/entities/IPatient"; +import IPatient from "../../domain/entities/IPatient"; import IValidatorService from "../../domain/interface/services/IValidatorService"; import CustomError from "../../domain/entities/CustomError"; import { StatusCode } from "../../types";