diff --git a/components/clinic/components/about/images/Images.js b/components/clinic/components/about/images/Images.js index 5cd7fff..6f1da5f 100644 --- a/components/clinic/components/about/images/Images.js +++ b/components/clinic/components/about/images/Images.js @@ -4,6 +4,8 @@ import Image from "next/image"; import CustomLoading from "@/app/component/loading/Custom"; function Images({ data }) { + const images_clinic = data.images_clinic; + return (
+ + img clinic + +
+ ); +} + +export default Img; diff --git a/components/clinic/components/about/images/List.js b/components/clinic/components/about/images/List.js index 26c15ef..3cf12ab 100644 --- a/components/clinic/components/about/images/List.js +++ b/components/clinic/components/about/images/List.js @@ -1,73 +1,53 @@ import CustomLoading from "@/app/component/loading/Custom"; import Image from "next/image"; +import Img from "./Img"; function List({ data }) { + const images_clinic = data.images_clinic; + return (
-
- - img clinic - -
-
- - img clinic - -
-
- - img clinic - -
-
- - img clinic - -
+ {images_clinic.map((img) => ( +
+ + img clinic + +
+ ))} + + + +
); } diff --git a/components/clinic/index.js b/components/clinic/index.js index e074738..58b1fcd 100644 --- a/components/clinic/index.js +++ b/components/clinic/index.js @@ -12,6 +12,7 @@ const listTab = ["درباره کلینیک", "اطلاعات تماس", "پزش function ClinicPage({ data, doctors }) { const [value, setValue] = useState(0); const handleChange = (event, newValue) => setValue(newValue); + console.log(data); const Components = [ , diff --git a/components/clinics/index.js b/components/clinics/index.js index 2baa2bb..d0f6029 100644 --- a/components/clinics/index.js +++ b/components/clinics/index.js @@ -11,6 +11,7 @@ import specialtiesData from "@/data/specialties.json"; function ClinicsPage({ clinics, matchedCity, matchedState }) { const router = useRouter(); const [filteredClinics, setFilteredClinics] = useState(clinics); + console.log(clinics); const [selected, setSelected] = useState({ province: matchedState?.name || "", diff --git a/components/dashboard/userAccount/detailUser/index.js b/components/dashboard/userAccount/detailUser/index.js index bb2e439..90edcde 100644 --- a/components/dashboard/userAccount/detailUser/index.js +++ b/components/dashboard/userAccount/detailUser/index.js @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import HeadTab from "../content/HeadTab"; import { request } from "@/services/response"; import { setNewData } from "./function"; @@ -12,6 +12,7 @@ import Surgeries from "./surgeries"; import FamilyHistory from "./familyHistory"; import Relatives from "./relatives"; import { dieses } from "./information/dieses"; +import Cookies from "js-cookie"; function DetailUser({ user, @@ -22,6 +23,8 @@ function DetailUser({ setIsTurnsDetails, }) { const [tab, setTab] = useState(0); + const [information, setInformation] = useState(); + const [prevInfo, setPrevInfo] = useState(); const initialData = { name: dataUser?.name, description: dataUser?.description, @@ -41,6 +44,27 @@ function DetailUser({ national_code: dataUser?.national_code, }; + useEffect(() => { + const user = Cookies.get("userInfo"); + const parsedUserInfo = user && JSON.parse(user); + console.log(parsedUserInfo); + + if (parsedUserInfo) { + request + .getUserProfile(parsedUserInfo.uuid) + .then((res) => { + setInformation(res); + setPrevInfo(res); + }) + .catch((err) => { + console.log(err); + }); + } else { + // handle Error + } + }, []); + console.log(information); + if (!dataUser) { initialData.other = [ { @@ -86,9 +110,12 @@ function DetailUser({ user={user} data={data} setData={setData} + prevInfo={prevInfo} userInfo={userInfo} dataUser={dataUser} + information={information} initialData={initialData} + setInformation={setInformation} updateDataUser={updateDataUser} isTurnsDetails={isTurnsDetails} setIsTurnsDetails={setIsTurnsDetails} diff --git a/components/dashboard/userAccount/detailUser/information/Content.js b/components/dashboard/userAccount/detailUser/information/Content.js index b5fe402..a46177c 100644 --- a/components/dashboard/userAccount/detailUser/information/Content.js +++ b/components/dashboard/userAccount/detailUser/information/Content.js @@ -1,4 +1,6 @@ -function Content({ isConfirmed, children, title }) { +function Content({ isConfirmed, children, title, error }) { + console.log(error); + return (
@@ -12,7 +14,10 @@ function Content({ isConfirmed, children, title }) {

)}
- {children} +
+ {children} +

{error || ""}

+
); } diff --git a/components/dashboard/userAccount/detailUser/information/DateBirthday.js b/components/dashboard/userAccount/detailUser/information/DateBirthday.js index bac3d1e..6dbab1d 100644 --- a/components/dashboard/userAccount/detailUser/information/DateBirthday.js +++ b/components/dashboard/userAccount/detailUser/information/DateBirthday.js @@ -4,7 +4,7 @@ import { Button, Popover } from "@mui/material"; import { DatePicker } from "jalaali-react-date-picker"; import { useState } from "react"; -function DateBirthday({ data, changeData }) { +function DateBirthday({ data, changeData, error }) { const [anchorEl, setAnchorEl] = useState(null); const handleClick = (event) => { @@ -21,7 +21,10 @@ function DateBirthday({ data, changeData }) { return (

diff --git a/components/dashboard/userAccount/detailUser/information/Form.js b/components/dashboard/userAccount/detailUser/information/Form.js index 05c0ae0..efb01a7 100644 --- a/components/dashboard/userAccount/detailUser/information/Form.js +++ b/components/dashboard/userAccount/detailUser/information/Form.js @@ -1,6 +1,7 @@ import Content from "./Content"; import DateBirthday from "./DateBirthday"; -import Field from "./Field"; +import AutoSelector from "./component/AutoSelector"; +import Field from "./component/Field"; import { gender, blood_group, @@ -8,14 +9,22 @@ import { education, job, } from "./listSelector"; -import AutoSelector from "@/app/component/element/AutoSelector"; -function Form({ data, userInfo, insurance, changeData, prevData }) { +function Form({ + data, + userInfo, + insurance, + errors, + prevInfo, + changeData, + prevData, +}) { const findVal = (list, name) => data && list && list.length && list.find((g) => g.id === data[name]); + console.log(errors); return ( -

+
- + - + - + + + + changeData(data === "زن" ? "female" : "male", "value", name) } @@ -57,15 +80,17 @@ function Form({ data, userInfo, insurance, changeData, prevData }) { list={gender} /> - + - + - + - + changeData( blood_group.find((g) => g.label === value).id, @@ -112,8 +145,9 @@ function Form({ data, userInfo, insurance, changeData, prevData }) { list={blood_group} /> - + changeData(value === "متاهل" ? "married" : "single", "value", name) } @@ -133,8 +167,9 @@ function Form({ data, userInfo, insurance, changeData, prevData }) { name="home_phone" /> - + changeData( education.find((g) => g.label === value).id, @@ -148,8 +183,9 @@ function Form({ data, userInfo, insurance, changeData, prevData }) { list={education} /> - + changeData(value === "آزاد" ? "azad" : "dolati", "value", name) } diff --git a/components/dashboard/userAccount/detailUser/information/component/AutoSelector.js b/components/dashboard/userAccount/detailUser/information/component/AutoSelector.js new file mode 100644 index 0000000..5a506fe --- /dev/null +++ b/components/dashboard/userAccount/detailUser/information/component/AutoSelector.js @@ -0,0 +1,101 @@ +import BottomSelect from "@/components/icons/BottomSelect"; +import { Autocomplete, Button, TextField } from "@mui/material"; +import { styleTextSelectRight } from "@/mui"; + +function AutoSelector({ + list, + value, + isError, + updateData, + label, + error, + disabled = false, + listboxProps, + name, +}) { + return ( + { + if (typeof option === "string") return option; + return option?.name || option?.label || ""; + }} + className="!w-full !rounded-lg auto-complete-selector" + onChange={(e, newValue) => { + updateData(name, newValue?.label || newValue || ""); + }} + 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: error + ? "1px solid red !important" + : "1px solid #D7D7D7 !important", + }, + "& .MuiInput-underline:hover:not(.Mui-disabled):before, .MuiOutlinedInput-notchedOutline": + { + borderColor: error ? "red !important" : "#D7D7D7 !important", + }, + "& .muirtl-1kiro5a-MuiInputBase-root-MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": + { + border: "1px solid #5559CE !important", + }, + "& .MuiOutlinedInput-notchedOutline": { + border: isError ? "1px solid red !important" : "", + }, + }} + renderOption={(props, option) => ( + + )} + renderInput={(params) => ( + + +
+ ), + }} + placeholder={label} + sx={{ + borderRadius: "8px", + }} + /> + )} + /> + ); +} + +export default AutoSelector; diff --git a/components/dashboard/userAccount/detailUser/information/Field.js b/components/dashboard/userAccount/detailUser/information/component/Field.js similarity index 87% rename from components/dashboard/userAccount/detailUser/information/Field.js rename to components/dashboard/userAccount/detailUser/information/component/Field.js index 85a12aa..7b7dad7 100644 --- a/components/dashboard/userAccount/detailUser/information/Field.js +++ b/components/dashboard/userAccount/detailUser/information/component/Field.js @@ -10,6 +10,7 @@ function Field({ data, name, iconGray, + error, isTransparent, type, props, @@ -24,19 +25,22 @@ function Field({ disabled={disable} type={type || "text"} placeholder={placeholder || ""} - className={`!w-full res-field-account dark:!bg-transparent ${ + className={`!w-full res-field-account dark:!bg-transparent ${ isTransparent ? "!bg-transparent lg:!bg-[#FFF]" : "!bg-[#FFF]" }`} onChange={(e) => { changeData(e.target.value, "value", name); }} sx={{ + // border: "1px solid red !important", "& .MuiFormLabel-root": { top: "-4px !important", }, "& .MuiInputBase-input": { padding: "12.5px 14px" }, "& .MuiOutlinedInput-notchedOutline": { - border: "1px solid #D7D7D7 !important", + border: error + ? "1px solid red !important" + : "1px solid #D7D7D7 !important", }, "& .MuiInputBase-root": { padding: "0 !important", diff --git a/components/dashboard/userAccount/detailUser/information/index.js b/components/dashboard/userAccount/detailUser/information/index.js index d106103..2cadc8b 100644 --- a/components/dashboard/userAccount/detailUser/information/index.js +++ b/components/dashboard/userAccount/detailUser/information/index.js @@ -10,13 +10,17 @@ function Information({ data, setData, userInfo, + prevInfo, dataUser, initialData, + information, + setInformation, updateDataUser, }) { const [disable, setDisable] = useState(true); - const [loading, setLoading] = useState(false); const [insurance, setInsurance] = useState(); + const [loading, setLoading] = useState(false); + const [errors, setErrors] = useState(); useEffect(() => { request.getInsuranceType().then((res) => { @@ -28,43 +32,54 @@ function Information({ }, []); const changeData = (value, type, name) => { - disable && setDisable(false); - setData({ - ...data, + setInformation({ + ...information, [name]: value, }); }; + const validationInfo = () => {}; + const sendReq = () => { setLoading(true); - console.log(data); + console.log(prevInfo); + console.log(prevInfo ? true : false); + if (!validationInfo()) + request[prevInfo ? "patchUserProfile" : "postUserProfile"]( + data, + prevInfo ? prevInfo.uuid : Cookies.get("uuid") + ) + .then((res) => { + console.log(res); - request[dataUser ? "patchUserProfile" : "postUserProfile"]( - data, - dataUser ? dataUser.uuid : Cookies.get("uuid") - ) - .then(() => { - if (!dataUser) { - updateDataUser(); - } - setLoading(false); - }) - .catch(() => { - setLoading(false); - }); + if (!dataUser) { + updateDataUser(); + } + setLoading(false); + }) + .catch((err) => { + console.log(err); + console.log(err?.response?.data); + if (err?.response?.data) { + setErrors(err.response.data); + } + + setLoading(false); + }); }; return (