redirect filter data to doctors page from home page just with one key && add picture url to doctors page && add conditional to appo page and change data in server

This commit is contained in:
Ehsan
2025-09-02 00:32:04 +03:30
parent 1e70d88a84
commit 6920e4078b
9 changed files with 96 additions and 52 deletions
+2 -2
View File
@@ -20,9 +20,9 @@ function ItemDoctor({ doctor }) {
<Image
width={72}
height={72}
src={doctor?.img}
src={doctor?.img[0]?.url}
alt="image-doctor"
className="w-[64px] md:w-[68px] lg:w-[72px] h-[64px] md:h-[68px] lg:h-[72px]"
className="object-contain w-[64px] md:w-[68px] lg:w-[72px] h-[64px] md:h-[68px] lg:h-[72px]"
/>
</CircularLoading>
<div className="flex flex-col items-start justify-center gap-2">
+2
View File
@@ -14,6 +14,7 @@ function Container({
doctor,
setData,
setStep,
prevData,
matchedCity,
isForAnother,
setIsForAnother,
@@ -26,6 +27,7 @@ function Container({
data={data}
setStep={setStep}
setData={setData}
prevData={prevData}
isForAnother={isForAnother}
setIsForAnother={setIsForAnother}
/>,
+2 -2
View File
@@ -2,7 +2,7 @@ import Content from "./Content";
import EditField from "../../../app/component/fields/EditField";
import DefaultSelect from "@/app/component/selectors/DefaultSelect";
function Form({ changeData, insurance, data, updateSelect, isForAnother }) {
function Form({ changeData, insurance, data, isForAnother }) {
const findVal = () => {
return insurance?.find(
(g) =>
@@ -31,7 +31,7 @@ function Form({ changeData, insurance, data, updateSelect, isForAnother }) {
</Content>
<Content title="نوع بیمه">
<DefaultSelect
updateData={(name, val) => updateSelect(val, "value", name)}
updateData={(name, val) => changeData(val, "value", name)}
label="نوع بیمه"
name="basic_insurance"
list={insurance}
@@ -0,0 +1,63 @@
import { useState } from "react";
import ButtonFixed from "../paying/ButtonFixed";
import { Button } from "@mui/material";
import ArrowLeftB from "@/components/icons/ArrowLeftB";
import { request } from "@/services/response";
function SubmitData({ setStep, data, prevData }) {
const [loading, setLoading] = useState(false);
const newStep = () => setStep((prev) => prev + 1);
const handleSubmit = () => {
const isChanged = JSON.stringify(prevData) !== JSON.stringify(data);
if (isChanged) {
setLoading(true);
let newData = data;
const { basic_insurance, name, national_code, uuid } = newData;
newData = {
basic_insurance: [basic_insurance.value?.id],
...(prevData.name?.value === data.name.value ? {} : { name: name }),
...(prevData.national_code?.value
? {}
: { national_code: national_code }),
};
request
.patchUserProfile(newData, uuid)
.then(() => {
setLoading(false);
newStep();
})
.catch(() => {
setLoading(false);
});
} else {
newStep();
}
};
return (
<ButtonFixed>
<Button
loading={loading}
className={`
!flex !w-full md:!w-fit !mt-0 md:!mt-[32px]
!gap-[4px] md:!mr-auto !px-[12px] !py-[8px] md:!py-[9px] !min-w-[150px]
`}
variant="contained"
onClick={handleSubmit}
>
<p
className={`${loading && "opacity-0"} text-[#EFEFEF] text-[16px] font-medium`}
>
ثبت اطلاعات
</p>
<ArrowLeftB />
</Button>
</ButtonFixed>
);
}
export default SubmitData;
+3 -35
View File
@@ -1,10 +1,9 @@
import { useEffect, useState } from "react";
import { Button } from "@mui/material";
import AddCircleBlueA from "@/components/icons/AddCircleBlueA";
import ArrowLeftB from "@/components/icons/ArrowLeftB";
import ButtonFixed from "../paying/ButtonFixed";
import Form from "./Form";
import { request } from "@/services/response";
import SubmitData from "./SubmitData";
function Detail({
isForAnother,
@@ -12,15 +11,11 @@ function Detail({
setIsForAnother,
data,
setData,
prevData,
fadeElement,
setIsPay,
}) {
const [insurance, setInsurance] = useState();
const [selected, setSelected] = useState({
first: "",
second: "",
});
const changeData = (value, type, name) =>
setData({
...data,
@@ -30,14 +25,6 @@ function Detail({
},
});
const updateSelect = (event, name) =>
setSelected({ ...selected, [name]: event });
const newStep = () => {
// if(data)
setStep((prev) => prev + 1);
};
useEffect(() => {
request.getInsuranceType().then((res) => {
if (res && res.data) {
@@ -61,7 +48,6 @@ function Detail({
data={data}
insurance={insurance}
changeData={changeData}
updateSelect={updateSelect}
isForAnother={isForAnother}
/>
{!isForAnother && (
@@ -82,25 +68,7 @@ function Detail({
</p>
</Button>
)}
<ButtonFixed>
<Button
className={`
!flex !w-full md:!w-fit
!gap-[4px] md:!mr-auto !px-[12px] !py-[8px] md:!py-[9px] !min-w-[150px]
${
isForAnother
? "!mt-0 md:!mt-[40px]"
: "!mt-0 md:!mt-[32px]"
}`}
variant="contained"
onClick={newStep}
>
<p className="text-[#EFEFEF] text-[16px] font-medium">
ثبت اطلاعات
</p>
<ArrowLeftB />
</Button>
</ButtonFixed>
<SubmitData setStep={setStep} data={data} prevData={prevData} />
</div>
</div>
);
+10 -4
View File
@@ -24,7 +24,7 @@ function AppointmentPage({ slug, matchedCity }) {
useEffect(() => {
const userInfo = Cookies.get("userInfo");
const parsedData = JSON.parse(userInfo);
const parsedData = userInfo && JSON.parse(userInfo);
if (userInfo && parsedData) {
request
@@ -32,8 +32,12 @@ function AppointmentPage({ slug, matchedCity }) {
.then((res) => {
if (res) {
const newData = {
uuid: res.uuid,
phone: { value: parsedData.username || "", isEdit: false },
national_code: { value: res.national_code || "", isEdit: true },
national_code: {
value: res.national_code || "",
isEdit: res.national_code ? false : true,
},
name: { value: `${res.name} ${res.family}`, isEdit: true },
basic_insurance: {
value: res.basic_insurance,
@@ -44,6 +48,7 @@ function AppointmentPage({ slug, matchedCity }) {
setPrevData(newData);
} else {
const emptyData = {
uuid: res.uuid,
phone: { value: parsedData.username || "", isEdit: false },
national_code: { value: "", isEdit: true },
name: { value: "", isEdit: true },
@@ -56,8 +61,8 @@ function AppointmentPage({ slug, matchedCity }) {
setPrevData(emptyData);
}
})
.catch((err) => {
console.log(err);
.catch(() => {
//
});
}
}, []);
@@ -69,6 +74,7 @@ function AppointmentPage({ slug, matchedCity }) {
doctor={doctor}
setData={setData}
setStep={setStep}
prevData={prevData}
matchedCity={matchedCity}
isForAnother={isForAnother}
setIsForAnother={setIsForAnother}
+4 -3
View File
@@ -12,9 +12,10 @@ function Title({ doctor }) {
<CircularLoading width={100} height={100}>
<Image
className="
w-[40px] sm:w-[81px] md:w-[123px] lg:w-[164px]
h-[40px] sm:h-[81px] md:h-[123px] lg:h-[164px]
"
object-contain
w-[40px] sm:w-[81px] md:w-[123px] lg:w-[164px]
h-[40px] sm:h-[81px] md:h-[123px] lg:h-[164px]
"
src={doctor?.img[0]?.url}
alt="img-doctor"
height={164}
+1 -1
View File
@@ -17,7 +17,7 @@ function FrequentSearches() {
href={{
pathname: "/doctors",
query: {
specialties: item.id,
field: item.id,
},
}}
>
+9 -5
View File
@@ -37,11 +37,15 @@ export const request = {
getUserProfile: (uuid) => api.get(`/api/v1/user-profile/${uuid}`),
postUserProfile: (data) => api.post("api/v1/user-profile", data),
patchUserProfile: (data, uuid, token) =>
api.patch(`api/v1/user-profile/${uuid}`, data, {
headers: {
Authorization: `Bearer ${token}`,
},
}),
api.patch(
`api/v1/user-profile/${uuid}`,
data,
token && {
headers: {
Authorization: `Bearer ${token}`,
},
}
),
getUserInfo: (headers) => api.get("oauth/userinfo", headers),
getInsuranceType: () =>
api.get("api/v1/categorys/insurance_type", removeTokenHead),