Skip to content

Commit b8202a6

Browse files
committed
Merge branch 'online-shopping' of https://github.com/map-of-pi/map-of-pi-frontend-react into online-shopping
2 parents 5f39501 + 69897a2 commit b8202a6

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

src/components/shared/Seller/ShopItem.tsx

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function OnlineShopping({ dbSeller }: { dbSeller: ISeller }) {
7171
}
7272
};
7373

74-
if (dbSeller){
74+
if (dbSeller) {
7575
getSellerItems(dbSeller.seller_id);
7676
}
7777
}, [dbSeller, reload]);
@@ -432,26 +432,33 @@ export const ShopItem: React.FC<{
432432
onClick={handleSave}
433433
/>
434434
</div>
435-
{formData?.expired_by && (
436-
<label className="text-[14px] text-[#333333]">
437-
<span className="fw-bold text-lg">
438-
{new Date(formData.expired_by) > new Date() ?
439-
t('SCREEN.SELLER_REGISTRATION.SELLER_ITEMS_FEATURE.SELLING_STATUS_OPTIONS.ACTIVE') :
440-
t('SCREEN.SELLER_REGISTRATION.SELLER_ITEMS_FEATURE.SELLING_STATUS_OPTIONS.EXPIRED')
441-
} :
442-
</span>
443-
{t('SCREEN.SELLER_REGISTRATION.SELLER_ITEMS_FEATURE.SELLING_EXPIRATION_DATE', {
444-
expired_by_date: new Intl.DateTimeFormat(locale || 'en-US', {
445-
day: '2-digit',
446-
month: 'long',
447-
year: 'numeric',
448-
hour: 'numeric',
449-
minute: 'numeric',
450-
hour12: true,
451-
}).format(new Date(formData.expired_by)),
452-
})}
453-
</label>
454-
)}
435+
<div className="mt-3">
436+
{formData?.expired_by && (() => {
437+
const expiredDate = new Date(formData.expired_by);
438+
const isActive = expiredDate > new Date();
439+
const sellingStatus = isActive
440+
? t('SCREEN.SELLER_REGISTRATION.SELLER_ITEMS_FEATURE.SELLING_STATUS_OPTIONS.ACTIVE')
441+
: t('SCREEN.SELLER_REGISTRATION.SELLER_ITEMS_FEATURE.SELLING_STATUS_OPTIONS.EXPIRED');
442+
443+
const formattedDate = new Intl.DateTimeFormat(locale || 'en-US', {
444+
day: '2-digit',
445+
month: 'long',
446+
year: 'numeric',
447+
hour: 'numeric',
448+
minute: 'numeric',
449+
hour12: true,
450+
}).format(expiredDate);
451+
452+
return (
453+
<label className="text-[14px] text-[#333333]">
454+
<span className="fw-bold text-lg">{sellingStatus}: </span>
455+
{t('SCREEN.SELLER_REGISTRATION.SELLER_ITEMS_FEATURE.SELLING_EXPIRATION_DATE', {
456+
expired_by_date: formattedDate,
457+
})}
458+
</label>
459+
);
460+
})()}
461+
</div>
455462
</div>
456463
</div>
457464
</>

src/constants/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ export interface IUserSettings {
1818
};
1919
}
2020

21-
export enum FulfillmentType {
22-
CollectionByBuyer = 'Collection by Buyer',
23-
DeliveredToBuyer = 'Delivered to Buyer'
24-
}
25-
2621
export interface ISeller {
2722
seller_id: string;
2823
name: string;
@@ -40,7 +35,7 @@ export interface ISeller {
4035
coordinates: [number, number];
4136
order_online_enabled_pref: boolean;
4237
fulfillment_method?: string;
43-
fulfillment_description?: string
38+
fulfillment_description?: string;
4439
}
4540

4641
export interface IReviewFeedback {
@@ -74,6 +69,11 @@ export enum DeviceLocationType {
7469
SearchCenter = 'searchCenter'
7570
}
7671

72+
export enum FulfillmentType {
73+
CollectionByBuyer = 'Collection by buyer',
74+
DeliveredToBuyer = 'Delivered to buyer'
75+
}
76+
7777
export enum StockLevelType {
7878
available_1 = '1 available',
7979
available_2 = '2 available',

0 commit comments

Comments
 (0)