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 searchParams = useSearchParams();
const [loadingDelete, setLoadingDelete] = useState(false);
const [openDeleteDialog, setOpenDeleteDialog] = useState(false);
const [deleteItemId, setDeleteItemId] = useState<string>("");
@ -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"
/>

View File

@ -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
/>
<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
label={
<span>

View File

@ -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 {