优化
This commit is contained in:
@@ -1,7 +1,37 @@
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
|
||||
export type TerminalDrayageStatus = 'WAITING_FOR_ARRIVAL' | 'ARRIVED' | 'PICKUP_SCHEDULED' | 'PICKED_UP' | 'UNLOADED' | 'EMPTY_RETURNED'
|
||||
export type TerminalDrayageAction = 'SELECT_FLEET' | 'SCHEDULE_PICKUP' | 'RECORD_PICKUP' | 'RECORD_EMPTY_RETURN'
|
||||
export type TerminalDrayageAction = 'SELECT_FLEET' | 'SCHEDULE_PICKUP' | 'RECORD_PICKUP' | 'RECORD_EMPTY_RETURN' | 'SEND_PICKUP_EMAIL'
|
||||
|
||||
export interface TerminalDrayageEmail {
|
||||
id: string
|
||||
fleetName: string
|
||||
recipient: string
|
||||
kind: 'REQUEST_PICKUP' | 'CANCEL_PICKUP'
|
||||
subject: string
|
||||
body: string
|
||||
status: 'PENDING' | 'SENDING' | 'SENT' | 'FAILED'
|
||||
attempts: number
|
||||
failureReason: string | null
|
||||
createdAt: string
|
||||
sentAt: string | null
|
||||
}
|
||||
|
||||
export async function getTerminalDrayageEmails(containerId: string) {
|
||||
type Mailbox = { deliveryEnabled: boolean; records: TerminalDrayageEmail[] }
|
||||
const response = await http.get<ApiEnvelope<Mailbox>, ApiEnvelope<Mailbox>>(`${path}/${encodeURIComponent(containerId)}/emails`)
|
||||
const result = unwrapApiResponse(response)
|
||||
return { ...result, records: result.records.map((mail) => ({ ...mail, id: String(mail.id) })) }
|
||||
}
|
||||
|
||||
export function sendTerminalDrayageEmail(containerId: string, expectedVersion: number) {
|
||||
return command(containerId, 'pickup-email', { expectedVersion })
|
||||
}
|
||||
|
||||
export async function retryTerminalDrayageEmail(containerId: string, mailId: string) {
|
||||
const response = await http.post<ApiEnvelope<null>, ApiEnvelope<null>>(`${path}/${encodeURIComponent(containerId)}/emails/${encodeURIComponent(mailId)}/retry`)
|
||||
unwrapApiResponse(response)
|
||||
}
|
||||
export type EmptyReturnWarningStatus = 'NOT_APPLICABLE' | 'PENDING' | 'OVERDUE' | 'RESOLVED'
|
||||
|
||||
export interface EmptyReturnWarning {
|
||||
|
||||
Reference in New Issue
Block a user