diff --git a/src/components/page/patient/MainPagePatient/MainPagePatient.tsx b/src/components/page/patient/MainPagePatient/MainPagePatient.tsx index 6b5a5a8..f6f8c4a 100644 --- a/src/components/page/patient/MainPagePatient/MainPagePatient.tsx +++ b/src/components/page/patient/MainPagePatient/MainPagePatient.tsx @@ -25,6 +25,8 @@ const MainPagePatient = () => { const pathname = usePathname(); const searchParams = useSearchParams(); + const [loadingDelete, setLoadingDelete] = useState(false); + const [openDeleteDialog, setOpenDeleteDialog] = useState(false); const [deleteItemId, setDeleteItemId] = useState(""); @@ -140,6 +142,26 @@ const MainPagePatient = () => { setOpenDeleteDialog(true); }; + const handleDeletePatient = async () => { + if (!deleteItemId) return; + + try { + setLoadingDelete(true); + + await patientServices.deletePatient(deleteItemId); + + // đóng dialog + reset state + handleClosePopup(); + + // refetch list + patientQuery.refetch(); + } catch (error) { + console.error("Delete patient error:", error); + } finally { + setLoadingDelete(false); + } + }; + /** * DATA */ @@ -258,7 +280,7 @@ const MainPagePatient = () => { note="Bạn có chắc chắn muốn xóa bệnh nhân này?" type="error" onClose={handleClosePopup} - onSubmit={() => {}} + onSubmit={handleDeletePatient} titleCancel="Hủy" titleSubmit="Xác nhận" /> diff --git a/src/components/page/patient/PopupCreatePatient/PopupCreatePatient.tsx b/src/components/page/patient/PopupCreatePatient/PopupCreatePatient.tsx index 8aa2ebb..09cf363 100644 --- a/src/components/page/patient/PopupCreatePatient/PopupCreatePatient.tsx +++ b/src/components/page/patient/PopupCreatePatient/PopupCreatePatient.tsx @@ -15,8 +15,6 @@ import { httpRequest } from "@/services"; import patientServices from "@/services/patientServices"; -import CustomLoading from "@/components/customs/custom-loading"; - export interface ICreatePatient { identificationNumber: string; fullName: string; @@ -168,6 +166,58 @@ const PopupCreatePatient = ({ onClose }: PropsPopupCreatePatient) => { isRequired /> +
+ + +
+ {/* NAM */} + + + {/* NỮ */} + +
+
+ diff --git a/src/constant/config/enum.ts b/src/constant/config/enum.ts index e09d018..83c9b10 100644 --- a/src/constant/config/enum.ts +++ b/src/constant/config/enum.ts @@ -16,9 +16,9 @@ export enum TYPE_STATUS { } export enum TYPE_GENDER { - MALE = "male", - FEMALE = "female", - OTHER = "other", + MALE = "Nam", + FEMALE = "Nữ", + OTHER = "Khác", } export enum TYPE_DATE {