diff --git a/app/component/uploadFile/Crop.js b/app/component/uploadFile/Crop.js
index ccda35f..e4bf9df 100644
--- a/app/component/uploadFile/Crop.js
+++ b/app/component/uploadFile/Crop.js
@@ -1,15 +1,19 @@
import { Button } from "@mui/material";
import { useState } from "react";
import Cropper from "react-easy-crop";
-import { cropImage } from "./cropImg";
+import { cropImage, dataURLtoFile } from "./cropImg";
function Crop({ data, uploadImg, handleClose }) {
const [crop, setCrop] = useState({ x: 0, y: 0 });
const [zoom, setZoom] = useState(1);
const [croppedAreaPixels, setCroppedAreaPixels] = useState(null);
- const onComplete = (imagePromisse) =>
- imagePromisse.then((image) => uploadImg(image));
+ const onComplete = async (imagePromise) => {
+ const dataUrl = await imagePromise;
+ const file = dataURLtoFile(dataUrl, "cropped-image.jpg");
+
+ uploadImg({ blob: dataUrl, file });
+ };
return (
diff --git a/app/component/uploadFile/cropImg.js b/app/component/uploadFile/cropImg.js
index 31655de..8dea372 100644
--- a/app/component/uploadFile/cropImg.js
+++ b/app/component/uploadFile/cropImg.js
@@ -21,7 +21,7 @@ async function getCroppedImg(imageSrc, pixelCrop) {
ctx.drawImage(
image,
safeArea / 2 - image.width * 0.5,
- safeArea / 2 - image.height * 0.5,
+ safeArea / 2 - image.height * 0.5
);
const data = ctx.getImageData(0, 0, safeArea, safeArea);
@@ -31,12 +31,26 @@ async function getCroppedImg(imageSrc, pixelCrop) {
ctx.putImageData(
data,
Math.round(0 - safeArea / 2 + image.width * 0.5 - pixelCrop.x),
- Math.round(0 - safeArea / 2 + image.height * 0.5 - pixelCrop.y),
+ Math.round(0 - safeArea / 2 + image.height * 0.5 - pixelCrop.y)
);
return canvas.toDataURL("image/jpeg");
}
+export const dataURLtoFile = (dataurl, filename) => {
+ const arr = dataurl.split(",");
+ const mime = arr[0].match(/:(.*?);/)[1];
+ const bstr = atob(arr[1]);
+ let n = bstr.length;
+ const u8arr = new Uint8Array(n);
+
+ while (n--) {
+ u8arr[n] = bstr.charCodeAt(n);
+ }
+
+ return new File([u8arr], filename, { type: mime });
+};
+
export const cropImage = async (image, croppedAreaPixels, onError) => {
try {
const croppedImage = await getCroppedImg(image, croppedAreaPixels);
diff --git a/app/component/uploadFile/index.js b/app/component/uploadFile/index.js
index 964132b..a10d9c5 100644
--- a/app/component/uploadFile/index.js
+++ b/app/component/uploadFile/index.js
@@ -54,7 +54,7 @@ function UploadFile({ image, setImage }) {
diff --git a/app/dashboard/page.js b/app/dashboard/page.js
index 5f704e7..ae44760 100644
--- a/app/dashboard/page.js
+++ b/app/dashboard/page.js
@@ -9,6 +9,7 @@ import { redirect } from "next/navigation";
export default async function Dashboard({ searchParams }) {
const { matchedCity } = getStateInfo();
const user = await getUser();
+
const ability = defineAbilitiesFor(user);
const cookieStore = cookies();
const token = cookieStore.get("access_token");
diff --git a/app/panel/(layout)/layout.js b/app/panel/(layout)/layout.js
index 09f05e5..c15e8af 100644
--- a/app/panel/(layout)/layout.js
+++ b/app/panel/(layout)/layout.js
@@ -1,6 +1,16 @@
import Content from "@/components/panel/Content";
+import { defineAbilitiesFor } from "@/lib/ability";
+import { getUser } from "@/lib/auth";
+import { redirect } from "next/navigation";
+
+async function LayoutPanel({ children }) {
+ const user = await getUser();
+ const ability = defineAbilitiesFor(user);
+
+ if (!ability.can("access", "Panel")) {
+ return redirect("/");
+ }
-function LayoutPanel({ children }) {
return
;
}
diff --git a/components/panel/addDoctor/Step.js b/components/panel/addDoctor/Step.js
deleted file mode 100644
index 74901b0..0000000
--- a/components/panel/addDoctor/Step.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import CalendarTick from "@/components/icons/CalendarTick";
-import LocationAdd from "@/components/icons/LocationAdd";
-import UserEdit from "@/components/icons/UserEdit";
-
-function Step({ value }) {
- const list = [
- { icon:
= 0} />, name: "اطلاعات عمومی" },
- { icon: = 1} />, name: "اطلاعات مطب" },
- { icon: = 2} />, name: "روزهای کاری" },
- ];
-
- return (
-
- {list.map((item, idx) => (
- -
-
-
= idx
- ? "before:right-0 !bg-transparent delay-700"
- : "before:-right-full"
- }`}
- >
-
{item.icon}
-
-
= idx
- ? "font-bold text-[#5559CE]"
- : "font-normal text-[#616161] dark:text-[#a1a1a1]"
- }`}
- >
- {item.name}
-
-
- {list.length > idx + 1 && (
- idx ? "before:right-0" : "before:-right-full"}`}
- >
- )}
-
- ))}
-
- );
-}
-
-export default Step;
diff --git a/components/panel/addDoctor/defaultState.js b/components/panel/addDoctor/defaultState.js
index d5b146e..c1e5a3d 100644
--- a/components/panel/addDoctor/defaultState.js
+++ b/components/panel/addDoctor/defaultState.js
@@ -1,72 +1,15 @@
export const defaultState = {
- general: {
- name: { value: "", placeholder: "", isEdit: true },
- medical_system_number: {
- value: "",
- placeholder: 1741025645,
- isEdit: true,
- },
- expertise: { value: "", placeholder: "دندان پزشکی", isEdit: true },
- description: { value: "", isEdit: true },
- skills: { value: "", isEdit: true },
- time_work: { value: "", isEdit: true },
- degree: { value: "", isEdit: true },
+ name: { value: "", placeholder: "", isEdit: true },
+ medical_system_number: {
+ value: "",
+ placeholder: 1741025645,
+ isEdit: true,
},
- office: {
- address: { value: "مپ", isEdit: true },
- phone: { value: "", placeholder: 1741025645, isEdit: true },
- office_number1: { value: "", isEdit: true },
- state: { value: "", isEdit: true },
- city: { value: "", isEdit: true },
- },
- work_day: [
- {
- name: "شنبه",
- number_turns: { value: 1, isEdit: true },
- turn_time: "",
- workplace: "",
- morning_time: ["", ""],
- evening_time: ["", ""],
- },
- {
- name: "یکشنبه",
- number_turns: { value: 1, isEdit: true },
- turn_time: "",
- workplace: "",
- morning_time: ["", ""],
- evening_time: ["", ""],
- },
- {
- name: "دوشنبه",
- number_turns: { value: 1, isEdit: true },
- turn_time: "",
- workplace: "",
- morning_time: ["", ""],
- evening_time: ["", ""],
- },
- {
- name: "سه شنبه",
- number_turns: { value: 1, isEdit: true },
- turn_time: "",
- workplace: "",
- morning_time: ["", ""],
- evening_time: ["", ""],
- },
- {
- name: "چهار شنبه",
- number_turns: { value: 1, isEdit: true },
- turn_time: "",
- workplace: "",
- morning_time: ["", ""],
- evening_time: ["", ""],
- },
- {
- name: "پنج شنبه",
- number_turns: { value: 1, isEdit: true },
- turn_time: "",
- workplace: "",
- morning_time: ["", ""],
- evening_time: ["", ""],
- },
- ],
+ expertise: { value: "", placeholder: "دندان پزشکی", isEdit: true },
+ description: { value: "", isEdit: true },
+ skills: { value: "", isEdit: true },
+ time_work: { value: "", isEdit: true },
+ phone: { value: "", placeholder: "", isEdit: true },
+ degree: { value: "", isEdit: true },
+ gender: { value: "woman", isEdit: true },
};
diff --git a/components/panel/addDoctor/listMenu/generalInformation/form/FieldDate.js b/components/panel/addDoctor/form/fields/FieldDate.js
similarity index 100%
rename from components/panel/addDoctor/listMenu/generalInformation/form/FieldDate.js
rename to components/panel/addDoctor/form/fields/FieldDate.js
diff --git a/components/panel/addDoctor/listMenu/generalInformation/form/RadioGender.js b/components/panel/addDoctor/form/fields/RadioGender.js
similarity index 77%
rename from components/panel/addDoctor/listMenu/generalInformation/form/RadioGender.js
rename to components/panel/addDoctor/form/fields/RadioGender.js
index 24ddcb9..0768993 100644
--- a/components/panel/addDoctor/listMenu/generalInformation/form/RadioGender.js
+++ b/components/panel/addDoctor/form/fields/RadioGender.js
@@ -1,11 +1,12 @@
import { FormControlLabel, Radio, RadioGroup } from "@mui/material";
-function RadioGender() {
+function RadioGender({ changeData, name }) {
return (
changeData(e.target.value, "value", name)}
sx={{
"& .muirtl-j204z7-MuiFormControlLabel-root": {
marginLeft: "0 !important",
@@ -14,13 +15,13 @@ function RadioGender() {
>
}
className="!text-[#A1A1A1]"
/>
}
className="!text-[#A1A1A1]"
/>
diff --git a/components/panel/addDoctor/listMenu/generalInformation/form/Selector.js b/components/panel/addDoctor/form/fields/Selector.js
similarity index 100%
rename from components/panel/addDoctor/listMenu/generalInformation/form/Selector.js
rename to components/panel/addDoctor/form/fields/Selector.js
diff --git a/components/panel/addDoctor/listMenu/generalInformation/form/index.js b/components/panel/addDoctor/form/index.js
similarity index 79%
rename from components/panel/addDoctor/listMenu/generalInformation/form/index.js
rename to components/panel/addDoctor/form/index.js
index dcd8719..a268925 100644
--- a/components/panel/addDoctor/listMenu/generalInformation/form/index.js
+++ b/components/panel/addDoctor/form/index.js
@@ -1,7 +1,7 @@
-import FieldDate from "./FieldDate";
-import RadioGender from "./RadioGender";
-import SendReq from "./SendReq";
-import Selector from "./Selector";
+import FieldDate from "./fields/FieldDate";
+import RadioGender from "./fields/RadioGender";
+import SendReq from "./sendReq";
+import Selector from "./fields/Selector";
// Components
import EditField from "@/app/component/EditField";
@@ -16,19 +16,15 @@ const validate_medical_number = {
max: 9999999999,
};
-function Form({ setValue, parent, data, setData }) {
+function Form({ image, data, setData, resetData }) {
const changeData = (value, type, name) => {
-
type !== "isEdit" &&
setData((prev) => {
return {
...prev,
- [parent]: {
- ...prev[parent],
- [name]: {
- ...prev[parent][name],
- [type]: value,
- },
+ [name]: {
+ ...prev[name],
+ [type]: value,
},
};
});
@@ -73,6 +69,7 @@ function Form({ setValue, parent, data, setData }) {
@@ -111,12 +108,24 @@ function Form({ setValue, parent, data, setData }) {
name="skills"
/>
-
-
+
+
+
+
+
+
-
+
>
);
}
diff --git a/components/panel/addDoctor/listMenu/generalInformation/form/listSelector.js b/components/panel/addDoctor/form/listSelector.js
similarity index 100%
rename from components/panel/addDoctor/listMenu/generalInformation/form/listSelector.js
rename to components/panel/addDoctor/form/listSelector.js
diff --git a/components/panel/addDoctor/form/sendReq/function.js b/components/panel/addDoctor/form/sendReq/function.js
new file mode 100644
index 0000000..0249999
--- /dev/null
+++ b/components/panel/addDoctor/form/sendReq/function.js
@@ -0,0 +1,18 @@
+import moment from "jalali-moment";
+
+export const dateToTimestamp = (date) => {
+ const gregorianMoment = moment(date, "jYYYY/jM/jD").locale("fa");
+ const unixTimestamp = gregorianMoment.valueOf();
+ return unixTimestamp / 1000;
+};
+
+export const transformData = (data) => {
+ return {
+ name: data.name.value,
+ activity_time: dateToTimestamp(data.time_work.value),
+ doctor_mobile_number: data.phone.value,
+ degree: data.degree.value,
+ specialty: [Number(data.expertise.value)],
+ info: data.description.value,
+ };
+};
diff --git a/components/panel/addDoctor/form/sendReq/index.js b/components/panel/addDoctor/form/sendReq/index.js
new file mode 100644
index 0000000..9914298
--- /dev/null
+++ b/components/panel/addDoctor/form/sendReq/index.js
@@ -0,0 +1,66 @@
+import ArrowLeftPA from "@/components/icons/ArrowLeftPA";
+import { checkAllValues } from "@/helper";
+import { request } from "@/services/response";
+import { Button } from "@mui/material";
+import { useState } from "react";
+import { transformData } from "./function";
+import { defaultState } from "../../defaultState";
+
+function SendReq({ img, data, resetData }) {
+ const [loading, setLoading] = useState(false);
+
+ const saveData = (img) => {
+ let transformed = transformData(data);
+
+ if (img) {
+ transformed.image = [img];
+ }
+
+ request
+ .postDoctor(transformed)
+ .then(() => {
+ resetData();
+ setLoading(false);
+ })
+ .catch(() => {
+ setLoading(false);
+ });
+ };
+
+ const saveImg = () => {
+ setLoading(true);
+ if (img) {
+ request
+ .postImageUpload(img.file)
+ .then((res) => {
+ const imgId = res.fid[0].value;
+ saveData(imgId);
+ })
+ .catch((err) => {
+ setLoading(false);
+ });
+ } else {
+ saveData();
+ }
+ };
+
+ return (
+
+
+
+ );
+}
+
+export default SendReq;
diff --git a/components/panel/addDoctor/index.js b/components/panel/addDoctor/index.js
index 85d13ee..fdd06ad 100644
--- a/components/panel/addDoctor/index.js
+++ b/components/panel/addDoctor/index.js
@@ -1,59 +1,29 @@
"use client";
+import Form from "./form";
import { useState } from "react";
-
-// Tabs
-import WorkingDays from "./listMenu/workingDays";
-import OfficeInformation from "./listMenu/officeInformation";
-import GeneralInformation from "./listMenu/generalInformation";
-import Step from "./Step";
import { defaultState } from "./defaultState";
+import UploadFile from "@/app/component/uploadFile";
function AddDoctorPage() {
- const [value, setValue] = useState(0);
const [data, setData] = useState(defaultState);
-
+ const [image, setImage] = useState("");
+ console.log(data);
const resetData = () => {
setData(defaultState);
- setValue(0);
+ setImage();
};
- const components = [
- ,
- ,
- ,
- ];
-
return (
-
-
- پروفایل من
-
-
-
-
- {components[value]}
-
-
+
+
+
);
}
diff --git a/components/panel/addDoctor/listMenu/Menu.js b/components/panel/addDoctor/listMenu/Menu.js
deleted file mode 100644
index e2f49cc..0000000
--- a/components/panel/addDoctor/listMenu/Menu.js
+++ /dev/null
@@ -1,45 +0,0 @@
-import ArrowLeftPH from "@/components/icons/ArrowLeftPH";
-import { Button } from "@mui/material";
-
-function Menu({ value, open, setOpen, listTab, handleChange }) {
- return (
-
- {listTab.map((item, idx) => (
- -
-
- {listTab.length > idx + 1 && (
-
- )}
-
- ))}
-
- );
-}
-
-export default Menu;
diff --git a/components/panel/addDoctor/listMenu/Tab.js b/components/panel/addDoctor/listMenu/Tab.js
deleted file mode 100644
index 4f6b5fe..0000000
--- a/components/panel/addDoctor/listMenu/Tab.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import Tabs from "@/app/component/Tabs";
-
-function Tab({ value, listTab, handleChange }) {
- return (
-
- );
-}
-
-export default Tab;
diff --git a/components/panel/addDoctor/listMenu/generalInformation/Head.js b/components/panel/addDoctor/listMenu/generalInformation/Head.js
deleted file mode 100644
index 4a61abc..0000000
--- a/components/panel/addDoctor/listMenu/generalInformation/Head.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import UploadFile from "@/app/component/uploadFile";
-import { useState } from "react";
-
-function Head() {
- const [image, setImage] = useState("");
-
- return
;
-}
-
-export default Head;
diff --git a/components/panel/addDoctor/listMenu/generalInformation/form/SendReq.js b/components/panel/addDoctor/listMenu/generalInformation/form/SendReq.js
deleted file mode 100644
index 1f94017..0000000
--- a/components/panel/addDoctor/listMenu/generalInformation/form/SendReq.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import ArrowLeftPA from "@/components/icons/ArrowLeftPA";
-import { checkAllValues } from "@/helper";
-import { Button } from "@mui/material";
-
-function SendReq({ setValue, data }) {
- return (
-
-
-
- );
-}
-
-export default SendReq;
diff --git a/components/panel/addDoctor/listMenu/generalInformation/index.js b/components/panel/addDoctor/listMenu/generalInformation/index.js
deleted file mode 100644
index 3d5d50c..0000000
--- a/components/panel/addDoctor/listMenu/generalInformation/index.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import Form from "./form";
-import Head from "./Head";
-
-function GeneralInformation({ setValue, parent, data, setData }) {
- return (
-
-
-
-
- );
-}
-
-export default GeneralInformation;
diff --git a/components/panel/addDoctor/listMenu/index.js b/components/panel/addDoctor/listMenu/index.js
deleted file mode 100644
index 939020d..0000000
--- a/components/panel/addDoctor/listMenu/index.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import Menu from "./Menu";
-import Tab from "./Tab";
-
-function ListMenu({ value, open, setOpen, handleChange, listTab }) {
- return (
- <>
-
-
-
-
-
-
- >
- );
-}
-
-export default ListMenu;
diff --git a/components/panel/addDoctor/listMenu/officeInformation/Form.js b/components/panel/addDoctor/listMenu/officeInformation/Form.js
deleted file mode 100644
index 8e1e7a7..0000000
--- a/components/panel/addDoctor/listMenu/officeInformation/Form.js
+++ /dev/null
@@ -1,136 +0,0 @@
-"use client";
-
-import { city, state } from "./listSelector";
-import EditField from "@/app/component/EditField";
-import ContentText from "@/app/component/ContentText";
-import AddLocationP from "@/components/icons/AddLocationP";
-import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect";
-import { useState } from "react";
-import ModalMap from "./modal";
-
-// Data
-import statesData from "@/data/state.json";
-import citiesData from "@/data/city.json";
-import Selector from "./Selector";
-
-const validate_phone_number = {
- min: 1,
- max: 9999999999,
-};
-
-function Form({ parent, data, setData }) {
- const [open, setOpen] = useState(false);
-
- const handleClose = () => setOpen(false);
- const handleOpen = () => setOpen(true);
-
- const changeData = (value, type, name) =>
- type !== "isEdit" &&
- setData((prev) => {
- return {
- ...prev,
- [parent]: {
- ...prev[parent],
- [name]: {
- ...prev[parent][name],
- [type]: value,
- },
- },
- };
- });
-
- const updateNum = (value, type, name) => {
- const parseValue = +value;
- const { max } = validate_phone_number;
- const validateValue = parseValue > max ? data[name].value : value;
- changeData(validateValue, type, name);
- };
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
}
- isTransparent={true}
- placeholder="از روی نقشه انتخاب کنید..."
- iconGray={true}
- changeData={changeData}
- data={data?.address}
- name="address"
- />
-
-
-
-
-
-
-
-
-
- {/*
-
- */}
-
-
- >
- );
-}
-
-export default Form;
diff --git a/components/panel/addDoctor/listMenu/officeInformation/Selector.js b/components/panel/addDoctor/listMenu/officeInformation/Selector.js
deleted file mode 100644
index 3c1ba91..0000000
--- a/components/panel/addDoctor/listMenu/officeInformation/Selector.js
+++ /dev/null
@@ -1,83 +0,0 @@
-import BottomSelect from "@/components/icons/BottomSelect";
-import { Autocomplete, Button, TextField } from "@mui/material";
-import { styleTextSelectRight } from "@/mui";
-
-function Selector({ updateData, label, name, list }) {
- return (
- option.name || ""}
- // isOptionEqualToValue={(option, value) => option.id === value.id}
- className="!w-full !rounded-lg auto-complete-selector "
- onChange={(e, newValue) => {
- if (newValue) {
- updateData && updateData(newValue.id, "value", name);
- }
- }}
- sx={{
- ...styleTextSelectRight,
- // Hide Icon Number
- "& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":
- {
- display: "none",
- },
- "& input[type=number]": {
- MozAppearance: "textfield",
- },
- "& .MuiInputBase-input": { padding: "12.5px 14px !important" },
- "& .MuiInputBase-root": {
- borderRadius: 2,
- padding: "0 !important",
- height: {
- xs: "43px !important",
- sm: "43px !important",
- md: "46px !important",
- lg: "48px !important",
- },
- },
- "& .MuiOutlinedInput-notchedOutline": {
- border: "1px solid #D7D7D7",
- },
- "& .MuiInput-underline:hover:not(.Mui-disabled):before, .MuiOutlinedInput-notchedOutline":
- {
- borderColor: "#D7D7D7 !important",
- },
- "& .muirtl-1kiro5a-MuiInputBase-root-MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":
- {
- border: "1px solid #5559CE !important",
- },
- }}
- renderOption={(props, option) => (
-
- )}
- renderInput={(params) => (
-
-
-
- ),
- }}
- placeholder={label}
- sx={{
- borderRadius: "8px",
- }}
- />
- )}
- />
- );
-}
-
-export default Selector;
diff --git a/components/panel/addDoctor/listMenu/officeInformation/index.js b/components/panel/addDoctor/listMenu/officeInformation/index.js
deleted file mode 100644
index 1e5eac4..0000000
--- a/components/panel/addDoctor/listMenu/officeInformation/index.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import ArrowLeftPA from "@/components/icons/ArrowLeftPA";
-import { Button } from "@mui/material";
-import Form from "./Form";
-import { checkAllValues } from "@/helper";
-import ScrollToTop from "@/app/component/ScrollToTop";
-
-function OfficeInformation({ setValue, parent, data, setData }) {
- return (
-
-
-
-
-
-
-
- );
-}
-
-export default OfficeInformation;
diff --git a/components/panel/addDoctor/listMenu/officeInformation/listSelector.js b/components/panel/addDoctor/listMenu/officeInformation/listSelector.js
deleted file mode 100644
index 9185e9f..0000000
--- a/components/panel/addDoctor/listMenu/officeInformation/listSelector.js
+++ /dev/null
@@ -1,13 +0,0 @@
-export const state = [
- { label: "استان 1", id: 10 },
- { label: "استان 2", id: 20 },
- { label: "استان 3", id: 30 },
- { label: "استان 4", id: 40 },
-];
-
-export const city = [
- { label: "شهر 1", id: 10 },
- { label: "شهر 2", id: 20 },
- { label: "شهر 3", id: 30 },
- { label: "شهر 4", id: 40 },
-];
diff --git a/components/panel/addDoctor/listMenu/officeInformation/modal/index.js b/components/panel/addDoctor/listMenu/officeInformation/modal/index.js
deleted file mode 100644
index 1f1dfd5..0000000
--- a/components/panel/addDoctor/listMenu/officeInformation/modal/index.js
+++ /dev/null
@@ -1,53 +0,0 @@
-import { styleDefault } from "@/mui";
-import { Modal } from "@mui/material";
-import { useState } from "react";
-
-import MapPicker from "react-google-map-picker";
-
-const DefaultLocation = {
- lat: 9.912345921562734,
- lng: 105.97776559918576,
-};
-const DefaultZoom = 10;
-
-function ModalMap({ open, handleClose }) {
- const [defaultLocation, setDefaultLocation] = useState(DefaultLocation);
-
- const [location, setLocation] = useState(defaultLocation);
- const [zoom, setZoom] = useState(DefaultZoom);
-
- function handleChangeLocation(lat, lng) {
- setLocation({ lat: lat, lng: lng });
- }
-
- function handleChangeZoom(newZoom) {
- setZoom(newZoom);
- }
-
- function handleResetLocation() {
- setDefaultLocation({ ...DefaultLocation });
- setZoom(DefaultZoom);
- }
-
- return (
-
-
-
-
-
- );
-}
-
-export default ModalMap;
diff --git a/components/panel/addDoctor/listMenu/workingDays/List.js b/components/panel/addDoctor/listMenu/workingDays/List.js
deleted file mode 100644
index 4debeb5..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/List.js
+++ /dev/null
@@ -1,151 +0,0 @@
-import { useState } from "react";
-import ModalAddTime from "./modal/ModalAddTime";
-import {
- Button,
- Table,
- TableBody,
- TableCell,
- TableContainer,
- TableHead,
- TableRow,
-} from "@mui/material";
-import ContentModal from "./modal";
-import EditOrangeAD from "@/components/icons/EditOrangeAD";
-
-function List({ parent, data, setData, setIsDisable }) {
- const [open, setOpen] = useState(false);
- const handleOpen = () => setOpen(true);
- const handleClose = () => setOpen(false);
-
- const [dataChange, setDataChange] = useState({
- is_morgen: false,
- idx: undefined,
- });
-
- return (
-
-
-
-
-
-
- روز های هفته
-
-
- تایم صبح
-
-
- تایم عصر
-
-
-
-
- {data[parent].map((row, idx) => (
-
-
- {row.name}
-
-
- {row.morning_time[0] || row.morning_time[1] ? (
-
- ) : (
-
- )}
-
-
- {row.evening_time[0] || row.evening_time[1] ? (
-
- ) : (
-
- )}
-
-
- ))}
-
-
-
-
-
- );
-}
-
-export default List;
diff --git a/components/panel/addDoctor/listMenu/workingDays/SendReq.js b/components/panel/addDoctor/listMenu/workingDays/SendReq.js
deleted file mode 100644
index fa4ffe2..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/SendReq.js
+++ /dev/null
@@ -1,64 +0,0 @@
-import { Button } from "@mui/material";
-import ArrowLeftWhiteD from "@/components/icons/ArrowLeftWhiteD";
-import { request } from "@/services/response";
-import { useState } from "react";
-import moment from "jalali-moment";
-import { defaultState } from "../../defaultState";
-
-const dateToTimestamp = (date) => {
- const gregorianMoment = moment(date, "jYYYY/jM/jD").locale("fa");
- const unixTimestamp = gregorianMoment.valueOf();
- return unixTimestamp / 1000;
-};
-
-const transformData = (data) => {
- return {
- name: data.general.name.value,
- activity_time: dateToTimestamp(data.general.time_work.value),
- doctor_mobile_number: data.office.phone.value,
- state: [Number(data.office.state.value)],
- city: [Number(data.office.city.value)],
- degree: data.general.degree.value,
- specialty: [Number(data.general.expertise.value)],
- info: data.general.description.value,
- };
-};
-
-function SendReq({ data, isDisable, resetData }) {
- const [loading, setLoading] = useState(false);
-
- const saveData = () => {
- setLoading(true);
-
- const transformed = transformData(data);
-
- request
- .postDoctor(transformed)
- .then(() => {
- resetData();
- setLoading(false);
- })
- .catch(() => {
- setLoading(false);
- });
- };
-
- return (
-
- );
-}
-
-export default SendReq;
diff --git a/components/panel/addDoctor/listMenu/workingDays/index.js b/components/panel/addDoctor/listMenu/workingDays/index.js
deleted file mode 100644
index 06cc8f0..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/index.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import List from "./List";
-import { useState } from "react";
-import ScrollToTop from "@/app/component/ScrollToTop";
-import SendReq from "./SendReq";
-
-function WorkingDays({ parent, data, setData, resetData }) {
- const [isDisable, setIsDisable] = useState(false);
-
- return (
-
-
-
- لیست روزهای کاری
-
-
-
-
- );
-}
-
-export default WorkingDays;
diff --git a/components/panel/addDoctor/listMenu/workingDays/modal/Form.js b/components/panel/addDoctor/listMenu/workingDays/modal/Form.js
deleted file mode 100644
index 6194a3f..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/modal/Form.js
+++ /dev/null
@@ -1,122 +0,0 @@
-import { Button } from "@mui/material";
-import ContentText from "@/app/component/ContentText";
-import TimePickerField from "@/app/component/TimePickerField";
-import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect";
-import { turnTime, workplace } from "./listSelector";
-import EditField from "@/app/component/EditField";
-import { useState } from "react";
-
-const validate_number_turns = {
- min: 1,
- max: 10,
-};
-
-function Form({
- handleClose,
- isVacation,
- parent,
- setData,
- dataChange,
- data,
- value,
-}) {
- const [update, setUpdate] = useState(false);
- const updateData = (value, type, name) =>
- setData((prev) => {
- const newData = prev;
- newData[parent][dataChange.idx][name] = value;
- return newData;
- });
-
- const updateNum = (value, type, name) => {
- const prevData = data;
- const prevVal = data[parent][dataChange.idx][name].value;
- const parseValue = +value;
- const { max } = validate_number_turns;
- const validateValue = parseValue > max ? prevVal : value;
- data[parent][dataChange.idx][name].value = validateValue;
- setUpdate(!update);
- setData(prevData);
- };
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-export default Form;
diff --git a/components/panel/addDoctor/listMenu/workingDays/modal/ModalAddTime.js b/components/panel/addDoctor/listMenu/workingDays/modal/ModalAddTime.js
deleted file mode 100644
index 56f3fc6..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/modal/ModalAddTime.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import AddTimeP from "@/components/icons/AddTimeP";
-import { Button } from "@mui/material";
-import React from "react";
-
-function ModalAddTime({ handleOpen, isMorgen, idx, setDataChange }) {
- return (
-
-
-
- );
-}
-
-export default ModalAddTime;
diff --git a/components/panel/addDoctor/listMenu/workingDays/modal/Radios.js b/components/panel/addDoctor/listMenu/workingDays/modal/Radios.js
deleted file mode 100644
index 71b402e..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/modal/Radios.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import { FormControlLabel, Radio, RadioGroup } from "@mui/material";
-
-function Radios({ value, handleChange }) {
- return (
-
- }
- label="روز کاری"
- />
- }
- label="تعطیل"
- />
-
- );
-}
-
-export default Radios;
diff --git a/components/panel/addDoctor/listMenu/workingDays/modal/index.js b/components/panel/addDoctor/listMenu/workingDays/modal/index.js
deleted file mode 100644
index ee77993..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/modal/index.js
+++ /dev/null
@@ -1,71 +0,0 @@
-import CloseModalD from "@/components/icons/CloseModalD";
-import { styleDefault } from "@/mui";
-import { Box, Button, Modal } from "@mui/material";
-import Radios from "./Radios";
-import Form from "./Form";
-import { useState } from "react";
-import { checkTimes } from "@/helper";
-
-function ContentModal({
- open,
- data,
- setData,
- parent,
- dataChange,
- handleClose,
- setIsDisable,
-}) {
- const [value, setValue] = useState(0);
- const [isVacation, setIsVacation] = useState(false);
-
- const handleChange = (event) => {
- const valueRadio = +event.target.value;
-
- const newData = data[parent];
- const { idx, is_morgen } = dataChange;
- newData[idx][is_morgen ? "morning_time" : "evening_time"][0] = "تعطیل";
-
- setIsVacation(valueRadio);
- setValue(valueRadio);
- const disable = checkTimes(newData).includes(false);
- !disable && setIsDisable(disable);
- };
-
- const closeModal = () => {
- handleClose();
- setValue(0);
- };
-
- return (
-
-
-
-
- اضافه کردن روز کاری
-
-
-
-
-
-
-
-
-
- );
-}
-
-export default ContentModal;
diff --git a/components/panel/addDoctor/listMenu/workingDays/modal/listSelector.js b/components/panel/addDoctor/listMenu/workingDays/modal/listSelector.js
deleted file mode 100644
index b6127e9..0000000
--- a/components/panel/addDoctor/listMenu/workingDays/modal/listSelector.js
+++ /dev/null
@@ -1,27 +0,0 @@
-const numberTurns = [
- { id: "1", label: 1 },
- { id: "2", label: 2 },
- { id: "3", label: 3 },
-];
-
-const turnTime = [
- { id: 1, label: "00:05" },
- { id: 2, label: "00:10" },
- { id: 3, label: "00:15" },
- { id: 4, label: "00:20" },
- { id: 5, label: "00:25" },
- { id: 6, label: "00:30" },
- { id: 7, label: "00:40" },
- { id: 8, label: "00:50" },
- { id: 9, label: "01:00" },
- { id: 10, label: "01:15" },
- { id: 11, label: "01:30" },
-];
-
-const workplace = [
- { id: "1", label: "تهران" },
- { id: "2", label: "رشت" },
- { id: "3", label: "اصفهان" },
-];
-
-export { numberTurns, turnTime, workplace };
diff --git a/helper/index.js b/helper/index.js
index e71cbd9..ec406c7 100644
--- a/helper/index.js
+++ b/helper/index.js
@@ -23,18 +23,21 @@ export const handleTwoLength = (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) {
+ const item = data[key];
+
+ if (typeof item === "object" && item !== null) {
+ if ("value" in item) {
+ if (!item.value) {
return false;
}
} else {
- if (!checkAllValues(data[key])) {
+ if (!checkAllValues(item)) {
return false;
}
}
}
}
+
return true;
};
diff --git a/lib/ability.js b/lib/ability.js
index 9e0610a..32629bb 100644
--- a/lib/ability.js
+++ b/lib/ability.js
@@ -6,6 +6,11 @@ export function defineAbilitiesFor(user) {
if (user) {
can("access", "Dashboard");
cannot("access", "Login");
+ const parsedData = JSON.parse(user.value);
+
+ if (parsedData.roles.find((item) => item === "representation")) {
+ can("access", "Panel");
+ }
} else {
can("access", "Login");
cannot("access", "Dashboard");
diff --git a/services/response.js b/services/response.js
index c3ee5af..3b1082d 100644
--- a/services/response.js
+++ b/services/response.js
@@ -60,4 +60,12 @@ export const request = {
),
postAppointment: (data) => api.post(`api/v1/appointment`, data),
postDoctor: (data) => api.post("api/v1/doctor", data),
+ postImageUpload: (data) =>
+ api.post("file/upload/clinic_pro/doctor/field_image", data, {
+ headers: {
+ "Content-Type": "application/octet-stream",
+ "Content-Disposition": 'file; filename="filename.jpg"',
+ "X-CSRF-Token": "",
+ },
+ }),
};