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 }) { >