base commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export const ORDER_STATUSES = [
|
||||
'DRAFT',
|
||||
'PENDING_PAYMENT',
|
||||
'PAID',
|
||||
'IN_PROGRESS',
|
||||
'SHIPPED',
|
||||
'DONE',
|
||||
'CANCELLED',
|
||||
]
|
||||
|
||||
export const ORDER_STATUS_TRANSITIONS = {
|
||||
DRAFT: new Set(['PENDING_PAYMENT', 'CANCELLED']),
|
||||
PENDING_PAYMENT: new Set(['PAID', 'CANCELLED']),
|
||||
PAID: new Set(['IN_PROGRESS', 'CANCELLED']),
|
||||
IN_PROGRESS: new Set(['SHIPPED', 'CANCELLED']),
|
||||
SHIPPED: new Set(['DONE']),
|
||||
DONE: new Set([]),
|
||||
CANCELLED: new Set([]),
|
||||
}
|
||||
|
||||
export function canTransitionOrderStatus(from, to) {
|
||||
if (from === to) return true
|
||||
const allowed = ORDER_STATUS_TRANSITIONS[from]
|
||||
return Boolean(allowed?.has(to))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user