import {
  ORDER_STATUSES as SHARED_ORDER_STATUSES,
  getNextAdminStatuses as sharedGetNextAdminStatuses,
} from '@shared/constants/order-status'

export const ORDER_STATUSES = SHARED_ORDER_STATUSES as typeof SHARED_ORDER_STATUSES

export type OrderStatus = (typeof ORDER_STATUSES)[number]

export function getAdminNextOrderStatuses(status: string, deliveryType: 'delivery' | 'pickup'): OrderStatus[] {
  return sharedGetNextAdminStatuses(status, deliveryType) as OrderStatus[]
}

export function canTransitionOrderStatus(from: string, to: string): boolean {
  if (from === to) return true
  return getAdminNextOrderStatuses(from, 'delivery').includes(to as OrderStatus)
}
