Skip to content

Commit e62b44c

Browse files
fix: timeslot local time
2 parents e3203e1 + b688aae commit e62b44c

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/app/admin/prepare/pizza/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ const PizzaMakerStation = () => {
150150
<div
151151
key={`${order._id.toString()}-${item.item._id.toString()}-${item.status}-${index}`}
152152
className={`border px-3 py-1 rounded-lg text-sm flex items-center justify-between ${item.status !== ITEM_STATUSES.PREPPING ? 'bg-green-50 border-green-100 text-gray-400' : ''}`}>
153-
{item.item.name} <span
154-
className="bg-gray-100 py-0.5 px-1 rounded-2xl">{timeslotToLocalTime(order.timeslot)}</span>
153+
{item.item.name}
154+
<span className="bg-gray-100 py-0.5 px-1 rounded-2xl">
155+
{timeslotToLocalTime(order.timeslot)}
156+
</span>
155157
</div>)
156158
)}
157159
</>

src/app/components/order/OrderSummary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const OrderSummary: React.FC<OrderSummaryPageProps> = ({
115115
<div className="flex justify-between text-sm text-gray-700 mt-2">
116116
<span>{t('cart.timeslot.title')}</span>
117117
<span>
118-
{timeslotToLocalTime(order.timeslot)}
118+
{order.timeslot?timeslotToLocalTime(order.timeslot):""}
119119
</span>
120120
</div>
121121
</div>

src/lib/time.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ export const timeslotToDate = (timeslot: string): Date => {
7070
}
7171

7272

73-
export const timeslotToLocalTime = (timeslot: string | null) => {
74-
if (!timeslot) {
75-
return null;
76-
}
73+
export const timeslotToLocalTime = (timeslot: string):string => {
7774
// Use a fixed date to avoid date boundary issues
7875
const utcDate = new Date(`1970-01-01T${timeslot}:00Z`);
7976
const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;

0 commit comments

Comments
 (0)