feat(panel): wire panel header/userDetail to real representation info
افزودن adaptRepresentationInfo که خروجی API نماینده را به propهای کامپوننتهای نمایشی map میکند و حذف import داده mock از Content پنل. فیلدهای آماری بدون معادل API خالی میمانند (بدون داده ساختگی). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3,16 +3,17 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import Header from "@/components/layoutPanel/header";
|
import Header from "@/components/layoutPanel/header";
|
||||||
import Sidebar from "@/components/layoutPanel/sidebar";
|
import Sidebar from "@/components/layoutPanel/sidebar";
|
||||||
import Information from "@/data/information.json";
|
|
||||||
import UserDetail from "@/components/layoutPanel/userDetail";
|
import UserDetail from "@/components/layoutPanel/userDetail";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import BgGray from "@/components/layoutPanel/sidebar/BgGray";
|
import BgGray from "@/components/layoutPanel/sidebar/BgGray";
|
||||||
|
import { adaptRepresentationInfo } from "@/helper";
|
||||||
|
|
||||||
function Content({ children, representationInfo }) {
|
function Content({ children, representationInfo }) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const [active, setActive] = useState(false);
|
const [active, setActive] = useState(false);
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const info = adaptRepresentationInfo(representationInfo);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -43,7 +44,7 @@ function Content({ children, representationInfo }) {
|
|||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<Header
|
<Header
|
||||||
data={Information}
|
data={info}
|
||||||
setActive={setActive}
|
setActive={setActive}
|
||||||
disableProfile={pathname.includes("dashboard")}
|
disableProfile={pathname.includes("dashboard")}
|
||||||
/>
|
/>
|
||||||
@@ -53,7 +54,7 @@ function Content({ children, representationInfo }) {
|
|||||||
</main>
|
</main>
|
||||||
{pathname.includes("dashboard") && (
|
{pathname.includes("dashboard") && (
|
||||||
<UserDetail
|
<UserDetail
|
||||||
data={Information}
|
data={info}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
representationInfo={representationInfo}
|
representationInfo={representationInfo}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -674,3 +674,25 @@ export function changeNumToDefault(str) {
|
|||||||
.replace(/[۰-۹]/g, d => "۰۱۲۳۴۵۶۷۸۹".indexOf(d))
|
.replace(/[۰-۹]/g, d => "۰۱۲۳۴۵۶۷۸۹".indexOf(d))
|
||||||
.replace(/[٠-٩]/g, d => "٠١٢٣٤٥٦٧٨٩".indexOf(d));
|
.replace(/[٠-٩]/g, d => "٠١٢٣٤٥٦٧٨٩".indexOf(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function adaptRepresentationInfo(representationInfo) {
|
||||||
|
const data = representationInfo?.data ?? representationInfo ?? {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: data.full_name ?? "",
|
||||||
|
src: data.avatar ?? "/assets/images/doctor.png",
|
||||||
|
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: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user