refactor: remove unused components and files related to date filtering and doctor search

- Deleted Date.js and FilterDate.js components as they are no longer needed.
- Removed SearchDoctor.js component which was responsible for searching doctors.
- Cleaned up the Head component by removing references to the deleted Date and SearchDoctor components.
- Removed TurnsPage component and its associated List component, which were not utilized.
- Deleted Cards and Table components from the list directory as they were not in use.
- Removed user account related components including Tab, Head, and Form components.
- Cleaned up bank account components including List, Item, and modal components.
- Removed representation adapters and related functions that were not in use.
This commit is contained in:
hamed
2026-06-25 18:14:27 +03:30
parent 537f3e47d5
commit f87110c277
70 changed files with 8 additions and 2911 deletions
+1 -4
View File
@@ -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 (
<ThemeProvider
attribute={router.includes("/panel") ? "class" : "data-"}
attribute="data-"
defaultTheme="system"
enableSystem
>
+1 -29
View File
@@ -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 }) {
تراکنش های من
</Button>
</Link>
{hasRepresentationRole && (
<Link href="/panel/dashboard" className="w-full">
<Button
fullWidth
variant="text"
className="!text-[#7E7E7E] !text-[14px] !font-medium !flex !justify-start !p-[8px] !gap-[5px]"
>
<ProfilePA />
داشبورد نماینده
</Button>
</Link>
)}
<Button
fullWidth
color="error"
-7
View File
@@ -1,7 +0,0 @@
import AddDoctorPage from "@/components/panel/addDoctor";
function AddDoctor() {
return <AddDoctorPage />;
}
export default AddDoctor;
-43
View File
@@ -1,43 +0,0 @@
import DashboardPage from "@/components/panel/dashboard";
import { cookies } from "next/headers";
import { fetchReq } from "@/lib/req";
import { safeJsonParse } from "@/lib/sanitize";
import { adaptRepresentationDashboard } from "@/lib/representationAdapters";
import { getServerAccessToken } from "@/lib/serverToken";
export const dynamic = "force-dynamic";
async function Dashboard() {
const API_URL = process.env.NEXT_PUBLIC_API_URL;
let dashboard = null;
try {
const cookieStore = await cookies();
const userInfo = cookieStore.get("userInfo");
if (userInfo) {
const parsedUserInfo = safeJsonParse(userInfo.value);
const representationUuid = parsedUserInfo?.representation_uuid;
if (representationUuid) {
const accessToken = await getServerAccessToken();
if (accessToken) {
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}` } }
);
}
}
}
} catch (error) {
console.error("Error fetching representation dashboard:", error);
}
return <DashboardPage data={adaptRepresentationDashboard(dashboard)} />;
}
export default Dashboard;
-51
View File
@@ -1,51 +0,0 @@
import Content from "@/components/panel/Content";
import { defineAbilitiesFor } from "@/lib/ability";
import { getUser } from "@/lib/auth";
import { redirect } from "next/navigation";
import { cookies } from "next/headers";
import { fetchReq } from "@/lib/req";
import { safeJsonParse } from "@/lib/sanitize";
import { getServerAccessToken } from "@/lib/serverToken";
async function LayoutPanel({ children }) {
const user = await getUser();
const ability = defineAbilitiesFor(user);
if (!ability.can("access", "Panel")) {
return redirect("/");
}
let representationInfo = null;
const API_URL = process.env.NEXT_PUBLIC_API_URL;
try {
const cookieStore = await cookies();
const userInfo = cookieStore.get("userInfo");
if (userInfo) {
const parsedUserInfo = safeJsonParse(userInfo.value);
if (!parsedUserInfo) return;
const representationUuid = parsedUserInfo?.representation_uuid;
if (representationUuid) {
const accessToken = await getServerAccessToken();
if (accessToken) {
representationInfo = await fetchReq(
`${API_URL}/api/v1/representation/${representationUuid}`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
}
}
}
} catch (error) {
console.error("Error fetching representation info:", error);
}
return <Content children={children} representationInfo={representationInfo} />;
}
export default LayoutPanel;
-43
View File
@@ -1,43 +0,0 @@
import TurnsPage from "@/components/panel/turns";
import { cookies } from "next/headers";
import { fetchReq } from "@/lib/req";
import { safeJsonParse } from "@/lib/sanitize";
import { adaptRepresentationDashboard } from "@/lib/representationAdapters";
import { getServerAccessToken } from "@/lib/serverToken";
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");
if (userInfo) {
const parsedUserInfo = safeJsonParse(userInfo.value);
const representationUuid = parsedUserInfo?.representation_uuid;
if (representationUuid) {
const accessToken = await getServerAccessToken();
if (accessToken) {
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}` } }
);
}
}
}
} catch (error) {
console.error("Error fetching representation turns:", error);
}
return <TurnsPage data={adaptRepresentationDashboard(dashboard)} />;
}
export default page;
-41
View File
@@ -1,41 +0,0 @@
import UserAccountPage from "@/components/panel/userAccount";
import { cookies } from "next/headers";
import { fetchReq } from "@/lib/req";
import { safeJsonParse } from "@/lib/sanitize";
import { adaptBankAccount } from "@/lib/representationAdapters";
import { getServerAccessToken } from "@/lib/serverToken";
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");
if (userInfo) {
const parsedUserInfo = safeJsonParse(userInfo.value);
const representationUuid = parsedUserInfo?.representation_uuid;
if (representationUuid) {
const accessToken = await getServerAccessToken();
if (accessToken) {
representation = await fetchReq(
`${API_URL}/api/v1/representation/${representationUuid}`,
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
}
}
}
} catch (error) {
console.error("Error fetching representation account:", error);
}
const bank = adaptBankAccount(representation?.data?.bank_account);
return <UserAccountPage data={{ bank }} />;
}
export default UserAccount;
+1 -1
View File
@@ -37,7 +37,7 @@ export default function robots() {
rules: {
userAgent: '*',
allow: '/',
disallow: ['/dashboard', '/panel'],
disallow: ['/dashboard'],
},
sitemap: `${baseUrl}/sitemap.xml`,
};