diff --git a/app/Providers.js b/app/Providers.js index 47c40e1..1396f65 100644 --- a/app/Providers.js +++ b/app/Providers.js @@ -1,14 +1,11 @@ "use client"; import { ThemeProvider } from "next-themes"; -import { usePathname } from "next/navigation"; import { useEffect } from "react"; import Cookies from "js-cookie"; import { setAccessToken } from "@/lib/tokenStore"; export function Providers({ children }) { - const router = usePathname(); - useEffect(() => { if (!Cookies.get("userInfo")) return; fetch("/api/auth/refresh", { method: "POST" }) @@ -21,7 +18,7 @@ export function Providers({ children }) { return ( diff --git a/app/component/DetailProfile.js b/app/component/DetailProfile.js index 5089c35..702ad6c 100644 --- a/app/component/DetailProfile.js +++ b/app/component/DetailProfile.js @@ -1,34 +1,18 @@ -import { useState, useEffect } from "react"; +import { useState } from "react"; import ProfilePA from "@/components/icons/ProfilePA"; import LogoutP from "@/components/icons/LogoutP"; import CardDA from "@/components/icons/CardDA"; import { Button, Popover } from "@mui/material"; import Link from "next/link"; import ModalLogout from "./ModalLogout"; -import Cookies from "js-cookie"; function DetailProfile({ anchorEl, setAnchorEl }) { const [modal, setModal] = useState(false); - const [hasRepresentationRole, setHasRepresentationRole] = useState(false); const handleClose = () => setAnchorEl(null); const closeModal = () => setModal(false); const openModal = () => setModal(true); - useEffect(() => { - const userInfo = Cookies.get("userInfo"); - if (userInfo) { - try { - const parsedUserInfo = JSON.parse(userInfo); - const roles = parsedUserInfo?.roles || {}; - const hasRole = Object.values(roles).includes("representation"); - setHasRepresentationRole(hasRole); - } catch (error) { - console.error("Error parsing userInfo:", error); - } - } - }, []); - const open = Boolean(anchorEl); const id = open ? "simple-popover" : undefined; @@ -74,18 +58,6 @@ function DetailProfile({ anchorEl, setAnchorEl }) { تراکنش های من - {hasRepresentationRole && ( - - - - )} - - - ); -} - -export default MenuProfile; diff --git a/components/layoutPanel/header/Search.js b/components/layoutPanel/header/Search.js deleted file mode 100644 index 88be082..0000000 --- a/components/layoutPanel/header/Search.js +++ /dev/null @@ -1,27 +0,0 @@ -import SearchHeaderP from "@/components/icons/SearchHeaderP"; -import { InputAdornment, TextField } from "@mui/material"; - -function Search() { - return ( - - - - ), - }} - sx={{ - "& .MuiOutlinedInput-input": { - paddingTop: "9px !important", - paddingBottom: "9px !important", - }, - }} - /> - ); -} - -export default Search; diff --git a/components/layoutPanel/header/icons/Search.js b/components/layoutPanel/header/icons/Search.js deleted file mode 100644 index 562895b..0000000 --- a/components/layoutPanel/header/icons/Search.js +++ /dev/null @@ -1,68 +0,0 @@ -import SearchHeaderP from "@/components/icons/SearchHeaderP"; -import { Button, Popover, TextField } from "@mui/material"; -import { useState } from "react"; - -function Search() { - const [anchorEl, setAnchorEl] = useState(null); - - const handleClick = (event) => setAnchorEl(event.currentTarget); - const handleClose = () => setAnchorEl(null); - - const open = Boolean(anchorEl); - const id = open ? "simple-popover" : undefined; - - return ( - <> - - - - - - ); -} - -export default Search; diff --git a/components/layoutPanel/header/icons/Theme.js b/components/layoutPanel/header/icons/Theme.js deleted file mode 100644 index 6f5ece1..0000000 --- a/components/layoutPanel/header/icons/Theme.js +++ /dev/null @@ -1,36 +0,0 @@ -import MoonP from "@/components/icons/MoonP"; -import Sun from "@/components/icons/Sun"; -import { Button } from "@mui/material"; -import { useTheme } from "next-themes"; -import { useState } from "react"; - -function Theme() { - const [mounted, setMounted] = useState(false); - const { theme, setTheme } = useTheme(); - - useState(() => setMounted(true), []); - - return ( - - ); -} - -export default Theme; diff --git a/components/layoutPanel/header/icons/index.js b/components/layoutPanel/header/icons/index.js deleted file mode 100644 index 0de1a2f..0000000 --- a/components/layoutPanel/header/icons/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Button } from "@mui/material"; -import NotificationP from "@/components/icons/NotificationP"; -import SettingP from "@/components/icons/SettingP"; -import Theme from "./Theme"; -import Search from "./Search"; - -function Icons() { - return ( -
- - - - -
- ); -} - -export default Icons; diff --git a/components/layoutPanel/header/index.js b/components/layoutPanel/header/index.js deleted file mode 100644 index 4d87bb7..0000000 --- a/components/layoutPanel/header/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import Icons from "./icons"; -import Search from "./Search"; -import SideButton from "./sideButton"; -import MenuProfile from "./MenuProfile"; - -function Header({ disableProfile, data, setActive }) { - return ( -
- - -
- - {!disableProfile && } -
-
- ); -} - -export default Header; diff --git a/components/layoutPanel/header/sideButton/ButtonMenu.js b/components/layoutPanel/header/sideButton/ButtonMenu.js deleted file mode 100644 index 3ea8c8e..0000000 --- a/components/layoutPanel/header/sideButton/ButtonMenu.js +++ /dev/null @@ -1,16 +0,0 @@ -import { Button } from "@mui/material"; - -function ButtonMenu({ setActive }) { - return ( - - ); -} - -export default ButtonMenu; diff --git a/components/layoutPanel/header/sideButton/index.js b/components/layoutPanel/header/sideButton/index.js deleted file mode 100644 index 3578c86..0000000 --- a/components/layoutPanel/header/sideButton/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ButtonMenu from "./ButtonMenu"; -import LogoPanelHead from "@/components/icons/LogoPanelHead"; - -function SideButton({ setActive }) { - return ( -
- -
- -
-
- ); -} - -export default SideButton; diff --git a/components/layoutPanel/index.js b/components/layoutPanel/index.js deleted file mode 100644 index 02afee3..0000000 --- a/components/layoutPanel/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import Header from "./header"; -import Sidebar from "./sidebar"; -import UserDetail from "./userDetail"; - -function LayoutPanel({ children, data }) { - return ( -
- -
-
-
- {children} -
-
- -
- ); -} - -export default LayoutPanel; diff --git a/components/layoutPanel/sidebar/BgGray.js b/components/layoutPanel/sidebar/BgGray.js deleted file mode 100644 index 8e6aca4..0000000 --- a/components/layoutPanel/sidebar/BgGray.js +++ /dev/null @@ -1,17 +0,0 @@ -function BgGray({ isActive, setIsActive }) { - return ( -
setIsActive(false)} - className={` - md:hidden ${ - isActive - ? "bg-[#232323] opacity-40 flex" - : "bg-transparent opacity-40 hidden" - } - absolute z-[25] cursor-pointer transition-all duration-500 left-0 top-0 w-screen h-screen - `} - >
- ); -} - -export default BgGray; diff --git a/components/layoutPanel/sidebar/HeadMd.js b/components/layoutPanel/sidebar/HeadMd.js deleted file mode 100644 index ed17d25..0000000 --- a/components/layoutPanel/sidebar/HeadMd.js +++ /dev/null @@ -1,32 +0,0 @@ -import DoubleArrowLeftP from "@/components/icons/DoubleArrowLeftP"; -import LogoPanel from "@/components/icons/LogoPanel"; -import { Button } from "@mui/material"; -import Link from "next/link"; -import React from "react"; - -function HeadMd({ open, setOpen }) { - return ( -
- - - - -
- ); -} - -export default HeadMd; diff --git a/components/layoutPanel/sidebar/HeadSm.js b/components/layoutPanel/sidebar/HeadSm.js deleted file mode 100644 index 23b47d5..0000000 --- a/components/layoutPanel/sidebar/HeadSm.js +++ /dev/null @@ -1,22 +0,0 @@ -import { Button } from "@mui/material"; -import ArrowRightP from "@/components/icons/ArrowRightP"; -import LogoPanelHead from "@/components/icons/LogoPanelHead"; - -function HeadSm({ setActive }) { - return ( -
- -
- -
-
- ); -} - -export default HeadSm; diff --git a/components/layoutPanel/sidebar/Links.js b/components/layoutPanel/sidebar/Links.js deleted file mode 100644 index 41cf7c6..0000000 --- a/components/layoutPanel/sidebar/Links.js +++ /dev/null @@ -1,73 +0,0 @@ -import Link from "next/link"; -import { Button } from "@mui/material"; -import { usePathname } from "next/navigation"; - -// Icons -import CalendarP from "@/components/icons/CalendarP"; -import CategoryP from "@/components/icons/CategoryP"; -import ProfileAddP from "@/components/icons/ProfileAddP"; -import ProfileCircleP from "@/components/icons/ProfileCircleP"; - -function Links({ open, setActive }) { - const list = [ - { name: "دشبورد", src: "/panel/dashboard", icon: }, - { - name: "حساب کاربری", - src: "/panel/user-account", - icon: , - }, - { - name: "اضافه کردن پزشک", - src: "/panel/add-doctor", - icon: , - }, - { name: "نوبت ها", src: "/panel/turns", icon: }, - ]; - - const pathname = usePathname(); - - return ( -
    - {list.map((item, idx) => ( -
  • - - - -
  • - ))} -
- ); -} - -export default Links; diff --git a/components/layoutPanel/sidebar/index.js b/components/layoutPanel/sidebar/index.js deleted file mode 100644 index f5982b8..0000000 --- a/components/layoutPanel/sidebar/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import Links from "./Links"; -import HeadMd from "./HeadMd"; -import HeadSm from "./HeadSm"; -import { Button } from "@mui/material"; -import LogoutOrangeP from "@/components/icons/LogoutOrangeP"; -import ModalLogout from "@/app/component/ModalLogout"; -import { useState } from "react"; - -function Sidebar({ active, setActive, open, setOpen }) { - const [modal, setModal] = useState(false); - const handleOpen = () => setModal(true); - const handleClose = () => setModal(false); - - return ( -
- -
- ); -} - -export default Sidebar; diff --git a/components/layoutPanel/userDetail/Activities.js b/components/layoutPanel/userDetail/Activities.js deleted file mode 100644 index fda4a76..0000000 --- a/components/layoutPanel/userDetail/Activities.js +++ /dev/null @@ -1,40 +0,0 @@ -import TextLoading from "@/app/component/loading/Text"; -import WarnP from "@/components/icons/WarnP"; - -function Activities({ data, loading }) { - return ( -
-

- فعالیت های امروز -

-
    - {data.todays_activities.map((item, idx) => ( -
  • -
    -
    -
    - -
    - -

    - {item.text} -

    -
    -
    - -

    - {item.time} -

    -
    -
    - {data.todays_activities.length > idx + 1 && ( - - )} -
  • - ))} -
-
- ); -} - -export default Activities; diff --git a/components/layoutPanel/userDetail/Date.js b/components/layoutPanel/userDetail/Date.js deleted file mode 100644 index 7a6f4ef..0000000 --- a/components/layoutPanel/userDetail/Date.js +++ /dev/null @@ -1,41 +0,0 @@ -"use client"; - -import JalaliDatePicker from "@/components/common/JalaliDatePicker"; - -function Date() { - return ( -
- } - prevIcon={<>} - dayLabelRender={() => ( -
-
- شنبه -
-
- ۱ شنبه -
-
- ۲ شنبه -
-
- ۳ شنبه -
-
- ۴ شنبه -
-
- ۵ شنبه -
-
- جمعه -
-
- )} - /> -
- ); -} - -export default Date; diff --git a/components/layoutPanel/userDetail/Head.js b/components/layoutPanel/userDetail/Head.js deleted file mode 100644 index e7d7b60..0000000 --- a/components/layoutPanel/userDetail/Head.js +++ /dev/null @@ -1,66 +0,0 @@ -import CircularLoading from "@/app/component/loading/Circular"; -import TextLoading from "@/app/component/loading/Text"; -import ArrowLeftBlueP from "@/components/icons/ArrowLeftBlueP"; -import LocationP from "@/components/icons/LocationP"; -import { Button } from "@mui/material"; -import Image from "next/image"; -import React from "react"; - -function Head({ data, loading, representationInfo }) { - const cityName = representationInfo?.city?.label || "اهواز"; - - return ( -
- - profile - -
- -

- {data.name} -

-
-
-
- - -

- نماینده شهر {cityName} -

-
-
-
-
-

- کل بیماران -

- -

- {data.all_patients} -

-
-
- -
-

- کل نوبت ها -

- -

- {data.total_turns} -

-
-
-
- -
- ); -} - -export default Head; diff --git a/components/layoutPanel/userDetail/index.js b/components/layoutPanel/userDetail/index.js deleted file mode 100644 index 47ade43..0000000 --- a/components/layoutPanel/userDetail/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import Head from "./Head"; -import Date from "./Date"; -import Activities from "./Activities"; - -function UserDetail({ data, loading, representationInfo }) { - return ( -
-
- - - - -
-
- ); -} - -export default UserDetail; diff --git a/components/panel/ColTable.js b/components/panel/ColTable.js deleted file mode 100644 index 23490d7..0000000 --- a/components/panel/ColTable.js +++ /dev/null @@ -1,70 +0,0 @@ -import CircularLoading from "@/app/component/loading/Circular"; -import TextLoading from "@/app/component/loading/Text"; -import Image from "next/image"; - -function ColTable({ data, loading }) { - return ( -
    - {data.map((item, idx) => ( -
  • -
    -
    - - doctor - - -

    - {item.name} -

    -
    -
    - -

    - تعداد نوبت: {item.number_of_turns} -

    -
    -
    -
    -
    -

    - تخصص: -

    - -

    - {item.expertise} -

    -
    -
    - -
    -

    - تاریخ نوبت: -

    - -

    - {item.date} -

    -
    -
    - -
    -

    - ساعت نوبت: -

    - -

    - {item.hour} -

    -
    -
    -
    -
  • - ))} -
- ); -} - -export default ColTable; diff --git a/components/panel/Content.js b/components/panel/Content.js deleted file mode 100644 index adf8516..0000000 --- a/components/panel/Content.js +++ /dev/null @@ -1,66 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; -import Header from "@/components/layoutPanel/header"; -import Sidebar from "@/components/layoutPanel/sidebar"; -import UserDetail from "@/components/layoutPanel/userDetail"; -import { usePathname } from "next/navigation"; -import BgGray from "@/components/layoutPanel/sidebar/BgGray"; -import { adaptRepresentationInfo } from "@/lib/representationAdapters"; - -function Content({ children, representationInfo }) { - const pathname = usePathname(); - const [active, setActive] = useState(false); - const [open, setOpen] = useState(true); - const [loading, setLoading] = useState(true); - const info = adaptRepresentationInfo(representationInfo); - - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 2000); - }, []); - - return ( -
- - -
-
-
- {children} -
-
- {pathname.includes("dashboard") && ( - - )} -
- ); -} - -export default Content; diff --git a/components/panel/addDoctor/defaultState.js b/components/panel/addDoctor/defaultState.js deleted file mode 100644 index 5e48fe1..0000000 --- a/components/panel/addDoctor/defaultState.js +++ /dev/null @@ -1,15 +0,0 @@ -export const defaultState = { - 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 }, - phone: { value: "", placeholder: "", isEdit: true }, - degree: { value: "", isEdit: true }, - gender: { value: "woman", isEdit: true }, -}; diff --git a/components/panel/addDoctor/form/Fields.js b/components/panel/addDoctor/form/Fields.js deleted file mode 100644 index 7c18f89..0000000 --- a/components/panel/addDoctor/form/Fields.js +++ /dev/null @@ -1,97 +0,0 @@ -import Selector from "./fields/Selector"; -import ContentText from "@/app/component/ContentText"; -import EditField from "@/app/component/fields/EditField"; -import GroupedSelect from "@/app/component/selectors/GroupedSelect"; -import MultipleSelect from "@/app/component/selectors/MultipleSelect"; - -// Data -import specialties from "@/data/specialties.json"; -import education from "@/data/education.json"; - -const validate_medical_number = { - min: 1, - max: 9999999999, -}; - -function Fields({ services, data, updateNum, changeData }) { - return ( - <> - - - - - - - - - - - - - - - - - - - - - - - ); -} - -export default Fields; diff --git a/components/panel/addDoctor/form/fields/FieldDate.js b/components/panel/addDoctor/form/fields/FieldDate.js deleted file mode 100644 index a43b3de..0000000 --- a/components/panel/addDoctor/form/fields/FieldDate.js +++ /dev/null @@ -1,54 +0,0 @@ -import { useState } from "react"; - -import { convertToJalali } from "@/helper"; -import EditField from "@/app/component/fields/EditField"; -import ButtonDate from "@/app/component/ButtonDate"; -import CalendarPD from "@/components/icons/CalendarPD"; -import ContentText from "@/app/component/ContentText"; - -function FieldDate({ changeListData, data }) { - const [anchorEl, setAnchorEl] = useState(null); - const open = Boolean(anchorEl); - const id = open ? "simple-popover" : undefined; - - const updateDate = (newDate) => { - const jalaliDate = newDate - ? convertToJalali(newDate) - : "تاریخ مد نظر پیدا نشد..."; - changeListData(jalaliDate, "value", "time_work"); - }; - - const handleClick = (event) => { - setAnchorEl(event.currentTarget); - }; - - return ( - - -
- } - isTransparent={true} - iconGray={true} - name="time_work" - /> - -
-
-
- ); -} - -export default FieldDate; diff --git a/components/panel/addDoctor/form/fields/RadioGender.js b/components/panel/addDoctor/form/fields/RadioGender.js deleted file mode 100644 index 1adc3e4..0000000 --- a/components/panel/addDoctor/form/fields/RadioGender.js +++ /dev/null @@ -1,34 +0,0 @@ -import { FormControlLabel, Radio, RadioGroup } from "@mui/material"; - -function RadioGender({ changeData, name, data }) { - return ( - changeData(e.target.value, "value", name)} - sx={{ - "& .muirtl-j204z7-MuiFormControlLabel-root": { - marginLeft: "0 !important", - }, - }} - > - } - dir="rtl" - className="!text-[#A1A1A1]" - /> - } - dir="rtl" - className="!text-[#A1A1A1]" - /> - - ); -} - -export default RadioGender; diff --git a/components/panel/addDoctor/form/fields/Selector.js b/components/panel/addDoctor/form/fields/Selector.js deleted file mode 100644 index f38cf2b..0000000 --- a/components/panel/addDoctor/form/fields/Selector.js +++ /dev/null @@ -1,85 +0,0 @@ -import BottomSelect from "@/components/icons/BottomSelect"; -import { Autocomplete, Button, TextField } from "@mui/material"; -import { styleTextSelectRight } from "@/mui"; - -function Selector({ data, updateData, nameKey, label, name, list }) { - const selectedOption = list.find((item) => item.id === data) || null; - - return ( - option[nameKey] || ""} - 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, - "& 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/form/index.js b/components/panel/addDoctor/form/index.js deleted file mode 100644 index c0ace2d..0000000 --- a/components/panel/addDoctor/form/index.js +++ /dev/null @@ -1,73 +0,0 @@ -import { useEffect, useState } from "react"; -import FieldDate from "./fields/FieldDate"; -import RadioGender from "./fields/RadioGender"; -import SendReq from "./sendReq"; -import ContentText from "@/app/component/ContentText"; -import { request } from "@/services/response"; -import Fields from "./Fields"; - -const validate_medical_number = { - min: 1, - max: 9999999999, -}; - -function Form({ image, data, setData, resetData }) { - const [services, setServices] = useState([]); - - const changeData = (value, type, name) => { - type !== "isEdit" && - setData((prev) => { - return { - ...prev, - [name]: { - ...prev[name], - [type]: value, - }, - }; - }); - }; - - const updateNum = (value, type, name) => { - const parseValue = +value; - const { max } = validate_medical_number; - const validateValue = parseValue > max ? data[name].value : value; - changeData(validateValue, type, name); - }; - - useEffect(() => { - request - .getDoctorServices() - .then((res) => { - setServices(res.data); - }) - .catch(() => { - // - }); - }, []); - - return ( - <> -
- -
- - - - -
-
- - - ); -} - -export default Form; diff --git a/components/panel/addDoctor/form/listSelector.js b/components/panel/addDoctor/form/listSelector.js deleted file mode 100644 index 6cd4d1e..0000000 --- a/components/panel/addDoctor/form/listSelector.js +++ /dev/null @@ -1,13 +0,0 @@ -export const degree = [ - { label: "مدرک 1", id: 10 }, - { label: "مدرک 2", id: 20 }, - { label: "مدرک 3", id: 30 }, - { label: "مدرک 4", id: 40 }, -]; - -export const expertise = [ - { label: "فوق تخصص", id: 10 }, - { label: "دکترای تخصصی", id: 20 }, - { label: "متخصص", id: 30 }, - { label: "دکتری", id: 40 }, -]; diff --git a/components/panel/addDoctor/form/sendReq/function.js b/components/panel/addDoctor/form/sendReq/function.js deleted file mode 100644 index 21e0303..0000000 --- a/components/panel/addDoctor/form/sendReq/function.js +++ /dev/null @@ -1,21 +0,0 @@ -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: [data.expertise.value], - info: data.description.value, - doctor_id: data.medical_system_number.value, - doctor_services: data.skills.value, - gender: data.gender.value, - }; -}; diff --git a/components/panel/addDoctor/form/sendReq/index.js b/components/panel/addDoctor/form/sendReq/index.js deleted file mode 100644 index 4950931..0000000 --- a/components/panel/addDoctor/form/sendReq/index.js +++ /dev/null @@ -1,68 +0,0 @@ -import ArrowLeftPA from "@/components/icons/ArrowLeftPA"; -import { alert, checkAllValues } from "@/helper"; -import { request } from "@/services/response"; -import { Button } from "@mui/material"; -import { useState } from "react"; -import { transformData } from "./function"; - -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((res) => { - if (res.id) { - alert("success", "پزشک جدید با موفقیت اضافه شد!"); - resetData(); - setLoading(false); - } - }) - .catch(() => { - setLoading(false); - alert("error", "خطا در ثبت پزشک! لطفاً دوباره تلاش کنید."); - }); - }; - - const saveImg = () => { - resetData(); - setLoading(true); - if (img) { - request - .postImageUpload(img.file) - .then((res) => { - const imgId = res.fid[0].value; - saveData(imgId); - }) - .catch(() => { - setLoading(false); - }); - } else { - saveData(); - } - }; - - return ( -
- -
- ); -} - -export default SendReq; diff --git a/components/panel/addDoctor/index.js b/components/panel/addDoctor/index.js deleted file mode 100644 index adac173..0000000 --- a/components/panel/addDoctor/index.js +++ /dev/null @@ -1,31 +0,0 @@ -"use client"; - -import Form from "./form"; -import { useState } from "react"; -import { defaultState } from "./defaultState"; -import UploadFile from "@/app/component/uploadFile"; - -function AddDoctorPage() { - const [data, setData] = useState(defaultState); - const [image, setImage] = useState(""); - - const resetData = () => { - setData(defaultState); - setImage(); - }; - - return ( -
- -
-
- ); -} - -export default AddDoctorPage; diff --git a/components/panel/dashboard/Cards.js b/components/panel/dashboard/Cards.js deleted file mode 100644 index 085999e..0000000 --- a/components/panel/dashboard/Cards.js +++ /dev/null @@ -1,63 +0,0 @@ -import CalendarTickGreenP from "../../icons/CalendarTickGreenP"; -import TextLoading from "@/app/component/loading/Text"; -import CardOrangeP from "../../icons/CardOrangeP"; -import PeopleBlueP from "../../icons/PeopleBlueP"; - -function Cards({ data, loading }) { - const list = [ - { - text: "تعداد کل بیماران", - bg_color: "bg-[#E5E9FF] dark:bg-[#5559CE]", - value: data.number_of_patients, - label: "نفر", - icon: , - }, - { - text: "نوبت های امروز", - bg_color: "bg-[rgba(20,204,38,0.14)] dark:bg-[#009D79]", - value: data.today_turns, - label: "نوبت", - icon: , - }, - { - text: "پرداختی ها", - bg_color: "bg-[#FFD8C5] dark:bg-[#F17732]", - value: data.payments, - label: "تومان", - icon: , - }, - ]; - - return ( -
    - {list.map((item, idx) => ( -
  • -
    - {item.icon} -
    -
    -

    - {item.text} -

    - -

    - {item.value} - - {item.label} - -

    -
    -
    -
  • - ))} -
- ); -} - -export default Cards; diff --git a/components/panel/dashboard/amountOfIncome/Chart.js b/components/panel/dashboard/amountOfIncome/Chart.js deleted file mode 100644 index 10c5447..0000000 --- a/components/panel/dashboard/amountOfIncome/Chart.js +++ /dev/null @@ -1,90 +0,0 @@ -"use client"; - -import { LineChart, lineElementClasses } from "@mui/x-charts"; - -function Chart({ data, loading }) { - return ( - - - - - - - - - ); -} - -export default Chart; diff --git a/components/panel/dashboard/amountOfIncome/Head.js b/components/panel/dashboard/amountOfIncome/Head.js deleted file mode 100644 index 16d1107..0000000 --- a/components/panel/dashboard/amountOfIncome/Head.js +++ /dev/null @@ -1,65 +0,0 @@ -"use client"; - -import ArrowDownP from "@/components/icons/ArrowDownP"; -import { MenuItem, Select } from "@mui/material"; - -function Head() { - const list = [ - { id: 1, text: "سال 1402" }, - { id: 2, text: "سال 1403" }, - { id: 3, text: "سال 1404" }, - { id: 4, text: "سال 1405" }, - { id: 5, text: "سال 1406" }, - { id: 6, text: "سال 1407" }, - ]; - - return ( -
-

- میزان درآمد -

- -
- ); -} - -export default Head; diff --git a/components/panel/dashboard/amountOfIncome/index.js b/components/panel/dashboard/amountOfIncome/index.js deleted file mode 100644 index fd7bbcd..0000000 --- a/components/panel/dashboard/amountOfIncome/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import Chart from "./Chart"; -import Head from "./Head"; - -function AmountOfIncome({ data, loading }) { - return ( -
- -
- -
-
- ); -} - -export default AmountOfIncome; diff --git a/components/panel/dashboard/index.js b/components/panel/dashboard/index.js deleted file mode 100644 index 519e832..0000000 --- a/components/panel/dashboard/index.js +++ /dev/null @@ -1,31 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; - -import Activities from "@/components/layoutPanel/userDetail/Activities"; -import AmountOfIncome from "./amountOfIncome"; -import Cards from "./Cards"; -import List from "./list"; - -function DashboardPage({ data }) { - const [loading, setLoading] = useState(true); - - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 2000); - }, []); - - return ( -
- - - -
- -
-
- ); -} - -export default DashboardPage; diff --git a/components/panel/dashboard/list/Table.js b/components/panel/dashboard/list/Table.js deleted file mode 100644 index 34e5582..0000000 --- a/components/panel/dashboard/list/Table.js +++ /dev/null @@ -1,84 +0,0 @@ -import CustomTable from "@/app/component/CustomTable"; -import CircularLoading from "@/app/component/loading/Circular"; -import TextLoading from "@/app/component/loading/Text"; -import { TableCell, TableRow } from "@mui/material"; -import Image from "next/image"; - -function Table({ data, loading }) { - const tableHead = ["ردیف", "نام پزشک", "تخصص", "تاریخ", "ساعت", "تعدد نوبت"]; - const centerTable = [0, 4]; - - return ( -
- - {data.list_of_doctors_appointments.map((row, idx) => ( - - - - {idx + 1} - - - -
- - doctor - - - {row.name} - -
-
- - - {row.expertise} - - - - - {row.date} - - - - - {row.hour} - - - - - {row.number_of_turns} - - -
- ))} -
-
- ); -} - -export default Table; diff --git a/components/panel/dashboard/list/index.js b/components/panel/dashboard/list/index.js deleted file mode 100644 index 0b0aa34..0000000 --- a/components/panel/dashboard/list/index.js +++ /dev/null @@ -1,29 +0,0 @@ -import { Button } from "@mui/material"; -import ArrowLeftP from "../../../icons/ArrowLeftP"; -import Table from "./Table"; -import ColTable from "../../ColTable"; - -function List({ data, loading }) { - return ( -
-
-

- لیست نوبت های پزشکان -

- -
-
- - - - - ); -} - -export default List; diff --git a/components/panel/turns/head/Date.js b/components/panel/turns/head/Date.js deleted file mode 100644 index 6f19627..0000000 --- a/components/panel/turns/head/Date.js +++ /dev/null @@ -1,14 +0,0 @@ -import FilterDate from "./FilterDate"; - -function Date() { - return ( -
-

- انتخاب بازه زمانی -

- -
- ); -} - -export default Date; diff --git a/components/panel/turns/head/FilterDate.js b/components/panel/turns/head/FilterDate.js deleted file mode 100644 index 3352e79..0000000 --- a/components/panel/turns/head/FilterDate.js +++ /dev/null @@ -1,37 +0,0 @@ -import { useState } from "react"; -import { convertToJalali } from "@/helper"; -import { ButtonGroup } from "@mui/material"; -import PopoverDate from "@/app/component/PopoverDate"; - -function FilterDate() { - const [date, setDate] = useState({ - start: null, - end: null, - }); - - const updateDate = (newDate, type) => { - setDate({ - ...date, - [type]: newDate, - }); - }; - - return ( - - - - - ); -} - -export default FilterDate; diff --git a/components/panel/turns/head/SearchDoctor.js b/components/panel/turns/head/SearchDoctor.js deleted file mode 100644 index 9450f02..0000000 --- a/components/panel/turns/head/SearchDoctor.js +++ /dev/null @@ -1,53 +0,0 @@ -import ArrowBottomP from "@/components/icons/ArrowBottomP"; -import ExportP from "@/components/icons/ExportP"; -import SearchD from "@/components/icons/SearchD"; -import { Button, ButtonGroup, TextField } from "@mui/material"; - -function SearchDoctor() { - return ( -
- - - - - -
- ); -} - -export default SearchDoctor; diff --git a/components/panel/turns/head/index.js b/components/panel/turns/head/index.js deleted file mode 100644 index cf43f00..0000000 --- a/components/panel/turns/head/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import Date from "./Date"; -import SearchDoctor from "./SearchDoctor"; - -function Head() { - return ( -
-
-

- لیست نوبت های پزشکان -

- -
- -
- ); -} - -export default Head; diff --git a/components/panel/turns/index.js b/components/panel/turns/index.js deleted file mode 100644 index b7d5654..0000000 --- a/components/panel/turns/index.js +++ /dev/null @@ -1,25 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; - -import Head from "./head"; -import List from "./list"; - -function TurnsPage({ data }) { - const [loading, setLoading] = useState(true); - - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 2000); - }, []); - - return ( -
- - -
- ); -} - -export default TurnsPage; diff --git a/components/panel/turns/list/Cards.js b/components/panel/turns/list/Cards.js deleted file mode 100644 index 8649bde..0000000 --- a/components/panel/turns/list/Cards.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; - -function Cards() { - return
Cards
; -} - -export default Cards; diff --git a/components/panel/turns/list/Table.js b/components/panel/turns/list/Table.js deleted file mode 100644 index b2c3312..0000000 --- a/components/panel/turns/list/Table.js +++ /dev/null @@ -1,83 +0,0 @@ -import Image from "next/image"; - -import { TableCell, TableRow } from "@mui/material"; -import Pagination from "@/app/component/Pagination"; -import CustomTable from "@/app/component/CustomTable"; -import TextLoading from "@/app/component/loading/Text"; -import CustomLoading from "@/app/component/loading/Custom"; -import CircularLoading from "@/app/component/loading/Circular"; - -function Table({ data, loading }) { - const tableHead = ["ردیف", "نام پزشک", "تخصص", "تاریخ", "ساعت", "تعدد نوبت"]; - const centerTable = [0, 4]; - - return ( -
- - {data.list_of_doctors_appointments.map((row, idx) => ( - - - - {idx + 1} - - - -
- - - - - {row.name} - -
-
- - - {row.expertise} - - - - - {row.date} - - - - - {row.hour} - - - - - {row.number_of_turns} - - -
- ))} -
-
- -
-
- ); -} - -export default Table; diff --git a/components/panel/turns/list/index.js b/components/panel/turns/list/index.js deleted file mode 100644 index 0fa2e3d..0000000 --- a/components/panel/turns/list/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import ColTable from "../../ColTable"; -import Table from "./Table"; - -function List({ data, loading }) { - return ( -
-
- - - ); -} - -export default List; diff --git a/components/panel/userAccount/Tab.js b/components/panel/userAccount/Tab.js deleted file mode 100644 index 4f6b5fe..0000000 --- a/components/panel/userAccount/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/userAccount/account/Head.js b/components/panel/userAccount/account/Head.js deleted file mode 100644 index e0b5c9a..0000000 --- a/components/panel/userAccount/account/Head.js +++ /dev/null @@ -1,12 +0,0 @@ -"use client"; - -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/userAccount/account/form/index.js b/components/panel/userAccount/account/form/index.js deleted file mode 100644 index a3ae0d7..0000000 --- a/components/panel/userAccount/account/form/index.js +++ /dev/null @@ -1,157 +0,0 @@ -"use client"; - -import { useState } from "react"; - -import ContentText from "../../../../../app/component/ContentText"; -import EditField from "@/app/component/fields/EditField"; -import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect"; -import { bank, city, state } from "./listSelector"; -import AddLocationP from "@/components/icons/AddLocationP"; -import { Button } from "@mui/material"; -import ArrowLeftButtonP from "@/components/icons/ArrowLeftButtonP"; - -const validate_phone_number = { - min: 1, - max: 9999999999, -}; - -function Form() { - const [data, setData] = useState({ - name: { value: "", isEdit: true }, - national_code: { value: "", isEdit: true }, - address: { value: "", isEdit: true }, - phone: { value: "", isEdit: true }, - account_number: { value: "", isEdit: true }, - }); - const [selected, setSelected] = useState({ - state: "", - city: "", - bank: "", - }); - const updateSelect = (event, name) => - setSelected({ ...selected, [name]: event }); - - const changeData = (value, type, name) => - setData({ - ...data, - [name]: { - ...data[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/userAccount/account/form/listSelector.js b/components/panel/userAccount/account/form/listSelector.js deleted file mode 100644 index 45b9944..0000000 --- a/components/panel/userAccount/account/form/listSelector.js +++ /dev/null @@ -1,20 +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 }, -]; - -export const bank = [ - { label: "بانک 1", id: 10 }, - { label: "بانک 2", id: 20 }, - { label: "بانک 3", id: 30 }, - { label: "بانک 4", id: 40 }, -]; diff --git a/components/panel/userAccount/account/index.js b/components/panel/userAccount/account/index.js deleted file mode 100644 index 97f69e0..0000000 --- a/components/panel/userAccount/account/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import Form from "./form"; -import Head from "./Head"; - -function Account() { - return ( -
- - -
- ); -} - -export default Account; diff --git a/components/panel/userAccount/bank/List.js b/components/panel/userAccount/bank/List.js deleted file mode 100644 index 52ec17d..0000000 --- a/components/panel/userAccount/bank/List.js +++ /dev/null @@ -1,91 +0,0 @@ -import CustomTable from "@/app/component/CustomTable"; -import { Button, TableCell, TableRow } from "@mui/material"; -import TextLoading from "@/app/component/loading/Text"; -import TrashB from "@/components/icons/TrashB"; -import EditB from "@/components/icons/EditB"; -import SwitchTable from "@/app/component/SwitchTable"; - -function List({ data, loading, changeStatus }) { - const tableHead = ["ردیف", "شماره کارت", "شماره شبا", "بانک", "وضعیت", ""]; - const centerTable = [0, 4, 5]; - - return ( -
-
- - {data.map((row, idx) => ( - - - - {idx + 1} - - - - - {row.card_number} - - - - - {row.shaba_number} - - - - - {row.bank} - - - - -
-

- {row.status ? "فعال" : "غیر فعال"} -

- -
-
-
- -
- - -
-
-
- ))} -
-
-
- ); -} - -export default List; diff --git a/components/panel/userAccount/bank/cards/Item.js b/components/panel/userAccount/bank/cards/Item.js deleted file mode 100644 index 4af89ab..0000000 --- a/components/panel/userAccount/bank/cards/Item.js +++ /dev/null @@ -1,78 +0,0 @@ -import TextLoading from "@/app/component/loading/Text"; -import SwitchTable from "@/app/component/SwitchTable"; -import EditB from "@/components/icons/EditB"; -import TrashB from "@/components/icons/TrashB"; -import { Button } from "@mui/material"; - -function Item({ data, loading, changeStatus }) { - return ( -
  • -
    -
    - -
    -

    - {data.status ? "فعال" : "غیر فعال"} -

    - -
    -
    -
    -
    - - -
    -
    -
      -
    • - -

      - شماره کارت: -

      -
      - -

      - {data.card_number} -

      -
      -
    • - -
    • - -

      - شماره شبا: -

      -
      - -

      - {data.shaba_number} -

      -
      -
    • - -
    • - -

      - بانک: -

      -
      - -

      - {data.bank} -

      -
      -
    • -
    -
  • - ); -} - -export default Item; diff --git a/components/panel/userAccount/bank/cards/index.js b/components/panel/userAccount/bank/cards/index.js deleted file mode 100644 index c28540a..0000000 --- a/components/panel/userAccount/bank/cards/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import Item from "./Item"; - -function Cards({ data, loading, changeStatus }) { - return ( -
      - {data.map((item, idx) => ( - - ))} -
    - ); -} - -export default Cards; diff --git a/components/panel/userAccount/bank/head/index.js b/components/panel/userAccount/bank/head/index.js deleted file mode 100644 index 13f6c95..0000000 --- a/components/panel/userAccount/bank/head/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ModalAddCard from "./modal"; - -function Head() { - return ( -
    -

    - کارت های بانکی شما -

    - -
    - ); -} - -export default Head; diff --git a/components/panel/userAccount/bank/head/modal/Form.js b/components/panel/userAccount/bank/head/modal/Form.js deleted file mode 100644 index 6dbea5c..0000000 --- a/components/panel/userAccount/bank/head/modal/Form.js +++ /dev/null @@ -1,58 +0,0 @@ -import EditField from "@/app/component/fields/EditField"; -import ContentText from "@/app/component/ContentText"; -import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect"; -import { validate_phone_number } from "./validate"; - -const list = [ - { label: "بانک 1", id: 10 }, - { label: "بانک 2", id: 20 }, - { label: "بانک 3", id: 30 }, - { label: "بانک 4", id: 40 }, -]; - -function Form({ data, changeData, updateNum }) { - return ( -
    - - - - - - - - - -
    - ); -} - -export default Form; diff --git a/components/panel/userAccount/bank/head/modal/index.js b/components/panel/userAccount/bank/head/modal/index.js deleted file mode 100644 index 7ec63dd..0000000 --- a/components/panel/userAccount/bank/head/modal/index.js +++ /dev/null @@ -1,82 +0,0 @@ -import { useState } from "react"; -import Form from "./Form"; -import { styleDefault } from "@/mui"; -import { Box, Button, Modal } from "@mui/material"; - -// Icons -import PlusB from "@/components/icons/PlusB"; -import CloseModalD from "@/components/icons/CloseModalD"; - -function ModalAddCard() { - const [open, setOpen] = useState(false); - const [data, setData] = useState({ - card: { value: "", is_edit: true }, - shaba: { value: "", is_edit: true }, - bank: { value: "", is_edit: true }, - }); - - const handleOpen = () => setOpen(true); - const handleClose = () => setOpen(false); - - const changeData = (value, name) => - setData({ ...data, [name]: { ...data[name], value } }); - - const updateNum = (value, type, name) => { - const parseValue = +value; - - changeData(parseValue, name); - }; - - const isValidData = data.card && data.shaba && data.value && data.value.value; - - return ( - <> - {/* Button Modal */} - - {/* Content Modal */} - - -
    -

    - اضافه کردن شماره کارت -

    - -
    - -
    - - -
    -
    -
    - - ); -} - -export default ModalAddCard; diff --git a/components/panel/userAccount/bank/head/modal/validate.js b/components/panel/userAccount/bank/head/modal/validate.js deleted file mode 100644 index 1c39b81..0000000 --- a/components/panel/userAccount/bank/head/modal/validate.js +++ /dev/null @@ -1,6 +0,0 @@ -const validate_phone_number = { - min: 1, - max: 9999999999, -}; - -export { validate_phone_number }; diff --git a/components/panel/userAccount/bank/index.js b/components/panel/userAccount/bank/index.js deleted file mode 100644 index 40f569b..0000000 --- a/components/panel/userAccount/bank/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import { useState } from "react"; -import Cards from "./cards"; -import Head from "./head"; -import List from "./List"; - -function Bank({ data, loading }) { - const [list, setList] = useState(data); - - const changeStatus = (value, id) => { - let newList = list; - if (value) { - newList = newList.map((item, idx) => { - return { - ...item, - status: item.id === id ? value : false, - }; - }); - } - setList(newList); - }; - - return ( -
    - - - -
    - ); -} - -export default Bank; diff --git a/components/panel/userAccount/index.js b/components/panel/userAccount/index.js deleted file mode 100644 index 3392eb5..0000000 --- a/components/panel/userAccount/index.js +++ /dev/null @@ -1,38 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; -import Account from "./account"; -import Bank from "./bank"; -import Tab from "./Tab"; - -const listTab = ["حساب کاربری", "حساب بانکی"]; - -function UserAccountPage({ data }) { - const [value, setValue] = useState(0); - const [loading, setLoading] = useState(true); - - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 2000); - }, []); - - const handleChange = (event, newValue) => setValue(newValue); - - const components = [, ]; - - return ( -
    - -
    {components[value]}
    -
    - ); -} - -export default UserAccountPage; diff --git a/lib/ability.js b/lib/ability.js index 0d51dee..9e0610a 100644 --- a/lib/ability.js +++ b/lib/ability.js @@ -1,5 +1,4 @@ import { AbilityBuilder, createMongoAbility } from "@casl/ability"; -import { safeJsonParse } from "./sanitize"; export function defineAbilitiesFor(user) { const { can, cannot, build } = new AbilityBuilder(createMongoAbility); @@ -7,11 +6,6 @@ export function defineAbilitiesFor(user) { if (user) { can("access", "Dashboard"); cannot("access", "Login"); - const parsedData = safeJsonParse(user.value); - const roles = parsedData?.roles; - if (roles && Array.isArray(Object.values(roles)) && Object.values(roles).includes("representation")) { - can("access", "Panel"); - } } else { can("access", "Login"); cannot("access", "Dashboard"); diff --git a/lib/representationAdapters.js b/lib/representationAdapters.js index 4f4a1ab..10b2463 100644 --- a/lib/representationAdapters.js +++ b/lib/representationAdapters.js @@ -1,56 +1,3 @@ -import moment from "moment-jalaali"; - -const DEFAULT_AVATAR = "/assets/images/doctor.png"; - -function toJalali(date) { - if (!date) return "--"; - return moment(date).format("jYYYY/jM/jD"); -} - -export function adaptRepresentationInfo(representationInfo) { - const data = representationInfo?.data ?? representationInfo ?? {}; - - return { - name: data.full_name ?? "", - src: data.avatar ?? DEFAULT_AVATAR, - detail: data.city_name ? `نماینده شهر ${data.city_name}` : "نماینده", - mobile_number: data.mobile_number ?? "", - commission_percent: data.commission_percent ?? null, - bank_account: data.bank_account ?? null, - city: { label: data.city_name ?? "" }, - all_patients: null, - total_turns: null, - number_of_patients: null, - today_turns: null, - payments: null, - todays_activities: [], - list_of_doctors_appointments: [], - chart_amount_income: [], - }; -} - -export function adaptRepresentationDashboard(dashboard) { - const stats = dashboard?.data?.stats ?? dashboard?.stats ?? {}; - const daily = Array.isArray(stats.daily) ? stats.daily : []; - - return { - number_of_patients: stats.total_appointments ?? 0, - today_turns: daily.length ? daily[daily.length - 1].appointments ?? 0 : 0, - payments: stats.total_revenue_rials ?? 0, - commission_rials: stats.commission_rials ?? 0, - chart_amount_income: daily.map((d) => d.revenue ?? 0), - list_of_doctors_appointments: daily.map((d) => ({ - name: "", - expertise: "", - image: DEFAULT_AVATAR, - date: toJalali(d.date), - hour: "", - number_of_turns: d.appointments ?? 0, - })), - todays_activities: [], - }; -} - export function buildPatientUser(profile, extras = {}) { // GET /user-profile is double-nested: { data: { data: {...} } } (after fetchReq → response.data) const data = profile?.data?.data ?? profile?.data ?? profile ?? {}; @@ -81,17 +28,3 @@ export function buildPatientUser(profile, extras = {}) { messages: [], }; } - -export function adaptBankAccount(bankAccount) { - if (!bankAccount) return []; - return [ - { - id: 1, - card_number: bankAccount.account_number ?? "", - shaba_number: bankAccount.iban ?? "", - bank: bankAccount.bank_name ?? "", - owner_name: bankAccount.owner_name ?? "", - status: true, - }, - ]; -}