handle disable button if no data include in page add doctor
This commit is contained in:
@@ -37,7 +37,6 @@ function AddDoctorPage() {
|
|||||||
{ name: "پنج شنبه", morning_time: ["", ""], evening_time: ["", ""] },
|
{ name: "پنج شنبه", morning_time: ["", ""], evening_time: ["", ""] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
<GeneralInformation
|
<GeneralInformation
|
||||||
@@ -71,7 +70,7 @@ function AddDoctorPage() {
|
|||||||
md:pt-[30px] pb-0 md:pb-[12px] lg:pb-[24px] px-0 md:px-[14px] lg:px-[26px] xl:px-[56px]"
|
md:pt-[30px] pb-0 md:pb-[12px] lg:pb-[24px] px-0 md:px-[14px] lg:px-[26px] xl:px-[56px]"
|
||||||
>
|
>
|
||||||
<Step value={value} />
|
<Step value={value} />
|
||||||
<div className="mt-[32px] px-[56px]">{components[value]}</div>
|
<div className="mt-[32px]">{components[value]}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import EditField from "@/app/component/EditField";
|
|||||||
import ContentText from "@/app/component/ContentText";
|
import ContentText from "@/app/component/ContentText";
|
||||||
import ArrowLeftPA from "@/components/icons/ArrowLeftPA";
|
import ArrowLeftPA from "@/components/icons/ArrowLeftPA";
|
||||||
import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect";
|
import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect";
|
||||||
|
import { checkAllValues } from "@/helper";
|
||||||
|
|
||||||
function Form({ setValue, parent, data, setData }) {
|
function Form({ setValue, parent, data, setData }) {
|
||||||
const changeData = (value, type, name) =>
|
const changeData = (value, type, name) =>
|
||||||
@@ -91,8 +92,9 @@ function Form({ setValue, parent, data, setData }) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="mt-[40px] w-full flex justify-end">
|
<div className="mt-[40px] w-full flex justify-end">
|
||||||
<Button
|
<Button
|
||||||
className="!bg-[#5559CE] !w-full md:!w-fit !shadow-none !rounded-[4px] !gap-[4px] !text-[#EFEFEF] !text-[14px] md:!text-[16px] !font-medium"
|
className="!w-full md:!w-fit !shadow-none !rounded-[4px] !gap-[4px] !text-[#EFEFEF] !text-[14px] md:!text-[16px] !font-medium"
|
||||||
onClick={() => setValue((prev) => prev + 1)}
|
onClick={() => setValue((prev) => prev + 1)}
|
||||||
|
disabled={!checkAllValues(data)}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
>
|
>
|
||||||
ثبت اطلاعات
|
ثبت اطلاعات
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Head from "./Head";
|
|||||||
|
|
||||||
function GeneralInformation({ setValue, parent, data, setData }) {
|
function GeneralInformation({ setValue, parent, data, setData }) {
|
||||||
return (
|
return (
|
||||||
<div className="opacity-page pb-[24px]">
|
<div className="opacity-page pb-[24px] px-[56px]">
|
||||||
<Head />
|
<Head />
|
||||||
<Form
|
<Form
|
||||||
parent={parent}
|
parent={parent}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import ArrowLeftPA from "@/components/icons/ArrowLeftPA";
|
import ArrowLeftPA from "@/components/icons/ArrowLeftPA";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import Form from "./Form";
|
import Form from "./Form";
|
||||||
|
import { checkAllValues } from "@/helper";
|
||||||
|
|
||||||
function OfficeInformation({ setValue, parent, data, setData }) {
|
function OfficeInformation({ setValue, parent, data, setData }) {
|
||||||
return (
|
return (
|
||||||
<div className="opacity-page pb-[24px]">
|
<div className="opacity-page pb-[24px] px-[56px]">
|
||||||
<Form parent={parent} setData={setData} data={data.office} />
|
<Form parent={parent} setData={setData} data={data.office} />
|
||||||
<div className="mt-[40px] w-full flex justify-end">
|
<div className="mt-[40px] w-full flex justify-end">
|
||||||
<Button
|
<Button
|
||||||
className="!bg-[#5559CE] !w-full md:!w-fit !shadow-none !rounded-[4px] !gap-[4px] !text-[#EFEFEF] !text-[14px] md:!text-[16px] !font-medium"
|
className="!w-full md:!w-fit !shadow-none !rounded-[4px] !gap-[4px] !text-[#EFEFEF] !text-[14px] md:!text-[16px] !font-medium"
|
||||||
|
disabled={!checkAllValues(data)}
|
||||||
onClick={() => setValue((prev) => prev + 1)}
|
onClick={() => setValue((prev) => prev + 1)}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -21,3 +21,23 @@ export const convertToJalali = (date) => {
|
|||||||
|
|
||||||
export const handleTwoLength = (value) =>
|
export const handleTwoLength = (value) =>
|
||||||
String(value).length === 1 ? `0${value}` : value;
|
String(value).length === 1 ? `0${value}` : value;
|
||||||
|
|
||||||
|
export const checkAllValues = (data) => {
|
||||||
|
for (let key in data) {
|
||||||
|
if (typeof data[key] === "object" && data[key] !== null) {
|
||||||
|
if ("value" in data[key]) {
|
||||||
|
if (!data[key].value) {
|
||||||
|
console.log(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!checkAllValues(data[key])) {
|
||||||
|
console.log(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(true);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user