From fc6f0d94a2c43de7ba13623c9cc8249e6d426c94 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sat, 31 May 2025 17:13:27 +0330 Subject: [PATCH] slider fix bug login --- src/config/axios.ts | 2 +- src/index.css | 25 +++++++++++++++ src/pages/home/Home.tsx | 46 +++++++++++++++++++++++++-- src/pages/home/hooks/useHomeData.ts | 7 ++++ src/pages/home/service/HomeService.ts | 5 +++ src/pages/home/types/HomeTypes.ts | 11 +++++++ 6 files changed, 93 insertions(+), 3 deletions(-) diff --git a/src/config/axios.ts b/src/config/axios.ts index eb01353..dda79ce 100644 --- a/src/config/axios.ts +++ b/src/config/axios.ts @@ -41,7 +41,7 @@ axiosInstance.interceptors.response.use( if (!refreshTokenValue) { removeRefreshToken(); removeToken(); - window.location.href = buildPath("auth/login"); + window.location.href = "/"; return; } const { data } = await refreshToken({ diff --git a/src/index.css b/src/index.css index b2b7a35..26fa897 100644 --- a/src/index.css +++ b/src/index.css @@ -144,3 +144,28 @@ tbody tr { .overflowX::-webkit-scrollbar { display: none; } + +@media screen and (max-width: 768px) { + .swiper-button-prev:after, + .swiper-rtl .swiper-button-next:after { + font-size: 30px; + } + + .swiper-button-next:after, + .swiper-rtl .swiper-button-prev:after { + font-size: 30px; + } +} + +.swiper-button-next { + top: 55% !important; +} + +.swiper-button-prev { + top: 55% !important; +} + +.swiper-button-prev:after, +.swiper-rtl .swiper-button-next:after { + color: #fff !important; +} diff --git a/src/pages/home/Home.tsx b/src/pages/home/Home.tsx index 5d3f247..4e54efa 100644 --- a/src/pages/home/Home.tsx +++ b/src/pages/home/Home.tsx @@ -1,13 +1,17 @@ import { Building, CloseCircle, InfoCircle, TickCircle } from 'iconsax-react' +import { Swiper, SwiperSlide } from 'swiper/react'; +import { Navigation as SwiperNavigation } from 'swiper/modules'; import { FC, useState } from 'react' import { useTranslation } from 'react-i18next' import { buildPath, clx } from '../../helpers/utils' import TitleSeeAll from '../../components/TitleSeeAll' -import { useGetCompanies, useGetIndustry, useGetCompanyRequest } from './hooks/useHomeData' -import { CompanyItemType, IndustryItemType } from './types/HomeTypes' +import { useGetCompanies, useGetIndustry, useGetCompanyRequest, useGetSliders } from './hooks/useHomeData' +import { CompanyItemType, IndustryItemType, SliderItemType } from './types/HomeTypes' import { Link } from 'react-router-dom' import { Pages } from '../../config/Pages' import { CompanyRequestStatus } from './enum/Enum' +import { Button } from '@headlessui/react'; + const Home: FC = () => { const { t } = useTranslation('global') @@ -15,9 +19,47 @@ const Home: FC = () => { const { data: industry } = useGetIndustry() const { data: companies } = useGetCompanies(activeIndustry) const { data: companyRequest } = useGetCompanyRequest() + const { data: sliders } = useGetSliders() return (
+ + + { + sliders?.data?.sliders?.map((item: SliderItemType) => { + return ( + +
+ banner + +
+
+

{item.title}

+

{item.description}

+ + + + +
+
+
+
+ ) + }) + } +
+ { companyRequest?.data?.requests &&
{ @@ -44,6 +45,12 @@ export const useGetCompanyRequest = () => { }); }; +export const useGetSliders = () => { + return useQuery({ + queryKey: ["sliders"], + queryFn: () => getSliders(), + }); +}; export const useGetMyCompany = () => { return useQuery({ queryKey: ["my-company"], diff --git a/src/pages/home/service/HomeService.ts b/src/pages/home/service/HomeService.ts index 185e217..4cb304e 100644 --- a/src/pages/home/service/HomeService.ts +++ b/src/pages/home/service/HomeService.ts @@ -35,3 +35,8 @@ export const getCompanyRequest = async () => { const { data } = await axios.get(`/companies/requests/user`); return data; }; + +export const getSliders = async () => { + const { data } = await axios.get(`/sliders/list/public`); + return data; +}; diff --git a/src/pages/home/types/HomeTypes.ts b/src/pages/home/types/HomeTypes.ts index 175105a..221867a 100644 --- a/src/pages/home/types/HomeTypes.ts +++ b/src/pages/home/types/HomeTypes.ts @@ -31,3 +31,14 @@ export type CompanyItemType = { business: string; invoiceCount: number; }; + +export type SliderItemType = { + id: string; + createdAt: string; + updatedAt: string; + deletedAt: string | null; + title: string; + imageUrl: string; + description: string; + link: string; +};