diff --git a/app/blog/[slug]/page.js b/app/blog/[slug]/page.js index 57c57aa..ba9082e 100644 --- a/app/blog/[slug]/page.js +++ b/app/blog/[slug]/page.js @@ -1,19 +1,19 @@ -import axios from "axios"; import BlogPage from "@/components/blog"; import Layout from "@/components/layout/StLayout"; +import { fetchReq } from "@/lib/ability"; async function Blog({ params: { slug } }) { - const blog = await axios.get( + const blog = await fetchReq( `https://back-dev.clinic-pro.ir/api/v1/blog/${slug}` ); - const blogs = await axios.get("https://back-dev.clinic-pro.ir/api/v1/blogs"); + const blogs = await fetchReq("https://back-dev.clinic-pro.ir/api/v1/blogs"); - const resBlog = blog.data; - const resBlogs = blogs.data; + const resBlog = blog; + const resBlogs = blogs; return ( - + ); } diff --git a/app/blogs/page.js b/app/blogs/page.js index ba253de..de6c1b1 100644 --- a/app/blogs/page.js +++ b/app/blogs/page.js @@ -1,12 +1,12 @@ import BlogsPage from "@/components/blogs"; import Layout from "@/components/layout/StLayout"; -import axios from "axios"; +import { fetchReq } from "@/lib/ability"; export default async function Blogs() { - const response = await axios.get( + const response = await fetchReq( "https://back-dev.clinic-pro.ir/api/v1/blogs" ); - const blogs = response.data.blogs; + const blogs = response.blogs; return ( diff --git a/app/clinic/[slug]/page.js b/app/clinic/[slug]/page.js index 6a0915e..94dcff9 100644 --- a/app/clinic/[slug]/page.js +++ b/app/clinic/[slug]/page.js @@ -1,18 +1,18 @@ import ClinicPage from "@/components/clinic"; import Layout from "@/components/layout/StLayout"; -import axios from "axios"; +import { fetchReq } from "@/lib/ability"; async function Clinic({ params: { slug } }) { - const reqClinics = await axios.get( + const reqClinics = await fetchReq( `https://back-dev.clinic-pro.ir/api/v1/clinic/${slug}` ); - const reqDoctors = await axios.get( + const reqDoctors = await fetchReq( "https://back-dev.clinic-pro.ir/api/v1/doctors" ); - const clinic = reqClinics.data; - const doctors = reqDoctors.data.$data; + const clinic = reqClinics; + const doctors = reqDoctors?.data || []; return ( diff --git a/app/clinics/page.js b/app/clinics/page.js index 6250baa..3871964 100644 --- a/app/clinics/page.js +++ b/app/clinics/page.js @@ -1,22 +1,20 @@ // app/clinics/page.js import ClinicsPage from "@/components/clinics"; import Layout from "@/components/layout/StLayout"; +import { fetchReq } from "@/lib/ability"; import { getStateInfo } from "@/lib/getStateInfo"; -import axios from "axios"; export default async function Clinics() { const { matchedCity, matchedState } = getStateInfo(); - const response = await axios.get( - "https://back-dev.clinic-pro.ir/api/v1/clinics?page=1&limit=10" + const clinics = await fetchReq( + "https://back-dev.clinic-pro.ir/api/v1/clinics" ); - const clinics = response.data.$data; - return ( diff --git a/app/component/DetailProfile.js b/app/component/DetailProfile.js index 48933fd..3254186 100644 --- a/app/component/DetailProfile.js +++ b/app/component/DetailProfile.js @@ -1,7 +1,6 @@ import { useState } from "react"; import ProfilePA from "@/components/icons/ProfilePA"; import LogoutP from "@/components/icons/LogoutP"; -import SettingPA from "@/components/icons/SettingPA"; import CardDA from "@/components/icons/CardDA"; import { Button, Popover } from "@mui/material"; import Link from "next/link"; @@ -15,6 +14,7 @@ function DetailProfile({ anchorEl, setAnchorEl }) { const open = Boolean(anchorEl); const id = open ? "simple-popover" : undefined; + return ( <> @@ -39,22 +39,24 @@ function DetailProfile({ anchorEl, setAnchorEl }) { پروفایل من - - + + diff --git a/app/component/Tabs.js b/app/component/Tabs.js index aed39e9..c2155a0 100644 --- a/app/component/Tabs.js +++ b/app/component/Tabs.js @@ -7,7 +7,7 @@ function a11yProps(index) { }; } -function Tabs({ value, handleChange, listTab, isSm, style }) { +function Tabs({ value, handleChange, listTab, inactives, isSm, style }) { return ( diff --git a/app/doctors/page.js b/app/doctors/page.js index 3afdf8f..e9470fb 100644 --- a/app/doctors/page.js +++ b/app/doctors/page.js @@ -6,11 +6,18 @@ import axios from "axios"; async function Doctors({ searchParams }) { const { matchedCity, matchedState } = getStateInfo(); - const response = await axios.get( - "https://back-dev.clinic-pro.ir/api/v1/doctors" - ); + let doctors = null; + try { + const response = await axios.get( + "https://back-dev.clinic-pro.ir/api/v1/doctors" + ); + console.log(response); - const doctors = response.data.$data; + doctors = response.data.$data; + } catch (error) { + // console.error("problem with req:", error.message); + // return redirect("/unauthorized"); + } return ( diff --git a/app/not-found.js b/app/not-found.js index 2229b2e..d8fcd8d 100644 --- a/app/not-found.js +++ b/app/not-found.js @@ -1,4 +1,4 @@ -import Layout from "@/components/layout"; +import Layout from "@/components/layout/StLayout"; import NotFoundPage from "@/components/notFound"; function NotFound() { diff --git a/components/blog/detail/Caption.js b/components/blog/detail/Caption.js index b118552..d7fdc8c 100644 --- a/components/blog/detail/Caption.js +++ b/components/blog/detail/Caption.js @@ -1,45 +1,33 @@ -import CustomLoading from "@/app/component/loading/Custom"; -import MultilineLoading from "@/app/component/loading/Multiline"; import Image from "next/image"; import React from "react"; -function Caption({ data, loading }) { +function Caption({ data }) { return ( <> - - cover-blog +
+
- -
- -
- -
- - cover-blog - -
- -
-
+ cover-blog +
); } diff --git a/components/blog/detail/SocialMedia.js b/components/blog/detail/SocialMedia.js index 7271ec3..383db35 100644 --- a/components/blog/detail/SocialMedia.js +++ b/components/blog/detail/SocialMedia.js @@ -5,15 +5,16 @@ import WhatsappB from "@/components/icons/WhatsappB"; const socials = [, , ]; -function SocialMedia({ loading }) { +function SocialMedia() { return (
    {socials.map((item, idx) => ( - -
  • - {item} -
  • -
    +
  • + {item} +
  • ))}
diff --git a/components/blog/detail/index.js b/components/blog/detail/index.js index b8a7967..96584b1 100644 --- a/components/blog/detail/index.js +++ b/components/blog/detail/index.js @@ -2,12 +2,12 @@ import Caption from "./Caption"; import SocialMedia from "./SocialMedia"; import CommentUser from "./commentUser"; -function Detail({ data, loading }) { +function Detail({ data }) { return (
- - - + + +
); } diff --git a/components/blog/head/index.js b/components/blog/head/index.js index bdc166e..457ccce 100644 --- a/components/blog/head/index.js +++ b/components/blog/head/index.js @@ -1,52 +1,38 @@ -import TextLoading from "@/app/component/loading/Text"; - -function Head({ data, loading }) { +function Head({ data }) { return (
- -
-

- بلاگ {">"} -

-

- پوست و مو {">"} -

-

- روش های خانگی محافظت از پوست در تابستان -

-
-
-
- -

- روش های خانگی محافظت از پوست در تابستان -

-
+
+

+ بلاگ {">"} +

+

+ پوست و مو {">"} +

+

+ روش های خانگی محافظت از پوست در تابستان +

+
+
+

+ روش های خانگی محافظت از پوست در تابستان +

تاریخ انتشار:

- -

- {data?.date_of_release} -

-
+

+ {data?.date_of_release} +

زمان مطالعه:

- -

- {data?.time} -

-
+

+ {data?.time} +

diff --git a/components/blog/index.js b/components/blog/index.js index 54b0b5b..4c51d41 100644 --- a/components/blog/index.js +++ b/components/blog/index.js @@ -1,25 +1,14 @@ -"use client"; - -import { useEffect, useState } from "react"; import Detail from "./detail"; import Head from "./head"; import RelatedContent from "./relatedContent"; -function BlogPage({ article, articles }) { - const [loading, setLoading] = useState(true); - - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 2000); - }, []); - +function BlogPage({ blog, blogs }) { return (
- +
- - + +
); diff --git a/components/blog/relatedContent/index.js b/components/blog/relatedContent/index.js index 1c4126f..d5b60e9 100644 --- a/components/blog/relatedContent/index.js +++ b/components/blog/relatedContent/index.js @@ -10,9 +10,11 @@ function RelatedContent({ data, loading }) {
    - {data?.map((item, idx) => ( - - ))} + {data && + data.length && + data?.map((item, idx) => ( + + ))}
); diff --git a/components/clinic/components/about/Services.js b/components/clinic/components/about/Services.js index 5830748..b32ede9 100644 --- a/components/clinic/components/about/Services.js +++ b/components/clinic/components/about/Services.js @@ -21,7 +21,7 @@ function Services({ data }) { ${idx === 0 ? "text-[#F17732]" : "text-[#525252]"} `} > - {item} + {item.name} diff --git a/components/clinic/components/about/Specialties.js b/components/clinic/components/about/Specialties.js index a1c9e64..365cb08 100644 --- a/components/clinic/components/about/Specialties.js +++ b/components/clinic/components/about/Specialties.js @@ -9,8 +9,8 @@ function Specialties({ data }) { gap-x-[40px] sm:gap-x-[48px] md:gap-x-[56px] lg:gap-x-[64px] gap-y-[24px] sm:gap-y-[30px] md:gap-y-[35px] lg:gap-y-[40px]" > - {data?.specialties?.map((item, idx) => ( -
  • + {data && data.specialties && data?.specialties?.map((item, idx) => ( +
  • @@ -21,7 +21,7 @@ function Specialties({ data }) { ${idx === 0 ? "text-[#F17732]" : "text-[#525252]"} `} > - {item} + {item.name}
  • diff --git a/components/clinic/components/about/index.js b/components/clinic/components/about/index.js index 7ad36e5..3327405 100644 --- a/components/clinic/components/about/index.js +++ b/components/clinic/components/about/index.js @@ -14,7 +14,7 @@ function About({ data }) { return (
    - +

    +
    + ); +} + +export default Field; diff --git a/components/dashboard/userAccount/detailUser/information/Form.js b/components/dashboard/userAccount/detailUser/information/Form.js index e5481a9..f8841a6 100644 --- a/components/dashboard/userAccount/detailUser/information/Form.js +++ b/components/dashboard/userAccount/detailUser/information/Form.js @@ -1,6 +1,6 @@ import Content from "./Content"; -import EditField from "@/app/component/EditField"; import DateBirthday from "./DateBirthday"; +import Field from "./Field"; import { insurance, gender, @@ -11,23 +11,24 @@ import { } from "./listSelector"; import AutoSelector from "@/app/component/element/AutoSelector"; -function Form({ data, changeData, selected, updateSelect }) { - const findVal = (list, name) => list.find((g) => g.id === selected[name]); +function Form({ data, changeData, prevData }) { + const findVal = (list, name) => data && list.find((g) => g.id === data[name]); return (
    - - - - updateSelect(name, data === "زن" ? "female" : "male") + changeData(data === "زن" ? "female" : "male", "value", name) } value={findVal(gender, "gender")} label="جنسیت" @@ -58,31 +59,31 @@ function Form({ data, changeData, selected, updateSelect }) { - - - updateSelect(name, blood_group.find((g) => g.label === value).id) + changeData( + blood_group.find((g) => g.label === value).id, + "value", + name + ) } - value={findVal(blood_group, "blood_group")} + value={findVal(blood_group, "blood_type")} label="گروه خونی" - name="blood_group" + name="blood_type" list={blood_group} /> - updateSelect(name, marital_status.find((g) => g.label === value).id) + changeData(value === "متاهل" ? "married" : "single", "value", name) } value={findVal(marital_status, "marital_status")} label="وضعیت تاهل" @@ -114,7 +119,7 @@ function Form({ data, changeData, selected, updateSelect }) { /> - - updateSelect(name, education.find((g) => g.label === value).id) + changeData( + education.find((g) => g.label === value).id, + "value", + name + ) } value={findVal(education, "education")} label="تحصیلات" @@ -137,7 +146,7 @@ function Form({ data, changeData, selected, updateSelect }) { - updateSelect(name, job.find((g) => g.label === value).id) + changeData(value === "آزاد" ? "azad" : "dolati", "value", name) } value={findVal(job, "job")} label="شغل" @@ -146,7 +155,7 @@ function Form({ data, changeData, selected, updateSelect }) { /> - { disable && setDisable(false); setData({ ...data, - [name]: { - ...data[name], - [type]: value, - }, + [name]: value, }); }; - const updateSelect = (name, event) => { - disable && setDisable(false); - setSelected({ ...selected, [name]: event }); + const sendReq = () => { + setLoading(true); + request[dataUser ? "patchUserProfile" : "postUserProfile"](data) + .then((res) => { + setLoading(false); + }) + .catch((err) => { + setLoading(false); + }); }; return (
    -
    +