feate:update project

This commit is contained in:
TuanVT 2026-05-25 18:48:35 +07:00
parent 2978cf2db0
commit 251854694e
3 changed files with 78 additions and 6 deletions

View File

@ -25,6 +25,8 @@ const MainPagePatient = () => {
const pathname = usePathname(); const pathname = usePathname();
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const [loadingDelete, setLoadingDelete] = useState(false);
const [openDeleteDialog, setOpenDeleteDialog] = useState(false); const [openDeleteDialog, setOpenDeleteDialog] = useState(false);
const [deleteItemId, setDeleteItemId] = useState<string>(""); const [deleteItemId, setDeleteItemId] = useState<string>("");
@ -140,6 +142,26 @@ const MainPagePatient = () => {
setOpenDeleteDialog(true); 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 * 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?" note="Bạn có chắc chắn muốn xóa bệnh nhân này?"
type="error" type="error"
onClose={handleClosePopup} onClose={handleClosePopup}
onSubmit={() => {}} onSubmit={handleDeletePatient}
titleCancel="Hủy" titleCancel="Hủy"
titleSubmit="Xác nhận" titleSubmit="Xác nhận"
/> />

View File

@ -15,8 +15,6 @@ import { httpRequest } from "@/services";
import patientServices from "@/services/patientServices"; import patientServices from "@/services/patientServices";
import CustomLoading from "@/components/customs/custom-loading";
export interface ICreatePatient { export interface ICreatePatient {
identificationNumber: string; identificationNumber: string;
fullName: string; fullName: string;
@ -168,6 +166,58 @@ const PopupCreatePatient = ({ onClose }: PropsPopupCreatePatient) => {
isRequired isRequired
/> />
<div className="space-y-3">
<label className="block text-sm font-medium text-gray-700">
Giới tính <span className="text-red-500">*</span>
</label>
<div className="flex items-center gap-6">
{/* NAM */}
<label className="flex cursor-pointer select-none items-center gap-2.5">
<input
id="male"
type="radio"
name="gender"
value={form.gender}
checked={form.gender === TYPE_GENDER.MALE}
onChange={() =>
setForm((prev: any) => ({
...prev,
gender: TYPE_GENDER.MALE,
}))
}
className="h-5 w-5 cursor-pointer"
/>
<span className="cursor-pointer text-sm font-medium text-gray-700">
Nam
</span>
</label>
{/* NỮ */}
<label className="flex cursor-pointer select-none items-center gap-2.5">
<input
id="female"
type="radio"
name="gender"
value={form.gender}
checked={form.gender === TYPE_GENDER.FEMALE}
onChange={() =>
setForm((prev: any) => ({
...prev,
gender: TYPE_GENDER.FEMALE,
}))
}
className="h-5 w-5 cursor-pointer"
/>
<span className="cursor-pointer text-sm font-medium text-gray-700">
Nữ
</span>
</label>
</div>
</div>
<InputForm <InputForm
label={ label={
<span> <span>

View File

@ -16,9 +16,9 @@ export enum TYPE_STATUS {
} }
export enum TYPE_GENDER { export enum TYPE_GENDER {
MALE = "male", MALE = "Nam",
FEMALE = "female", FEMALE = "Nữ",
OTHER = "other", OTHER = "Khác",
} }
export enum TYPE_DATE { export enum TYPE_DATE {