"use client"; import CustomButton from "@/components/customs/custom-button"; import FormCustom from "@/components/utils/FormCustom"; import InputForm from "@/components/utils/FormCustom/components/InputForm"; import TextArea from "@/components/utils/FormCustom/components/TextArea"; import { ContextFormCustom } from "@/components/utils/FormCustom/contexts"; import { QUERY_KEY, TYPE_GENDER } from "@/constant/config/enum"; import { X } from "lucide-react"; import React, { useState } from "react"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { httpRequest } from "@/services"; import patientServices from "@/services/patientServices"; export interface ICreatePatient { identificationNumber: string; fullName: string; dateOfBirth: string; gender: string; phone: string; email: string; address: string; } export interface PropsPopupCreatePatient { onClose: () => void; } /* QUERY KEY */ // export const QUERY_KEY = { // table_list_patient: "table_list_patient", // }; const PopupCreatePatient = ({ onClose }: PropsPopupCreatePatient) => { const queryClient = useQueryClient(); const [form, setForm] = useState({ identificationNumber: "", fullName: "", dateOfBirth: "", gender: "", phone: "", email: "", address: "", }); const createPatientMutation = useMutation({ mutationFn: async () => { return await httpRequest({ showMessageFailed: true, showMessageSuccess: true, msgSuccess: "Tạo bệnh nhân thành công!", http: patientServices.createPatient({ identificationNumber: form.identificationNumber, fullName: form.fullName, dateOfBirth: form.dateOfBirth, gender: form.gender, phone: form.phone, email: form.email, address: form.address, }), }); }, onSuccess() { /* REFRESH LIST */ queryClient.invalidateQueries({ queryKey: [QUERY_KEY.table_list_patient], }); onClose(); }, }); const handleSubmit = () => { createPatientMutation.mutate(); }; return (
{/* CLOSE */} {/* HEADER */}

Thêm bệnh nhân

{/* BODY */}
Mã định danh * } placeholder="Mã định danh" name="identificationNumber" type="text" value={form.identificationNumber} isRequired /> Tên bệnh nhân * } placeholder="Tên bệnh nhân" name="fullName" type="text" value={form.fullName} isRequired />
{/* NAM */} {/* NỮ */}
Ngày sinh * } placeholder="Ngày sinh" name="dateOfBirth" type="Date" value={form.dateOfBirth} isRequired /> Số điện thoại * } placeholder="Số điện thoại" name="phone" type="text" value={form.phone} isRequired /> Email * } placeholder="Email" name="email" type="text" value={form.email} isRequired />