test commit
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
import { DELIVERY_CARRIERS as SHARED_DELIVERY_CARRIERS } from '@shared/constants/delivery-carrier'
|
||||
import {
|
||||
DELIVERY_CARRIERS as SHARED_DELIVERY_CARRIERS,
|
||||
DELIVERY_CARRIER_LABELS,
|
||||
deliveryCarrierLabelRu as sharedDeliveryCarrierLabelRu,
|
||||
} from '@shared/constants/delivery-carrier'
|
||||
|
||||
export const DELIVERY_CARRIER_CODES = SHARED_DELIVERY_CARRIERS as typeof SHARED_DELIVERY_CARRIERS
|
||||
|
||||
export type DeliveryCarrierCode = (typeof DELIVERY_CARRIER_CODES)[number]
|
||||
|
||||
export const DELIVERY_CARRIER_OPTIONS: ReadonlyArray<{ code: DeliveryCarrierCode; label: string }> = [
|
||||
{ code: 'RUSSIAN_POST', label: 'Почта России' },
|
||||
{ code: 'OZON_PVZ', label: 'Озон доставка (пункт выдачи)' },
|
||||
{ code: 'YANDEX_PVZ', label: 'Яндекс доставка (пункт выдачи)' },
|
||||
{ code: 'FIVE_POST', label: '5Post (пункт выдачи)' },
|
||||
]
|
||||
|
||||
const carrierLabelMap: Record<DeliveryCarrierCode, string> = Object.fromEntries(
|
||||
DELIVERY_CARRIER_OPTIONS.map((o) => [o.code, o.label]),
|
||||
) as Record<DeliveryCarrierCode, string>
|
||||
export const DELIVERY_CARRIER_OPTIONS: ReadonlyArray<{ code: DeliveryCarrierCode; label: string }> =
|
||||
DELIVERY_CARRIER_CODES.map((code) => ({
|
||||
code,
|
||||
label: DELIVERY_CARRIER_LABELS[code],
|
||||
}))
|
||||
|
||||
export function deliveryCarrierLabelRu(code: string | null | undefined): string | null {
|
||||
if (!code) return null
|
||||
return carrierLabelMap[code as DeliveryCarrierCode] ?? code
|
||||
return sharedDeliveryCarrierLabelRu(code)
|
||||
}
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import { ORDER_STATUSES as SHARED_ORDER_STATUSES } from '@shared/constants/order-status'
|
||||
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[] {
|
||||
switch (status) {
|
||||
case 'DRAFT':
|
||||
return ['PENDING_PAYMENT', 'CANCELLED']
|
||||
case 'PENDING_PAYMENT':
|
||||
return ['PAID', 'CANCELLED']
|
||||
case 'PAID':
|
||||
return ['IN_PROGRESS', 'CANCELLED']
|
||||
case 'IN_PROGRESS':
|
||||
if (deliveryType === 'delivery') return ['SHIPPED', 'CANCELLED']
|
||||
return ['READY_FOR_PICKUP', 'CANCELLED']
|
||||
default:
|
||||
return []
|
||||
}
|
||||
return sharedGetNextAdminStatuses(status, deliveryType) as OrderStatus[]
|
||||
}
|
||||
|
||||
export function canTransitionOrderStatus(from: string, to: string): boolean {
|
||||
|
||||
Reference in New Issue
Block a user