Skip to content

Commit 6f9d52e

Browse files
committed
fix: batal 30 menit issue
1 parent 75a9f0b commit 6f9d52e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main-event/supermarket/supermarket.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,15 +580,17 @@ export class SupermarketService {
580580
},
581581
},
582582
orderBy: {
583-
updatedAt: 'desc',
583+
createdAt: 'desc',
584584
},
585585
});
586586

587587
// If new Date() - cart.updatedAt > 30 minutes, then change the status into 'CANCELED'
588588
for (const cart of await cartData) {
589589
const now = new Date();
590590
const thirtyMinutes = 30 * 60 * 1000;
591-
if (now.getTime() - cart.updatedAt.getTime() > thirtyMinutes) {
591+
const isPassed = now.getTime() - cart.updatedAt.getTime() > thirtyMinutes;
592+
593+
if (isPassed) {
592594
if (cart.status === 'CHECKED_OUT') {
593595
await this.prisma.supermarketUserCart.update({
594596
where: { id: cart.id },

0 commit comments

Comments
 (0)