From 8541dd59e5d1700eb07ad4941229e40fed9f7936 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sun, 1 Jun 2025 11:10:33 +0330 Subject: [PATCH] show footer + add sidebar --- src/config/Pages.ts | 1 + src/langs/fa.json | 4 +- src/pages/company/List.tsx | 72 +++++++++++++++++ src/router/Main.tsx | 2 + src/shared/Footer.tsx | 135 ++++++++++++++++---------------- src/shared/Header.tsx | 2 +- src/shared/SideBar.tsx | 16 +++- src/shared/store/sharedStore.ts | 2 + src/shared/types/SharedTypes.ts | 2 + 9 files changed, 166 insertions(+), 70 deletions(-) create mode 100644 src/pages/company/List.tsx diff --git a/src/config/Pages.ts b/src/config/Pages.ts index cb1cd00..f73725f 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -26,6 +26,7 @@ export const Pages = { company: { detail: "company/", my: "company/my", + list: "company-list", }, grade: { records: "grade-records", diff --git a/src/langs/fa.json b/src/langs/fa.json index eccf40b..d4d1074 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -92,7 +92,9 @@ "criticisms": "انتقادات", "learning": "آموزش", "setting": "تنظیمات", - "logout": "خروج" + "logout": "خروج", + "my_company": "شرکت من", + "companies": "لیست شرکت ها" }, "header": { "search": "جستجو" diff --git a/src/pages/company/List.tsx b/src/pages/company/List.tsx new file mode 100644 index 0000000..ffff2fd --- /dev/null +++ b/src/pages/company/List.tsx @@ -0,0 +1,72 @@ +import { FC, useState } from 'react' +import { Link } from 'react-router-dom' +import { useGetCompanies, useGetIndustry } from '../home/hooks/useHomeData' +import { buildPath, clx } from '../../helpers/utils' +import { Building } from 'iconsax-react' +import { CompanyItemType, IndustryItemType } from '../home/types/HomeTypes' +import { Pages } from '../../config/Pages' + +const CompanyList: FC = () => { + + const [activeIndustry, setActiveIndustry] = useState('') + const { data: industry } = useGetIndustry() + const { data: companies } = useGetCompanies(activeIndustry) + + return ( +
+
+
setActiveIndustry('')}> + +
+ همه +
+
+ { + industry?.data?.industries?.map((item: IndustryItemType) => { + return ( +
setActiveIndustry(item.id)}> + {item.title} +
+ {item.title} +
+
+ ) + }) + } +
+ +
+ { + companies?.data?.companies?.map((item: CompanyItemType) => { + return ( + +
+ {item.name} +
+
+
+ {item.name} +
+
+ {item.address} +
+
+ + ) + }) + } +
+
+ ) +} + +export default CompanyList \ No newline at end of file diff --git a/src/router/Main.tsx b/src/router/Main.tsx index 6c2ce8d..b815645 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -27,6 +27,7 @@ import AnnouncementtList from "../pages/annoncement/List" import AnnouncementDetail from "../pages/annoncement/Detail" import MyCompany from "../pages/company/MyCompany" import Setting from "../pages/setting/Setting" +import CompanyList from "../pages/company/List" const MainRouter = () => { const { slug } = useParams() const getSlugId = useGetSlugId() @@ -66,6 +67,7 @@ const MainRouter = () => { } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/shared/Footer.tsx b/src/shared/Footer.tsx index 486e561..6267679 100644 --- a/src/shared/Footer.tsx +++ b/src/shared/Footer.tsx @@ -1,11 +1,13 @@ -import { Buildings, Home2, Messages3, NotificationStatus, Receipt21 } from 'iconsax-react' +import { Buildings, Buildings2, Home2, Messages3, NotificationStatus } from 'iconsax-react' import { FC } from 'react' import { useTranslation } from 'react-i18next' import { Pages } from '../config/Pages' import { Link, useParams, useLocation } from 'react-router-dom' +import { useSharedStore } from './store/sharedStore' const Footer: FC = () => { + const { isLogin } = useSharedStore() const { t } = useTranslation('global') const { slug } = useParams() const location = useLocation() @@ -14,79 +16,78 @@ const Footer: FC = () => { return location.pathname.includes(path) } - return null - - return ( -
-
-
- -
- -
- {t('footer.home')} -
-
- - -
- -
- {t('footer.invoice')} -
-
- - -
-
-
- + if (isLogin) + return ( +
+
+
+ +
+ +
+ {t('footer.home')}
-
- {t('footer.my_company')} + + +
+ +
+ {t('footer.companies')} +
-
- - -
- -
- {t('footer.announcements')} + + +
+
+
+ +
+
+
+ {t('footer.my_company')} +
-
- + + +
+ +
+ {t('footer.announcements')} +
+
+ - -
- -
- {t('footer.tickets')} + +
+ +
+ {t('footer.tickets')} +
-
- + +
-
- ) + ) } export default Footer \ No newline at end of file diff --git a/src/shared/Header.tsx b/src/shared/Header.tsx index 0d17fe9..4f5bd6c 100644 --- a/src/shared/Header.tsx +++ b/src/shared/Header.tsx @@ -16,7 +16,7 @@ import { getToken } from '../config/func' const Header: FC = () => { - const [isLogin, setIsLogin] = useState(false) + const { isLogin, setIsLogin } = useSharedStore() const checkLogin = async () => { const token = await getToken() setIsLogin(!!token) diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index a61a1c3..77dd2d3 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -1,7 +1,7 @@ import { FC } from 'react' import LogoImage from '../assets/images/logo.svg' import { useTranslation } from 'react-i18next' -import { DocumentText, Home2, Logout, Messages3, NotificationStatus, Receipt21, Setting2 } from 'iconsax-react' +import { Buildings2, DocumentText, Home2, Logout, Messages3, NotificationStatus, Receipt21, Setting2 } from 'iconsax-react' import SideBarItem from './SideBarItem' import { useLocation } from 'react-router-dom' import { Pages } from '../config/Pages' @@ -46,6 +46,20 @@ const SideBar: FC = () => { link={Pages.dashboard} /> + } + title={t('sidebar.companies')} + isActive={isActive('company-list')} + link={Pages.company.list} + /> + + } + title={t('sidebar.my_company')} + isActive={isActive('company/my')} + link={Pages.company.my} + /> + ((set) => ({ setOpenSidebar: (value) => set({ openSidebar: value }), slug: "", setSlug: (value) => set({ slug: value }), + isLogin: false, + setIsLogin: (value) => set({ isLogin: value }), })); diff --git a/src/shared/types/SharedTypes.ts b/src/shared/types/SharedTypes.ts index 0fe5c42..176a3de 100644 --- a/src/shared/types/SharedTypes.ts +++ b/src/shared/types/SharedTypes.ts @@ -3,4 +3,6 @@ export type SharedStoreType = { setOpenSidebar: (value: boolean) => void; slug: string; setSlug: (value: string) => void; + isLogin: boolean; + setIsLogin: (value: boolean) => void; };