From dc1c6d25bec41c25dc09bbd0dc700556e507a1a7 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Mon, 15 Jun 2026 00:10:40 +0330 Subject: [PATCH] feat(dashboard): connect patient dashboard to real user profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - buildPatientUser: ساخت آبجکت user از user-profile واقعی با کلیدهای مورد انتظار کامپوننت‌ها؛ comments/messages خالی و اعداد هدر صفر (بدون داده ساختگی، چون endpoint ندارند) - app/dashboard/page.js پروفایل را server-side از user-profile/{uuid} می‌گیرد - حذف import userData.json mock از Content داشبورد - نوبت/تراکنش/تب اطلاعات از قبل به API واقعی وصل بودند (بدون تغییر) Co-Authored-By: Claude Opus 4.8 --- app/dashboard/page.js | 12 ++++++++++++ components/dashboard/Content.js | 7 +++---- lib/representationAdapters.js | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/dashboard/page.js b/app/dashboard/page.js index d9ddeb8..99a222c 100644 --- a/app/dashboard/page.js +++ b/app/dashboard/page.js @@ -5,6 +5,8 @@ import { getStateInfo } from "@/lib/getStateInfo"; import { removeToken } from "@/utils"; import { cookies } from "next/headers"; import { redirect } from "next/navigation"; +import { fetchReq } from "@/lib/req"; +import { buildPatientUser } from "@/lib/representationAdapters"; export default async function Dashboard({ searchParams }) { const awaitedSearchParams = await searchParams; @@ -20,11 +22,21 @@ export default async function Dashboard({ searchParams }) { return redirect("/login"); } + const uuid = cookieStore.get("uuid")?.value; + let profile = null; + if (uuid) { + profile = await fetchReq( + `${process.env.NEXT_PUBLIC_API_URL}/api/v1/user-profile/${uuid}`, + { headers: { Authorization: `Bearer ${token.value}` } } + ); + } + return ( ); } diff --git a/components/dashboard/Content.js b/components/dashboard/Content.js index bf2bbcd..8fefaf0 100644 --- a/components/dashboard/Content.js +++ b/components/dashboard/Content.js @@ -2,11 +2,10 @@ import { useState } from "react"; -import userData from "@/data/userData.json"; import DashboardPage from "@/components/dashboard"; import UserAccountPage from "./userAccount"; -function Content({ matchedCity, params, logged }) { +function Content({ matchedCity, params, logged, user }) { const [value, setValue] = useState(Number(params?.sidebar) || 0); const [isOpenSide, setIsOpenSide] = useState(); const [isTurnsDetails, setIsTurnsDetails] = useState(null); @@ -16,7 +15,7 @@ function Content({ matchedCity, params, logged }) { value={value} logged={logged} setValue={setValue} - user={userData.data} + user={user} isOpenSide={isOpenSide} matchedCity={matchedCity} setIsOpenSide={setIsOpenSide} @@ -25,7 +24,7 @@ function Content({ matchedCity, params, logged }) { >