feat(panel): connect turns/user-account/add-doctor to real data
- انتقال adapterهای نماینده به lib/representationAdapters (server-safe، بدون وابستگی client مثل js-cookie/react-toastify) - turns: لیست از daily[] داشبورد ماهانه (ستون نام/تخصص خالی، بدون داده ساختگی) - user-account: حساب بانکی واقعی از bank_account نماینده (map به آرایه تککارته) - add-doctor: حذف import mock مرده (کامپوننت data مصرف نمیکرد) - رفع dead import اشتباه از turns/page در clinic/doctors که build را میشکست Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import AddDoctorPage from "@/components/panel/addDoctor";
|
||||
import Information from "@/data/information.json";
|
||||
|
||||
function AddDoctor() {
|
||||
return <AddDoctorPage data={Information} />;
|
||||
return <AddDoctorPage />;
|
||||
}
|
||||
|
||||
export default AddDoctor;
|
||||
|
||||
@@ -2,7 +2,7 @@ import DashboardPage from "@/components/panel/dashboard";
|
||||
import { cookies } from "next/headers";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
import { safeJsonParse } from "@/lib/sanitize";
|
||||
import { adaptRepresentationDashboard } from "@/helper";
|
||||
import { adaptRepresentationDashboard } from "@/lib/representationAdapters";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
@@ -1,8 +1,40 @@
|
||||
import TurnsPage from "@/components/panel/turns";
|
||||
import Information from "@/data/information.json";
|
||||
import { cookies } from "next/headers";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
import { safeJsonParse } from "@/lib/sanitize";
|
||||
import { adaptRepresentationDashboard } from "@/lib/representationAdapters";
|
||||
|
||||
function page() {
|
||||
return <TurnsPage data={Information} />;
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
async function page() {
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
let dashboard = null;
|
||||
|
||||
try {
|
||||
const cookieStore = await cookies();
|
||||
const userInfo = cookieStore.get("userInfo");
|
||||
const accessToken = cookieStore.get("access_token");
|
||||
|
||||
if (userInfo && accessToken) {
|
||||
const parsedUserInfo = safeJsonParse(userInfo.value);
|
||||
const representationUuid = parsedUserInfo?.representation_uuid;
|
||||
|
||||
if (representationUuid) {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = now.getMonth() + 1;
|
||||
|
||||
dashboard = await fetchReq(
|
||||
`${API_URL}/api/v1/representation/${representationUuid}/dashboard/monthly?year=${year}&month=${month}`,
|
||||
{ headers: { Authorization: `Bearer ${accessToken.value}` } }
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching representation turns:", error);
|
||||
}
|
||||
|
||||
return <TurnsPage data={adaptRepresentationDashboard(dashboard)} />;
|
||||
}
|
||||
|
||||
export default page;
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
import UserAccountPage from "@/components/panel/userAccount";
|
||||
import Information from "@/data/information.json";
|
||||
import Bank from "@/data/bank.json";
|
||||
import { cookies } from "next/headers";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
import { safeJsonParse } from "@/lib/sanitize";
|
||||
import { adaptBankAccount } from "@/lib/representationAdapters";
|
||||
|
||||
function UserAccount() {
|
||||
return <UserAccountPage data={{ information: Information, bank: Bank }} />;
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
async function UserAccount() {
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
let representation = null;
|
||||
|
||||
try {
|
||||
const cookieStore = await cookies();
|
||||
const userInfo = cookieStore.get("userInfo");
|
||||
const accessToken = cookieStore.get("access_token");
|
||||
|
||||
if (userInfo && accessToken) {
|
||||
const parsedUserInfo = safeJsonParse(userInfo.value);
|
||||
const representationUuid = parsedUserInfo?.representation_uuid;
|
||||
|
||||
if (representationUuid) {
|
||||
representation = await fetchReq(
|
||||
`${API_URL}/api/v1/representation/${representationUuid}`,
|
||||
{ headers: { Authorization: `Bearer ${accessToken.value}` } }
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching representation account:", error);
|
||||
}
|
||||
|
||||
const bank = adaptBankAccount(representation?.data?.bank_account);
|
||||
|
||||
return <UserAccountPage data={{ bank }} />;
|
||||
}
|
||||
|
||||
export default UserAccount;
|
||||
|
||||
Reference in New Issue
Block a user