Skip to content

Commit

Permalink
Notification model and entitie added
Browse files Browse the repository at this point in the history
  • Loading branch information
sinanptm committed Sep 22, 2024
1 parent 575d021 commit 9164ad5
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 18 deletions.
6 changes: 4 additions & 2 deletions client/components/models/NotificationModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -72,4 +72,6 @@ export default function NotificationModal({ open, setOpen, notifications }: Prop
</AlertDialogContent>
</AlertDialog>
);
}
}

export default NotificationModal
2 changes: 1 addition & 1 deletion client/components/models/admin/PatientProfileModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion client/components/models/patient/UpdateProfilePatient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion client/components/models/patient/UploadProfileModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion client/components/patient/profile/NavSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion client/components/view/table/PatientsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion client/lib/api/patient/authenticationRoutes.ts
Original file line number Diff line number Diff line change
@@ -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`,
Expand Down
2 changes: 1 addition & 1 deletion client/lib/api/patient/authorizedRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IPatient } from "@/types";
import IPatient from "@/types";
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";

const getAuthTokens = () => {
Expand Down
2 changes: 1 addition & 1 deletion server/src/domain/entities/CustomError.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion server/src/domain/entities/IAppointment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IDoctor from "./IDoctor";
import { IPatient } from "./IPatient";
import IPatient from "./IPatient";
import ISlot from "./ISlot";

export enum AppointmentStatus {
Expand Down
21 changes: 21 additions & 0 deletions server/src/domain/entities/INotification.ts
Original file line number Diff line number Diff line change
@@ -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,
}
2 changes: 1 addition & 1 deletion server/src/domain/entities/IPatient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface IPatient {
export default interface IPatient {
readonly _id?: string;
readonly createdAt?: string;
readonly updatedAt?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IPatient } from "../../entities/IPatient";
import IPatient from "../../entities/IPatient";
import { PaginatedResult } from "../../../types";

export default interface IPatientRepository {
Expand Down
44 changes: 44 additions & 0 deletions server/src/infrastructure/database/NotificationMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { model, Schema } from "mongoose";
import INotification, { NotificationStatus, NotificationTypes } from "../../domain/entities/INotification";

const notificationSchema = new Schema<INotification>(
{
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<INotification>("Notification", notificationSchema);
export default NotificationModel;
2 changes: 1 addition & 1 deletion server/src/infrastructure/database/PatientModel.ts
Original file line number Diff line number Diff line change
@@ -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<IPatient>(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion server/src/use_case/admin/PatientUseCase.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion server/src/use_case/patient/AuthenticationUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion server/src/use_case/patient/PatientUseCases.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit 9164ad5

Please sign in to comment.