add remain

This commit is contained in:
hamid zarghami
2026-01-06 09:23:05 +03:30
parent 37717d5f05
commit 63293f5591
3 changed files with 36 additions and 7 deletions
+2 -1
View File
@@ -891,7 +891,8 @@
"established_year": "سال تاسیس", "established_year": "سال تاسیس",
"subscription_id": "شناسه اشتراک", "subscription_id": "شناسه اشتراک",
"subscription_start_date": "تاریخ شروع اشتراک", "subscription_start_date": "تاریخ شروع اشتراک",
"subscription_end_date": "تاریخ پایان اشتراک" "subscription_end_date": "تاریخ پایان اشتراک",
"days_remaining": "چند روز مانده"
}, },
"cancel": "لغو" "cancel": "لغو"
} }
+30 -4
View File
@@ -46,6 +46,20 @@ const RestaurantsList: FC = () => {
} }
} }
const calculateDaysRemaining = (endDate: string): string => {
const end = moment(endDate)
const now = moment()
const diff = end.diff(now, 'days')
if (diff < 0) {
return 'منقضی شده'
}
return `${diff} روز`
}
const formatJalaliDate = (date: string): string => {
return moment(date).format('jYYYY-jMM-jDD')
}
return ( return (
<div className='mt-4'> <div className='mt-4'>
<div className='flex w-full justify-between items-center'> <div className='flex w-full justify-between items-center'>
@@ -65,10 +79,12 @@ const RestaurantsList: FC = () => {
<Td text={t('restaurant.name')} /> <Td text={t('restaurant.name')} />
<Td text={t('restaurant.phone')} /> <Td text={t('restaurant.phone')} />
<Td text={t('restaurant.address')} /> <Td text={t('restaurant.address')} />
<Td text={t('restaurant.domain')} /> <Td text={t('restaurant.slug')} />
<Td text={t('restaurant.plan')} /> <Td text={t('restaurant.plan')} />
<Td text={t('restaurant.status')} /> <Td text={t('restaurant.status')} />
<Td text={t('restaurant.created_at')} /> <Td text={t('restaurant.subscription_start_date')} />
<Td text={t('restaurant.subscription_end_date')} />
<Td text={t('restaurant.days_remaining')} />
<Td text={''} /> <Td text={''} />
</tr> </tr>
</thead> </thead>
@@ -92,7 +108,7 @@ const RestaurantsList: FC = () => {
)} )}
</div> </div>
</Td> </Td>
<Td text={item.domain || '-'} /> <Td text={item?.slug || '-'} />
<Td text={item.plan || '-'} /> <Td text={item.plan || '-'} />
<Td text={''}> <Td text={''}>
<div className={`w-fit px-3 py-1 rounded-2xl text-xs ${item.isActive <div className={`w-fit px-3 py-1 rounded-2xl text-xs ${item.isActive
@@ -104,7 +120,17 @@ const RestaurantsList: FC = () => {
</Td> </Td>
<Td text={''}> <Td text={''}>
<div className='dltr text-right'> <div className='dltr text-right'>
{moment(item.createdAt).format('jYYYY-jMM-jDD HH:mm')} {formatJalaliDate(item.subscriptionStartDate)}
</div>
</Td>
<Td text={''}>
<div className='dltr text-right'>
{formatJalaliDate(item.subscriptionEndDate)}
</div>
</Td>
<Td text={''}>
<div className='dltr text-right'>
{calculateDaysRemaining(item.subscriptionEndDate)}
</div> </div>
</Td> </Td>
<Td text={''}> <Td text={''}>
+4 -2
View File
@@ -84,7 +84,7 @@ export type RestaurantType = {
longitude: number | null; longitude: number | null;
serviceArea: string | null; serviceArea: string | null;
isActive: boolean; isActive: boolean;
establishedYear: number | null; establishedYear: number;
phone: string; phone: string;
instagram: string | null; instagram: string | null;
telegram: string | null; telegram: string | null;
@@ -117,8 +117,10 @@ export type RestaurantsData = {
restaurants: RestaurantType[]; restaurants: RestaurantType[];
}; };
export interface RestaurantsResponse extends IResponse<RestaurantsData> { export interface RestaurantsResponse {
statusCode: number; statusCode: number;
success: boolean;
data: RestaurantsData;
} }
export interface RestaurantResponse extends IResponse<RestaurantType> { export interface RestaurantResponse extends IResponse<RestaurantType> {