99 lines
4.3 KiB
TypeScript
99 lines
4.3 KiB
TypeScript
import { FC, useState } from 'react'
|
||
import { useTranslation } from 'react-i18next'
|
||
import Input from '../../components/Input'
|
||
import { useGetMyServices } from './hooks/useServiceData'
|
||
import { MyServicesItem } from './types/ServiecTypes'
|
||
import { useGetAds } from '../ads/hooks/useAdsData'
|
||
import { AdsDisplayLocation } from '../ads/types/AdsTypes'
|
||
import { Helmet } from 'react-helmet-async'
|
||
import ServiceItemSkeleton from './components/ServiceItemSkeleton'
|
||
import ServiceItem from '../../components/ServiceItem'
|
||
import EmptyMyService from './components/EmptyMyService'
|
||
|
||
const MyServices: FC = () => {
|
||
|
||
const { t } = useTranslation('global')
|
||
const [search, setSearch] = useState<string>('')
|
||
const getServices = useGetMyServices(search)
|
||
const getAdsLeft = useGetAds(AdsDisplayLocation.MY_SERVICES_PAGE)
|
||
|
||
return (
|
||
<div className='w-full flex gap-6 mt-4'>
|
||
<Helmet>
|
||
<title>
|
||
داناک | سرویس های من
|
||
</title>
|
||
</Helmet>
|
||
<div className='flex-1'>
|
||
<div>
|
||
{t('service.my_service')}
|
||
</div>
|
||
|
||
<div className='mt-8 flex xl:gap-6 gap-4 items-center'>
|
||
<div className='xl:w-[300px] w-full'>
|
||
<Input
|
||
variant='search'
|
||
placeholder={t('service.search')}
|
||
className='bg-white w-full'
|
||
onChangeSearchFinal={(value) => setSearch(value)}
|
||
/>
|
||
</div>
|
||
|
||
{/* <div>
|
||
<Select
|
||
items={[
|
||
{ label: t('all'), value: 'all' },
|
||
{ label: 'Active', value: 'active' },
|
||
{ label: 'Inactive', value: 'inactive' },
|
||
]}
|
||
className='max-w-[100px]'
|
||
/>
|
||
</div> */}
|
||
</div>
|
||
|
||
<div className='flex items-stretch flex-wrap xl:gap-6 gap-4 xl:items-center mt-8'>
|
||
{
|
||
getServices.isPending ?
|
||
Array.from({ length: 4 }).map((_, index) => <ServiceItemSkeleton key={index} />)
|
||
:
|
||
getServices.data?.data?.subscriptions?.length > 0 ?
|
||
getServices.data?.data?.subscriptions?.map((item: MyServicesItem) => {
|
||
return (
|
||
<ServiceItem
|
||
key={item.id}
|
||
item={item.plan.service}
|
||
isLinkPanel
|
||
businessName={item.businessName}
|
||
isDisabled={item.status === 'INACTIVE'}
|
||
/>
|
||
)
|
||
})
|
||
:
|
||
<EmptyMyService />
|
||
}
|
||
<div className='flex-1 min-w-[40%] xl:min-w-[20%] px-6'></div>
|
||
<div className='flex-1 min-w-[40%] xl:min-w-[20%] px-6'></div>
|
||
<div className='flex-1 min-w-[40%] xl:min-w-[20%] px-6'></div>
|
||
</div>
|
||
</div>
|
||
|
||
{
|
||
getAdsLeft.isSuccess && getAdsLeft.data.data.ads[0] &&
|
||
<a href={getAdsLeft.data?.data?.ads[0].link} target='_blank' className='bg-white w-sidebar h-fit hidden xl:block rounded-3xl overflow-hidden sticky top-0'>
|
||
<img
|
||
src={getAdsLeft.data.data.ads[0].imageUrl}
|
||
className='w-full backdrop-blur-[100px] h-[550px] object-cover'
|
||
/>
|
||
|
||
<div className='absolute flex items-center px-4 w-full bottom-0 h-[86px] bg-black bg-opacity-5 backdrop-blur-[14px]'>
|
||
<div className='max-w-[80%] text-sm leading-6 text-white'>
|
||
{getAdsLeft.data.data.ads[0].title}
|
||
</div>
|
||
</div>
|
||
</a>
|
||
}
|
||
</div>
|
||
)
|
||
}
|
||
|
||
export default MyServices |