diff --git a/src/common/funcs/optionConvert.ts b/src/common/funcs/optionConvert.ts index 68f54ac..a945544 100644 --- a/src/common/funcs/optionConvert.ts +++ b/src/common/funcs/optionConvert.ts @@ -108,6 +108,45 @@ export function getTextAddress(detailAddress: any, address?: string): string { return parts.length ? parts.join(", ") : "---"; } +export const formatDateOfBirth = (value: string) => { + const digits = value.replace(/\D/g, "").slice(0, 8); + if (digits.length <= 2) return digits; + if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`; + return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4)}`; +}; + +export const parseDateOfBirth = (value: string) => { + const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/); + if (!match) return null; + + const day = Number(match[1]); + const month = Number(match[2]); + const year = Number(match[3]); + + const parsedDate = new Date(year, month - 1, day); + + if ( + parsedDate.getFullYear() !== year || + parsedDate.getMonth() !== month - 1 || + parsedDate.getDate() !== day + ) { + return null; + } + + return parsedDate; +}; + +export const formatToISODate = (date: Date | null): string => { + if (!date) return ""; + + const year = date.getFullYear(); + // Đảm bảo tháng và ngày luôn có 2 chữ số (VD: 02, 12) + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + + return `${year}-${month}-${day}`; // Kết quả: "2001-02-12" +}; + export function numberToWords(number: number) { if (typeof number !== "number" || isNaN(number)) { return "Không hợp lệ"; diff --git a/src/components/page/auth/MainLogin/MainLogin.tsx b/src/components/page/auth/MainLogin/MainLogin.tsx index 215b899..78e8b9e 100644 --- a/src/components/page/auth/MainLogin/MainLogin.tsx +++ b/src/components/page/auth/MainLogin/MainLogin.tsx @@ -78,6 +78,11 @@ export default function MainLogin() { // Kiểm tra nhanh điều kiện dữ liệu trước khi trigger API if (!form.username || !form.password) return; + // if (form.password.length < 6) { + // alert("Mật khẩu phải có ít nhất 6 ký tự"); + // return; + // } + if (isRememberPassword) { store.dispatch( setDataLoginStorage({ @@ -136,6 +141,7 @@ export default function MainLogin() { onClean isRequired isBlur + min={6} showDone icon={} /> diff --git a/src/components/page/auth/MainRegister/MainRegister.tsx b/src/components/page/auth/MainRegister/MainRegister.tsx index 1936ff1..3acca9a 100644 --- a/src/components/page/auth/MainRegister/MainRegister.tsx +++ b/src/components/page/auth/MainRegister/MainRegister.tsx @@ -154,6 +154,7 @@ export default function MainRegister() { onClean isRequired isBlur + min={6} showDone icon={} /> diff --git a/src/components/page/consultation/CreateConsultation/CreateConsultation.tsx b/src/components/page/consultation/CreateConsultation/CreateConsultation.tsx index be798de..4d6b5dd 100644 --- a/src/components/page/consultation/CreateConsultation/CreateConsultation.tsx +++ b/src/components/page/consultation/CreateConsultation/CreateConsultation.tsx @@ -1,26 +1,16 @@ "use client"; import React, { useMemo, useState } from "react"; - -import { X } from "lucide-react"; - import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; - import FormCustom from "@/components/utils/FormCustom/FormCustom"; - import SelectForm from "@/components/utils/FormCustom/components/SelectForm"; - import { httpRequest } from "@/services"; - import consultationServices from "@/services/consultationServices"; - import patientServices, { PatientItem, PatientResponse, } from "@/services/patientServices"; - import { QUERY_KEY } from "@/constant/config/enum"; - import CustomButton from "@/components/customs/custom-button"; import { useRouter, useSearchParams } from "next/navigation"; import InputForm from "@/components/utils/FormCustom/components/InputForm"; @@ -137,6 +127,9 @@ const CreateConsultation = () => { if (!form?.patientId) { return toastWarn({ msg: "Vui lòng chọn bệnh nhân" }); } + if (!form?.specialtyIds) { + return toastWarn({ msg: "Vui lòng chọn chuyên khoa" }); + } createConsultationMutation.mutate(); }; @@ -174,7 +167,7 @@ const CreateConsultation = () => {
+ Bệnh nhân * @@ -205,7 +198,11 @@ const CreateConsultation = () => {
+ Lý do khám * + + } name="chiefComplaint" type="text" value={form.chiefComplaint} @@ -217,7 +214,11 @@ const CreateConsultation = () => { /> + Triệu chứng * + + } name="symptomsText" placeholder="Nhập triệu chứng" isRequired @@ -229,7 +230,12 @@ const CreateConsultation = () => { + Chỉ số huyết áp, chỉ số mạch{" "} + * + + } name="vitalSigns" placeholder="Nhập chỉ số huyết áp, chỉ số mạch" value={form.vitalSigns} @@ -242,7 +248,12 @@ const CreateConsultation = () => {
- label="Chuyên khoa" + label={ + + Chuyên khoa + * + + } text="chuyên khoa" title="Chọn chuyên khoa" placeholder="Chọn nhiều chuyên khoa..." diff --git a/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx b/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx index dc1a5b1..ddca924 100644 --- a/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx +++ b/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx @@ -575,26 +575,34 @@ const DetailConsultation = () => {

CHUYÊN KHOA

- -

{selectedSpecialty.specialtyName || "---"}

+ {/* Thêm class để bọc text */} +

+ {selectedSpecialty.specialtyName || "---"} +

CHẨN ĐOÁN

- -

{selectedSpecialty.diagnosis || "---"}

+ {/* Thêm class để bọc text */} +

+ {selectedSpecialty.diagnosis || "---"} +

GHI CHÚ KHÁM

- -

{selectedSpecialty.specialtyNotes || "---"}

+ {/* Thêm class để bọc text */} +

+ {selectedSpecialty.specialtyNotes || "---"} +

THỦ THUẬT

- -

{selectedSpecialty.procedureNotes || "---"}

+ {/* Thêm class để bọc text */} +

+ {selectedSpecialty.procedureNotes || "---"} +

diff --git a/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx b/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx index 36cf89f..1cb150c 100644 --- a/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx +++ b/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx @@ -352,7 +352,7 @@ const MainPageConsultation = () => { }, { uuid: TYPE_STATUS.PendingPrescription, - name: "Chờ nhận thuốc/kính", + name: "Chờ nhận thuốc", }, { uuid: TYPE_STATUS.Completed, diff --git a/src/components/page/consultation/UpdateConsultation/UpdateConsultation.tsx b/src/components/page/consultation/UpdateConsultation/UpdateConsultation.tsx index 0b63318..59bbbe0 100644 --- a/src/components/page/consultation/UpdateConsultation/UpdateConsultation.tsx +++ b/src/components/page/consultation/UpdateConsultation/UpdateConsultation.tsx @@ -18,6 +18,7 @@ import consultationServices, { import uploadServices from "@/services/uploadServices"; import UploadMultipleFile from "@/components/utils/UploadMultipleFile"; import TextArea from "@/components/utils/FormCustom/components/TextArea"; +import { toastWarn } from "@/common/funcs/toast"; /* ========================= TYPES @@ -247,7 +248,11 @@ const UpdateConsultation = () => { {/* GENERAL INFO (PATIENT) */} + Bệnh nhân * + + } name="patientInfo" type="text" // Hiển thị Tên bệnh nhân - SĐT hoặc CCCD dựa trên API detail trả về @@ -268,7 +273,11 @@ const UpdateConsultation = () => { + Lý do khám * + + } name="chiefComplaint" type="text" value={form.chiefComplaint} @@ -280,7 +289,11 @@ const UpdateConsultation = () => { /> + Triệu chứng * + + } name="symptomsText" placeholder="Nhập triệu chứng" isRequired @@ -292,7 +305,12 @@ const UpdateConsultation = () => { + Chỉ số huyết áp, chỉ số mạch{" "} + * + + } name="vitalSigns" placeholder="Nhập chỉ số huyết áp, chỉ số mạch" value={form.vitalSigns} @@ -304,7 +322,11 @@ const UpdateConsultation = () => { + Chẩn đoán * + + } name="diagnosis" placeholder="Nhập chẩn đoán" value={form.diagnosis} @@ -316,7 +338,11 @@ const UpdateConsultation = () => { + Kế hoạch điều trị * + + } name="treatmentPlan" placeholder="Nhập kế hoạch điều trị" value={form.treatmentPlan} @@ -328,7 +354,11 @@ const UpdateConsultation = () => { + Ghi chú bác sĩ * + + } name="doctorNotes" placeholder="Nhập ghi chú" value={form.doctorNotes} @@ -372,7 +402,12 @@ const UpdateConsultation = () => {