From c4c0c93599921b6af8526588caa27a188040e0f4 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sun, 18 May 2025 16:39:10 +0330 Subject: [PATCH] base url --- .DS_Store | Bin 6148 -> 6148 bytes .env | 4 +-- src/App.tsx | 15 +++++------ src/config/Pages.ts | 54 ++++++++++++++++++------------------- src/router/Main.tsx | 32 +++++++++++----------- src/shared/Footer.tsx | 13 ++++----- src/shared/Header.tsx | 7 ++--- src/shared/SideBarItem.tsx | 14 +++++++--- 8 files changed, 75 insertions(+), 64 deletions(-) diff --git a/.DS_Store b/.DS_Store index 4c772616bdf090f99f1c2dc3fb99e20ead82b5cf..fa219f063771ce4f40cc382724a2165612cd5d28 100644 GIT binary patch delta 114 zcmZoMXfc@JFDk;oz`)4BAi$7RUR;orlb;0S@7S2QoS7FS!@{7)kj{|FP%`-(YooA{ zsg8n)fl;lFLbaul0g!EMHaUsScrrgrg(zHQS#VKaPJUiG$lS>rSY$RYV5w)?%+B$b F9{~6T94!C< delta 48 zcmZoMXfc@JFDS&oz`)4BAi$85ZWx@LpIfk5kYhD7qtN6#EY+LyS!Xa!ta!1Ro#QV* E04^vFeE { const checkLogin = async () => { const token = await getToken(); - if (token) { + if (token || true) { setIsLogin('isLogin') } else { setIsLogin('isNotLogin') @@ -121,7 +120,11 @@ function App() { null : isLogin === 'isLogin' ? - + + } /> + } /> + } /> + : } @@ -130,10 +133,6 @@ function App() { - - - - ) } export default App diff --git a/src/config/Pages.ts b/src/config/Pages.ts index 367bba8..a9150ed 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -1,45 +1,45 @@ export const Pages = { auth: { - login: "/auth/login", - register: "/auth/register", - forgotPassword: "/auth/forgot", + login: "auth/login", + register: "auth/register", + forgotPassword: "auth/forgot", }, - dashboard: "/dashboard", + dashboard: "dashboard", services: { - mine: "/services", - other: "/other-service", - detail: "/services/detail/", + mine: "services", + other: "other-service", + detail: "services/detail/", }, - transactions: "/transactions", + transactions: "transactions", receipts: { - index: "/receipts", - detail: "/receipts/", + index: "receipts", + detail: "receipts/", }, ticket: { - list: "/tickets", - create: "/tickets/create", - detail: "/tickets/messages/", + list: "tickets", + create: "tickets/create", + detail: "tickets/messages/", }, announcement: { - list: "/announcement", - detail: "/announcement/", + list: "announcement", + detail: "announcement/", }, company: { - detail: "/company/detail/", + detail: "company/detail/", }, grade: { - records: "/grade-records", + records: "grade-records", }, - criticisms: "/criticisms", - learning: "/learning", - setting: "/setting", - wallet: "/wallet", - profile: "/profile", - certificate: "/certificate", - admitCard: "/admitCard", - myCourses: "/my-courses", - payment: "/payment", + criticisms: "criticisms", + learning: "learning", + setting: "setting", + wallet: "wallet", + profile: "profile", + certificate: "certificate", + admitCard: "admitCard", + myCourses: "my-courses", + payment: "payment", reportCard: { - list: "/report-card/list", + list: "report-card/list", }, }; diff --git a/src/router/Main.tsx b/src/router/Main.tsx index 7f2b72b..d7d6378 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -2,7 +2,6 @@ import Header from "../shared/Header" import SideBar from "../shared/SideBar" import '../assets/fonts/irancell/style.css' import { Route, Routes } from 'react-router-dom' -import { Pages } from '../config/Pages' import Home from '../pages/home/Home' import ReceiptsList from '../pages/receipts/List' import AddCriticisms from '../pages/criticisms/Add' @@ -18,6 +17,7 @@ import ReportCardList from "../pages/ReportCard/List" import TransactionList from "../pages/transaction/List" import Profile from "../pages/profile/Profile" import CompanyDetail from "../pages/company/Detail" + const MainRouter = () => { return (
@@ -27,20 +27,21 @@ const MainRouter = () => {
- } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } />
@@ -49,4 +50,5 @@ const MainRouter = () => {
) } + export default MainRouter \ No newline at end of file diff --git a/src/shared/Footer.tsx b/src/shared/Footer.tsx index 16dd1cb..68a710c 100644 --- a/src/shared/Footer.tsx +++ b/src/shared/Footer.tsx @@ -2,17 +2,18 @@ import { Buildings, Buildings2, Home2, Messages3, NotificationStatus } from 'ico import { FC } from 'react' import { useTranslation } from 'react-i18next' import { Pages } from '../config/Pages' -import { Link } from 'react-router-dom' +import { Link, useParams } from 'react-router-dom' const Footer: FC = () => { const { t } = useTranslation('global') + const { slug } = useParams() return (
- +
{
- +
{
- +
@@ -49,7 +50,7 @@ const Footer: FC = () => {
- +
{
- +
{ const { t } = useTranslation('global') const { setOpenSidebar, openSidebar } = useSharedStore() + const { slug } = useParams() return (
@@ -27,13 +28,13 @@ const Header: FC = () => { {/* */}
- +
- +
diff --git a/src/shared/SideBarItem.tsx b/src/shared/SideBarItem.tsx index f4295f1..55363a6 100644 --- a/src/shared/SideBarItem.tsx +++ b/src/shared/SideBarItem.tsx @@ -1,5 +1,5 @@ import { FC, ReactNode } from 'react' -import { Link } from 'react-router-dom' +import { Link, useParams } from 'react-router-dom' import { clx } from '../helpers/utils' import { Pages } from '../config/Pages' @@ -7,19 +7,27 @@ type Props = { icon: ReactNode, title: string, isActive: boolean, - link: string, + link: string, // مقدار مثل: "dashboard" یا "wallet" isLogout?: boolean, } const SideBarItem: FC = (props: Props) => { + const { slug } = useParams(); // دریافت slug از URL + const fullLink = props.isLogout ? Pages.auth.login : `/${slug}/${props.link.replace(/^\//, '')}`; const handleLogout = () => { localStorage.removeItem(import.meta.env.VITE_TOKEN_NAME) window.location.href = Pages.auth.login } + // alert(slug) + return ( - +