This commit is contained in:
hamid zarghami
2025-05-18 16:39:10 +03:30
parent 60750d9648
commit c4c0c93599
8 changed files with 75 additions and 64 deletions
Vendored
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -1,4 +1,4 @@
VITE_TOKEN_NAME = 'dzone_token'
VITE_REFRESH_TOKEN_NAME = 'dzone_refresh_token'
# VITE_BASE_URL = 'https://api.danakcorp.com'
VITE_BASE_URL = 'http://192.168.1.109:4000'
VITE_BASE_URL = 'https://dzone-api.danakcorp.com'
# VITE_BASE_URL = 'http://192.168.1.109:4000'
+7 -8
View File
@@ -1,8 +1,7 @@
import MainRouter from './router/Main'
import i18next from 'i18next'
import { I18nextProvider } from 'react-i18next'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import 'swiper/swiper-bundle.css';
import FaJson from './langs/fa.json'
import { useState } from 'react';
@@ -36,7 +35,7 @@ function App() {
useEffect(() => {
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' ?
<MainRouter />
<Routes>
<Route path="/:slug/*" element={<MainRouter />} />
<Route path="/" element={<Navigate to="/fa/dashboard" replace />} />
<Route path="/auth/*" element={<AuthRouter />} />
</Routes>
:
<AuthRouter />
}
@@ -130,10 +133,6 @@ function App() {
</QueryClientProvider>
</BrowserRouter>
</>
)
}
export default App
+27 -27
View File
@@ -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",
},
};
+17 -15
View File
@@ -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 (
<div className='p-4 overflow-hidden'>
@@ -27,20 +27,21 @@ const MainRouter = () => {
<div className={`hide-scroll-bar overflow-auto w-[${window.innerWidth}] max-h-[calc(100vh-113px)]`}>
<div>
<Routes>
<Route path={Pages.dashboard} element={<Home />} />
<Route path={Pages.receipts.index} element={<ReceiptsList />} />
<Route path={Pages.receipts.detail + ':id'} element={<ReceiptsDetail />} />
<Route path={Pages.company.detail + ':id'} element={<CompanyDetail />} />
<Route path={Pages.criticisms} element={<AddCriticisms />} />
<Route path={Pages.grade.records} element={<GradeRecordes />} />
<Route path={Pages.transactions} element={<TransactionList />} />
<Route path={Pages.certificate} element={<Certificate />} />
<Route path={Pages.admitCard} element={<AdmitCard />} />
<Route path={Pages.myCourses} element={<MyCourses />} />
<Route path={Pages.payment} element={<Payment />} />
<Route path={Pages.wallet} element={<Wallet />} />
<Route path={Pages.reportCard.list} element={<ReportCardList />} />
<Route path={Pages.profile} element={<Profile />} />
<Route path="/" element={<Home />} />
<Route path="dashboard" element={<Home />} />
<Route path="receipts" element={<ReceiptsList />} />
<Route path="receipts/:id" element={<ReceiptsDetail />} />
<Route path="company/:id" element={<CompanyDetail />} />
<Route path="criticisms" element={<AddCriticisms />} />
<Route path="grade/records" element={<GradeRecordes />} />
<Route path="transactions" element={<TransactionList />} />
<Route path="certificate" element={<Certificate />} />
<Route path="admitCard" element={<AdmitCard />} />
<Route path="myCourses" element={<MyCourses />} />
<Route path="payment" element={<Payment />} />
<Route path="wallet" element={<Wallet />} />
<Route path="reportCard/list" element={<ReportCardList />} />
<Route path="profile" element={<Profile />} />
</Routes>
</div>
</div>
@@ -49,4 +50,5 @@ const MainRouter = () => {
</div>
)
}
export default MainRouter
+7 -6
View File
@@ -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 (
<div className='xl:hidden'>
<div className='h-[60px] '></div>
<div className='fixed bottom-2 z-10 right-3 left-3 bg-white h-[60px] rounded-2xl flex justify-between items-center px-3'>
<Link to={Pages.dashboard}>
<Link to={`/${slug}/${Pages.dashboard}`}>
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
<Home2
className='size-5'
@@ -23,7 +24,7 @@ const Footer: FC = () => {
</div>
</div>
</Link>
<Link to={Pages.services.other}>
<Link to={`/${slug}/${Pages.services.other}`}>
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
<Buildings2
className='size-5'
@@ -34,7 +35,7 @@ const Footer: FC = () => {
</div>
</div>
</Link>
<Link to={Pages.services.mine}>
<Link to={`/${slug}/${Pages.services.mine}`}>
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
<div className='bg-white p-1 rounded-full -mt-7'>
<div className='bg-black flex justify-center items-center size-10 rounded-full'>
@@ -49,7 +50,7 @@ const Footer: FC = () => {
</div>
</div>
</Link>
<Link to={Pages.announcement.list}>
<Link to={`/${slug}/${Pages.announcement.list}`}>
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
<NotificationStatus
className='size-5'
@@ -61,7 +62,7 @@ const Footer: FC = () => {
</div>
</Link>
<Link to={Pages.ticket.list}>
<Link to={`/${slug}/${Pages.ticket.list}`}>
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
<Messages3
className='size-5'
+4 -3
View File
@@ -3,7 +3,7 @@ import Input from '../components/Input'
import { ArrowDown2, Element3, HambergerMenu, Wallet } from 'iconsax-react'
import AvatarImage from '../assets/images/Avatar.png'
import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import { Link, useParams } from 'react-router-dom'
import { Pages } from '../config/Pages'
import Notifications from '../pages/notification/Notification'
import { useSharedStore } from './store/sharedStore'
@@ -12,6 +12,7 @@ const Header: FC = () => {
const { t } = useTranslation('global')
const { setOpenSidebar, openSidebar } = useSharedStore()
const { slug } = useParams()
return (
<div className='fixed z-10 right-4 left-4 xl:right-[285px] top-4 xl:h-16 h-12 flex items-center px-6 bg-white justify-between rounded-[32px] xl:w-[calc(100%-305px)]'>
@@ -27,13 +28,13 @@ const Header: FC = () => {
{/* <img src={LogoImage} className='h-6 xl:hidden block absolute right-0 left-0 mx-auto' /> */}
<div className='flex xl:gap-6 gap-3 items-center'>
<Element3 color='black' className='xl:size-[18px] size-4' />
<Link to={Pages.wallet}>
<Link to={`/${slug}/${Pages.wallet}`}>
<Wallet className='xl:size-[18px] size-4' color='black' />
</Link>
<Notifications />
<div className='flex gap-2 items-center'>
<div className='size-7 rounded-full bg-description overflow-hidden'>
<Link to={Pages.profile}>
<Link to={`/${slug}/${Pages.profile}`}>
<img src={AvatarImage} className='size-full object-cover' />
</Link>
</div>
+11 -3
View File
@@ -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: 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 (
<Link onClick={props.isLogout ? handleLogout : undefined} to={props.link} className='flex text-xs gap-9 mt-4'>
<Link
onClick={props.isLogout ? handleLogout : undefined}
to={fullLink}
className='flex text-xs gap-9 mt-4'
>
<div className={clx(
'w-1 bg-black h-6',
!props.isActive && 'invisible'