diff --git a/public/static/images/background_auth.jpg b/public/static/images/background_auth.jpg index 33e3c78..30b2521 100644 Binary files a/public/static/images/background_auth.jpg and b/public/static/images/background_auth.jpg differ diff --git a/src/app/consultation/create/page.tsx b/src/app/consultation/create/page.tsx new file mode 100644 index 0000000..8c5e48e --- /dev/null +++ b/src/app/consultation/create/page.tsx @@ -0,0 +1,14 @@ +"use client"; +import BaseLayout from "@/components/layouts/BaseLayout"; +import CreateConsultation from "@/components/page/consultation/CreateConsultation"; +import React from "react"; + +const page = () => { + return ( + + + + ); +}; + +export default page; diff --git a/src/app/consultation/update/page.tsx b/src/app/consultation/update/page.tsx new file mode 100644 index 0000000..4c042d8 --- /dev/null +++ b/src/app/consultation/update/page.tsx @@ -0,0 +1,14 @@ +"use client"; +import BaseLayout from "@/components/layouts/BaseLayout"; +import UpdateConsultation from "@/components/page/consultation/UpdateConsultation"; +import React from "react"; + +const page = () => { + return ( + + + + ); +}; + +export default page; diff --git a/src/components/page/auth/MainLogin/MainLogin.tsx b/src/components/page/auth/MainLogin/MainLogin.tsx index dd1b434..10d5c2e 100644 --- a/src/components/page/auth/MainLogin/MainLogin.tsx +++ b/src/components/page/auth/MainLogin/MainLogin.tsx @@ -52,7 +52,7 @@ export default function MainLogin() { http: authServices.login({ username: form.username, password: form.password, - deviceId: form.deviceId, + deviceId: form.username, }), }); }, @@ -142,7 +142,7 @@ export default function MainLogin() { icon={} /> -
+ {/*
@@ -159,7 +159,7 @@ export default function MainLogin() { showDone icon={} /> -
+
*/} {/* PASSWORD */}
diff --git a/src/components/page/consultation/PopupCreateConsultation/PopupCreateConsultation.tsx b/src/components/page/consultation/CreateConsultation/CreateConsultation.tsx similarity index 54% rename from src/components/page/consultation/PopupCreateConsultation/PopupCreateConsultation.tsx rename to src/components/page/consultation/CreateConsultation/CreateConsultation.tsx index b0fe972..2d0ac34 100644 --- a/src/components/page/consultation/PopupCreateConsultation/PopupCreateConsultation.tsx +++ b/src/components/page/consultation/CreateConsultation/CreateConsultation.tsx @@ -22,18 +22,30 @@ import patientServices, { import { QUERY_KEY } from "@/constant/config/enum"; import CustomButton from "@/components/customs/custom-button"; +import { useRouter } from "next/navigation"; +import InputForm from "@/components/utils/FormCustom/components/InputForm"; +import GridColumn from "@/components/layouts/GridColumn"; -export interface PopupCreateConsultationProps { - onClose: () => void; -} - -const PopupCreateConsultation = ({ onClose }: PopupCreateConsultationProps) => { +const CreateConsultation = () => { + const router = useRouter(); const queryClient = useQueryClient(); const [form, setForm] = useState<{ patientId: string; + chiefComplaint: string; + symptomsText: string; + vitalSigns: string; + diagnosis: string; + treatmentPlan: string; + doctorNotes: string; }>({ patientId: "", + chiefComplaint: "", + symptomsText: "", + vitalSigns: "", + diagnosis: "", + treatmentPlan: "", + doctorNotes: "", }); /* ========================= @@ -94,8 +106,7 @@ const PopupCreateConsultation = ({ onClose }: PopupCreateConsultationProps) => { queryClient.invalidateQueries({ queryKey: [QUERY_KEY.table_list_consultation], }); - - onClose(); + router.back(); }, }); @@ -108,8 +119,6 @@ const PopupCreateConsultation = ({ onClose }: PopupCreateConsultationProps) => {
- {/* CLOSE */} - - - {/* HEADER */} -
+
-

- Thêm phiên khám -

+ > +

+ Thêm phiên khám +

+
+
+ router.back()} + > + Hủy bỏ + + + + {createConsultationMutation.isPending + ? "Đang tạo..." + : "Tạo phiên khám"} + +
{/* BODY */}
-
+
@@ -183,40 +219,66 @@ const PopupCreateConsultation = ({ onClose }: PopupCreateConsultationProps) => { getOptionValue={(item: PatientItem) => item.id} />
+ {/* + + + + + + + + + + + */}
{/* FOOTER */} -
- - Hủy bỏ - - - - {createConsultationMutation.isPending - ? "Đang tạo..." - : "Tạo phiên khám"} - -
); }; -export default PopupCreateConsultation; +export default CreateConsultation; diff --git a/src/components/page/consultation/CreateConsultation/index.ts b/src/components/page/consultation/CreateConsultation/index.ts new file mode 100644 index 0000000..294ec6b --- /dev/null +++ b/src/components/page/consultation/CreateConsultation/index.ts @@ -0,0 +1 @@ +export { default } from "./CreateConsultation"; diff --git a/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx b/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx index b7f61f3..615d3cb 100644 --- a/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx +++ b/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx @@ -27,8 +27,8 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation"; import React, { useMemo, useState } from "react"; -import PopupUpdateConsultation from "../PopupUpdateConsultation"; -import PopupCreateConsultation from "../PopupCreateConsultation"; +import { PATH } from "@/constant/config"; +import Pagination from "@/components/customs/custom-pagination"; const MainPageConsultation = () => { const router = useRouter(); @@ -49,10 +49,6 @@ const MainPageConsultation = () => { const _keyword = searchParams.get("_keyword"); - const _create = searchParams.get("_create"); - - const _update = searchParams.get("_update"); - /* ========================= STATE ========================= */ @@ -112,6 +108,9 @@ const MainPageConsultation = () => { UPDATE QUERY ========================= */ + const page = _page ? Number(_page) : 1; + const pageSize = _pageSize ? Number(_pageSize) : 10; + const updateQuery = (key: string, value: string | number) => { const params = new URLSearchParams(searchParams.toString()); @@ -130,45 +129,21 @@ const MainPageConsultation = () => { router.push(queryString ? `?${queryString}` : pathname); }; - /* ========================= - CREATE POPUP - ========================= */ - - const handleOpenCreate = () => { - const params = new URLSearchParams(searchParams.toString()); - - params.set("_create", "true"); - - router.push(`?${params.toString()}`); - }; - - /* ========================= - UPDATE POPUP - ========================= */ - - const handleOpenUpdate = (item: ConsultationItem) => { - const params = new URLSearchParams(searchParams.toString()); - - params.set("_update", item.id); - - router.push(`?${params.toString()}`); - }; - /* ========================= CLOSE POPUP ========================= */ - const handleClosePopup = () => { - const params = new URLSearchParams(searchParams.toString()); + // const handleClosePopup = () => { + // const params = new URLSearchParams(searchParams.toString()); - params.delete("_create"); + // params.delete("_create"); - params.delete("_update"); + // params.delete("_update"); - const queryString = params.toString(); + // const queryString = params.toString(); - router.push(queryString ? `?${queryString}` : pathname); - }; + // router.push(queryString ? `?${queryString}` : pathname); + // }; /* ========================= DIALOG @@ -268,9 +243,10 @@ const MainPageConsultation = () => { variant="midnightBlue" fullWidth={false} icon={} - onClick={handleOpenCreate} + // onClick={handleOpenCreate} + href="/consultation/create" > - Thêm mới + Tạo phiên khám
@@ -310,6 +286,13 @@ const MainPageConsultation = () => { ), }, + { + title: "TÊN BỆNH NHÂN", + + render: (item: ConsultationItem) => ( + {item.patientName} + ), + }, { title: "MÃ PHIÊN KHÁM", @@ -365,24 +348,30 @@ const MainPageConsultation = () => { stateActive={item.status} listState={[ { - state: 1, - text: "Đang khám", + state: TYPE_STATUS.Draft, + text: "Đang chờ", textColor: "#000", backgroundColor: "#FFE4C4", }, { - state: 2, - text: "Hoàn thành", - textColor: "#fff", - backgroundColor: "#22c55e", + state: TYPE_STATUS.InProgress, + text: "Đang thực hiện", + textColor: "#000", + backgroundColor: "#ff3300", }, { - state: 3, + state: TYPE_STATUS.Completed, + text: "Hoàn thành", + textColor: "#000", + backgroundColor: "#3d69eb", + }, + { + state: TYPE_STATUS.Cancelled, text: "Đã hủy", - textColor: "#fff", - backgroundColor: "#ef4444", + textColor: "#000", + backgroundColor: "#cccc", }, ]} /> @@ -408,7 +397,7 @@ const MainPageConsultation = () => { size="sm" disabled={isDisabled} icon={} - onClick={() => handleOpenUpdate(item)} + href={`/consultation/update?_id=${item?.id}`} /> {/* CANCEL */} @@ -437,6 +426,14 @@ const MainPageConsultation = () => { ]} /> + updateQuery("_page", value)} + onSetPageSize={(value) => updateQuery("_pageSize", value)} + dependencies={[_pageSize, _keyword]} + /> {/* CANCEL DIALOG */} { titleCancel="Đóng" titleSubmit="Xác nhận" /> - - {/* CREATE */} - - - - - {/* UPDATE */} - - -
); }; diff --git a/src/components/page/consultation/PopupCreateConsultation/index.ts b/src/components/page/consultation/PopupCreateConsultation/index.ts deleted file mode 100644 index 2953914..0000000 --- a/src/components/page/consultation/PopupCreateConsultation/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./PopupCreateConsultation"; diff --git a/src/components/page/consultation/PopupUpdateConsultation/PopupUpdateConsultation.tsx b/src/components/page/consultation/PopupUpdateConsultation/PopupUpdateConsultation.tsx deleted file mode 100644 index 72c28e6..0000000 --- a/src/components/page/consultation/PopupUpdateConsultation/PopupUpdateConsultation.tsx +++ /dev/null @@ -1,281 +0,0 @@ -"use client"; - -import React, { useEffect, useState } from "react"; - -import { X } from "lucide-react"; - -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; - -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 { QUERY_KEY } from "@/constant/config/enum"; - -import { httpRequest } from "@/services"; - -import consultationServices, { - ConsultationDetail, -} from "@/services/consultationServices"; -import { ContextFormCustom } from "@/components/utils/FormCustom/contexts"; - -interface PopupUpdateConsultationProps { - id: string; - onClose: () => void; -} - -interface IUpdateConsul { - chiefComplaint: string; - symptomsText: string; - vitalSigns: string; - diagnosis: string; - treatmentPlan: string; - doctorNotes: string; -} - -const defaultForm: IUpdateConsul = { - chiefComplaint: "", - symptomsText: "", - vitalSigns: "", - diagnosis: "", - treatmentPlan: "", - doctorNotes: "", -}; - -const PopupUpdateConsultation = ({ - id, - onClose, -}: PopupUpdateConsultationProps) => { - const queryClient = useQueryClient(); - const [form, setForm] = useState(defaultForm); - - const consulDetailQuery = useQuery({ - queryKey: [QUERY_KEY.chi_tiet_phien_kham, id], - enabled: !!id, - queryFn: async () => { - const res = await httpRequest({ - showMessageFailed: true, - http: consultationServices.detailConsultations(id), - }); - return ( - res || { - id: "", - patientId: "", - sessionCode: "", - visitDate: "", - status: 1, - chiefComplaint: null, - symptomsText: null, - vitalSigns: null, - diagnosis: null, - treatmentPlan: null, - doctorNotes: null, - createdBy: "", - isDeleted: false, - } - ); - }, - }); - - useEffect(() => { - const consul = consulDetailQuery.data; - - if (!consul) return; - - setForm({ - chiefComplaint: consul.chiefComplaint || "", - symptomsText: consul.symptomsText || "", - vitalSigns: consul.vitalSigns || "", - diagnosis: consul.diagnosis || "", - treatmentPlan: consul.treatmentPlan || "", - doctorNotes: consul.doctorNotes || "", - }); - }, [consulDetailQuery.data]); - - /* ========================= - SUBMIT - ========================= */ - - const updateConsultationMutation = useMutation({ - mutationFn: async () => { - return httpRequest({ - showMessageFailed: true, - showMessageSuccess: true, - msgSuccess: "Cập nhật phiên khám thành công!", - http: consultationServices.putConsultations(id, { - chiefComplaint: form.chiefComplaint, - symptomsText: form.symptomsText, - vitalSigns: form.vitalSigns, - diagnosis: form.diagnosis, - treatmentPlan: form.treatmentPlan, - doctorNotes: form.doctorNotes, - }), - }); - }, - - onSuccess(data) { - if (!data) return; - - queryClient.invalidateQueries({ - queryKey: [QUERY_KEY.table_list_consultation], - }); - - queryClient.invalidateQueries({ - queryKey: [QUERY_KEY.chi_tiet_phien_kham, id], - }); - - onClose(); - }, - }); - - const handleSubmit = () => { - updateConsultationMutation.mutate(); - }; - - if (consulDetailQuery.isLoading) { - return ( -
- Đang tải dữ liệu... -
- ); - } - - return ( - -
- {/* CLOSE */} - - - {/* HEADER */} -
-

- Chỉnh sửa phiên khám -

-
- - {/* BODY */} -
-
- - -