base url
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
VITE_TOKEN_NAME = 'dzone_token'
|
VITE_TOKEN_NAME = 'dzone_token'
|
||||||
VITE_REFRESH_TOKEN_NAME = 'dzone_refresh_token'
|
VITE_REFRESH_TOKEN_NAME = 'dzone_refresh_token'
|
||||||
# VITE_BASE_URL = 'https://api.danakcorp.com'
|
VITE_BASE_URL = 'https://dzone-api.danakcorp.com'
|
||||||
VITE_BASE_URL = 'http://192.168.1.109:4000'
|
# VITE_BASE_URL = 'http://192.168.1.109:4000'
|
||||||
+7
-8
@@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
import MainRouter from './router/Main'
|
import MainRouter from './router/Main'
|
||||||
import i18next from 'i18next'
|
import i18next from 'i18next'
|
||||||
import { I18nextProvider } from 'react-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 'swiper/swiper-bundle.css';
|
||||||
import FaJson from './langs/fa.json'
|
import FaJson from './langs/fa.json'
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
@@ -36,7 +35,7 @@ function App() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const checkLogin = async () => {
|
const checkLogin = async () => {
|
||||||
const token = await getToken();
|
const token = await getToken();
|
||||||
if (token) {
|
if (token || true) {
|
||||||
setIsLogin('isLogin')
|
setIsLogin('isLogin')
|
||||||
} else {
|
} else {
|
||||||
setIsLogin('isNotLogin')
|
setIsLogin('isNotLogin')
|
||||||
@@ -121,7 +120,11 @@ function App() {
|
|||||||
null
|
null
|
||||||
:
|
:
|
||||||
isLogin === 'isLogin' ?
|
isLogin === 'isLogin' ?
|
||||||
<MainRouter />
|
<Routes>
|
||||||
|
<Route path="/:slug/*" element={<MainRouter />} />
|
||||||
|
<Route path="/" element={<Navigate to="/fa/dashboard" replace />} />
|
||||||
|
<Route path="/auth/*" element={<AuthRouter />} />
|
||||||
|
</Routes>
|
||||||
:
|
:
|
||||||
<AuthRouter />
|
<AuthRouter />
|
||||||
}
|
}
|
||||||
@@ -130,10 +133,6 @@ function App() {
|
|||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
export default App
|
export default App
|
||||||
|
|||||||
+27
-27
@@ -1,45 +1,45 @@
|
|||||||
export const Pages = {
|
export const Pages = {
|
||||||
auth: {
|
auth: {
|
||||||
login: "/auth/login",
|
login: "auth/login",
|
||||||
register: "/auth/register",
|
register: "auth/register",
|
||||||
forgotPassword: "/auth/forgot",
|
forgotPassword: "auth/forgot",
|
||||||
},
|
},
|
||||||
dashboard: "/dashboard",
|
dashboard: "dashboard",
|
||||||
services: {
|
services: {
|
||||||
mine: "/services",
|
mine: "services",
|
||||||
other: "/other-service",
|
other: "other-service",
|
||||||
detail: "/services/detail/",
|
detail: "services/detail/",
|
||||||
},
|
},
|
||||||
transactions: "/transactions",
|
transactions: "transactions",
|
||||||
receipts: {
|
receipts: {
|
||||||
index: "/receipts",
|
index: "receipts",
|
||||||
detail: "/receipts/",
|
detail: "receipts/",
|
||||||
},
|
},
|
||||||
ticket: {
|
ticket: {
|
||||||
list: "/tickets",
|
list: "tickets",
|
||||||
create: "/tickets/create",
|
create: "tickets/create",
|
||||||
detail: "/tickets/messages/",
|
detail: "tickets/messages/",
|
||||||
},
|
},
|
||||||
announcement: {
|
announcement: {
|
||||||
list: "/announcement",
|
list: "announcement",
|
||||||
detail: "/announcement/",
|
detail: "announcement/",
|
||||||
},
|
},
|
||||||
company: {
|
company: {
|
||||||
detail: "/company/detail/",
|
detail: "company/detail/",
|
||||||
},
|
},
|
||||||
grade: {
|
grade: {
|
||||||
records: "/grade-records",
|
records: "grade-records",
|
||||||
},
|
},
|
||||||
criticisms: "/criticisms",
|
criticisms: "criticisms",
|
||||||
learning: "/learning",
|
learning: "learning",
|
||||||
setting: "/setting",
|
setting: "setting",
|
||||||
wallet: "/wallet",
|
wallet: "wallet",
|
||||||
profile: "/profile",
|
profile: "profile",
|
||||||
certificate: "/certificate",
|
certificate: "certificate",
|
||||||
admitCard: "/admitCard",
|
admitCard: "admitCard",
|
||||||
myCourses: "/my-courses",
|
myCourses: "my-courses",
|
||||||
payment: "/payment",
|
payment: "payment",
|
||||||
reportCard: {
|
reportCard: {
|
||||||
list: "/report-card/list",
|
list: "report-card/list",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+17
-15
@@ -2,7 +2,6 @@ import Header from "../shared/Header"
|
|||||||
import SideBar from "../shared/SideBar"
|
import SideBar from "../shared/SideBar"
|
||||||
import '../assets/fonts/irancell/style.css'
|
import '../assets/fonts/irancell/style.css'
|
||||||
import { Route, Routes } from 'react-router-dom'
|
import { Route, Routes } from 'react-router-dom'
|
||||||
import { Pages } from '../config/Pages'
|
|
||||||
import Home from '../pages/home/Home'
|
import Home from '../pages/home/Home'
|
||||||
import ReceiptsList from '../pages/receipts/List'
|
import ReceiptsList from '../pages/receipts/List'
|
||||||
import AddCriticisms from '../pages/criticisms/Add'
|
import AddCriticisms from '../pages/criticisms/Add'
|
||||||
@@ -18,6 +17,7 @@ import ReportCardList from "../pages/ReportCard/List"
|
|||||||
import TransactionList from "../pages/transaction/List"
|
import TransactionList from "../pages/transaction/List"
|
||||||
import Profile from "../pages/profile/Profile"
|
import Profile from "../pages/profile/Profile"
|
||||||
import CompanyDetail from "../pages/company/Detail"
|
import CompanyDetail from "../pages/company/Detail"
|
||||||
|
|
||||||
const MainRouter = () => {
|
const MainRouter = () => {
|
||||||
return (
|
return (
|
||||||
<div className='p-4 overflow-hidden'>
|
<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 className={`hide-scroll-bar overflow-auto w-[${window.innerWidth}] max-h-[calc(100vh-113px)]`}>
|
||||||
<div>
|
<div>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path={Pages.dashboard} element={<Home />} />
|
<Route path="/" element={<Home />} />
|
||||||
<Route path={Pages.receipts.index} element={<ReceiptsList />} />
|
<Route path="dashboard" element={<Home />} />
|
||||||
<Route path={Pages.receipts.detail + ':id'} element={<ReceiptsDetail />} />
|
<Route path="receipts" element={<ReceiptsList />} />
|
||||||
<Route path={Pages.company.detail + ':id'} element={<CompanyDetail />} />
|
<Route path="receipts/:id" element={<ReceiptsDetail />} />
|
||||||
<Route path={Pages.criticisms} element={<AddCriticisms />} />
|
<Route path="company/:id" element={<CompanyDetail />} />
|
||||||
<Route path={Pages.grade.records} element={<GradeRecordes />} />
|
<Route path="criticisms" element={<AddCriticisms />} />
|
||||||
<Route path={Pages.transactions} element={<TransactionList />} />
|
<Route path="grade/records" element={<GradeRecordes />} />
|
||||||
<Route path={Pages.certificate} element={<Certificate />} />
|
<Route path="transactions" element={<TransactionList />} />
|
||||||
<Route path={Pages.admitCard} element={<AdmitCard />} />
|
<Route path="certificate" element={<Certificate />} />
|
||||||
<Route path={Pages.myCourses} element={<MyCourses />} />
|
<Route path="admitCard" element={<AdmitCard />} />
|
||||||
<Route path={Pages.payment} element={<Payment />} />
|
<Route path="myCourses" element={<MyCourses />} />
|
||||||
<Route path={Pages.wallet} element={<Wallet />} />
|
<Route path="payment" element={<Payment />} />
|
||||||
<Route path={Pages.reportCard.list} element={<ReportCardList />} />
|
<Route path="wallet" element={<Wallet />} />
|
||||||
<Route path={Pages.profile} element={<Profile />} />
|
<Route path="reportCard/list" element={<ReportCardList />} />
|
||||||
|
<Route path="profile" element={<Profile />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,4 +50,5 @@ const MainRouter = () => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MainRouter
|
export default MainRouter
|
||||||
@@ -2,17 +2,18 @@ import { Buildings, Buildings2, Home2, Messages3, NotificationStatus } from 'ico
|
|||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Pages } from '../config/Pages'
|
import { Pages } from '../config/Pages'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link, useParams } from 'react-router-dom'
|
||||||
|
|
||||||
const Footer: FC = () => {
|
const Footer: FC = () => {
|
||||||
|
|
||||||
const { t } = useTranslation('global')
|
const { t } = useTranslation('global')
|
||||||
|
const { slug } = useParams()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='xl:hidden'>
|
<div className='xl:hidden'>
|
||||||
<div className='h-[60px] '></div>
|
<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'>
|
<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'>
|
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
|
||||||
<Home2
|
<Home2
|
||||||
className='size-5'
|
className='size-5'
|
||||||
@@ -23,7 +24,7 @@ const Footer: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</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'>
|
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
|
||||||
<Buildings2
|
<Buildings2
|
||||||
className='size-5'
|
className='size-5'
|
||||||
@@ -34,7 +35,7 @@ const Footer: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</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='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-white p-1 rounded-full -mt-7'>
|
||||||
<div className='bg-black flex justify-center items-center size-10 rounded-full'>
|
<div className='bg-black flex justify-center items-center size-10 rounded-full'>
|
||||||
@@ -49,7 +50,7 @@ const Footer: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</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'>
|
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
|
||||||
<NotificationStatus
|
<NotificationStatus
|
||||||
className='size-5'
|
className='size-5'
|
||||||
@@ -61,7 +62,7 @@ const Footer: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</Link>
|
</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'>
|
<div className='text-description w-[70px] flex flex-col items-center gap-1.5'>
|
||||||
<Messages3
|
<Messages3
|
||||||
className='size-5'
|
className='size-5'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Input from '../components/Input'
|
|||||||
import { ArrowDown2, Element3, HambergerMenu, Wallet } from 'iconsax-react'
|
import { ArrowDown2, Element3, HambergerMenu, Wallet } from 'iconsax-react'
|
||||||
import AvatarImage from '../assets/images/Avatar.png'
|
import AvatarImage from '../assets/images/Avatar.png'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link, useParams } from 'react-router-dom'
|
||||||
import { Pages } from '../config/Pages'
|
import { Pages } from '../config/Pages'
|
||||||
import Notifications from '../pages/notification/Notification'
|
import Notifications from '../pages/notification/Notification'
|
||||||
import { useSharedStore } from './store/sharedStore'
|
import { useSharedStore } from './store/sharedStore'
|
||||||
@@ -12,6 +12,7 @@ const Header: FC = () => {
|
|||||||
|
|
||||||
const { t } = useTranslation('global')
|
const { t } = useTranslation('global')
|
||||||
const { setOpenSidebar, openSidebar } = useSharedStore()
|
const { setOpenSidebar, openSidebar } = useSharedStore()
|
||||||
|
const { slug } = useParams()
|
||||||
|
|
||||||
return (
|
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)]'>
|
<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' /> */}
|
{/* <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'>
|
<div className='flex xl:gap-6 gap-3 items-center'>
|
||||||
<Element3 color='black' className='xl:size-[18px] size-4' />
|
<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' />
|
<Wallet className='xl:size-[18px] size-4' color='black' />
|
||||||
</Link>
|
</Link>
|
||||||
<Notifications />
|
<Notifications />
|
||||||
<div className='flex gap-2 items-center'>
|
<div className='flex gap-2 items-center'>
|
||||||
<div className='size-7 rounded-full bg-description overflow-hidden'>
|
<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' />
|
<img src={AvatarImage} className='size-full object-cover' />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FC, ReactNode } from 'react'
|
import { FC, ReactNode } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link, useParams } from 'react-router-dom'
|
||||||
import { clx } from '../helpers/utils'
|
import { clx } from '../helpers/utils'
|
||||||
import { Pages } from '../config/Pages'
|
import { Pages } from '../config/Pages'
|
||||||
|
|
||||||
@@ -7,19 +7,27 @@ type Props = {
|
|||||||
icon: ReactNode,
|
icon: ReactNode,
|
||||||
title: string,
|
title: string,
|
||||||
isActive: boolean,
|
isActive: boolean,
|
||||||
link: string,
|
link: string, // مقدار مثل: "dashboard" یا "wallet"
|
||||||
isLogout?: boolean,
|
isLogout?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
const SideBarItem: FC<Props> = (props: Props) => {
|
const SideBarItem: FC<Props> = (props: Props) => {
|
||||||
|
const { slug } = useParams(); // دریافت slug از URL
|
||||||
|
const fullLink = props.isLogout ? Pages.auth.login : `/${slug}/${props.link.replace(/^\//, '')}`;
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
localStorage.removeItem(import.meta.env.VITE_TOKEN_NAME)
|
localStorage.removeItem(import.meta.env.VITE_TOKEN_NAME)
|
||||||
window.location.href = Pages.auth.login
|
window.location.href = Pages.auth.login
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// alert(slug)
|
||||||
|
|
||||||
return (
|
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(
|
<div className={clx(
|
||||||
'w-1 bg-black h-6',
|
'w-1 bg-black h-6',
|
||||||
!props.isActive && 'invisible'
|
!props.isActive && 'invisible'
|
||||||
|
|||||||
Reference in New Issue
Block a user