mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 07:45:45 +00:00
implement booking flow
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { QUERY_KEYS } from "@/constants/QUERY_KEYS";
|
||||
import { endpoint } from "@/utils/endpoint";
|
||||
import type {
|
||||
CreateFileUploadFieldDto,
|
||||
@@ -16,7 +17,6 @@ import {
|
||||
UpdateDropdownSettingDto,
|
||||
} from "@/types/dropdownSettings";
|
||||
import {
|
||||
ApproveRatePayload,
|
||||
RuleEngineListResult,
|
||||
RuleEngineRecord,
|
||||
RuleEngineResourceSlug,
|
||||
@@ -27,8 +27,14 @@ import {
|
||||
ruleEngineService,
|
||||
RuleEngineListParams,
|
||||
} from "./ruleEngine/ruleEngine.service";
|
||||
import { bookingsService, BookingListFilter } from "./bookings.service";
|
||||
import type { Freight, PaginatedResponse } from "@edr/types";
|
||||
import {
|
||||
bookingsService,
|
||||
BookingListFilter,
|
||||
type ApproveStepPayload,
|
||||
type PaginatedBookings,
|
||||
type RejectStepPayload,
|
||||
} from "./bookings.service";
|
||||
import type { BookingDetail } from "@/types/booking";
|
||||
|
||||
export const api = {
|
||||
fileUploadSettings: {
|
||||
@@ -167,15 +173,21 @@ export const api = {
|
||||
list: endpoint<
|
||||
{ resource: RuleEngineResourceSlug; params?: RuleEngineListParams },
|
||||
RuleEngineListResult<RuleEngineRecord>
|
||||
>("rule-engine", "list", ({ resource, params }) =>
|
||||
ruleEngineService.list(resource, params),
|
||||
>(
|
||||
"rule-engine",
|
||||
"list",
|
||||
({ resource, params }) => ruleEngineService.list(resource, params),
|
||||
({ resource, params }) => QUERY_KEYS.RULE_ENGINE.list(resource, params),
|
||||
),
|
||||
|
||||
getById: endpoint<
|
||||
{ resource: RuleEngineResourceSlug; id: string },
|
||||
RuleEngineRecord
|
||||
>("rule-engine", "getById", ({ resource, id }) =>
|
||||
ruleEngineService.getById(resource, id),
|
||||
>(
|
||||
"rule-engine",
|
||||
"getById",
|
||||
({ resource, id }) => ruleEngineService.getById(resource, id),
|
||||
({ resource, id }) => QUERY_KEYS.RULE_ENGINE.detail(resource, id),
|
||||
),
|
||||
|
||||
create: endpoint<
|
||||
@@ -209,37 +221,33 @@ export const api = {
|
||||
({ id }) => ruleEngineService.submitRate(id),
|
||||
),
|
||||
|
||||
approveRate: endpoint<
|
||||
{ id: string; payload: ApproveRatePayload },
|
||||
RuleEngineRecord
|
||||
>("rule-engine", "approveRate", ({ id, payload }) =>
|
||||
ruleEngineService.approveRate(id, payload),
|
||||
approveRate: endpoint<{ id: string }, RuleEngineRecord>(
|
||||
"rule-engine",
|
||||
"approveRate",
|
||||
({ id }) => ruleEngineService.approveRate(id),
|
||||
),
|
||||
|
||||
getApprovalChain: endpoint<void, RuleEngineRecord[]>(
|
||||
"rule-engine",
|
||||
"getApprovalChain",
|
||||
() => ruleEngineService.getApprovalChain(),
|
||||
() => QUERY_KEYS.RULE_ENGINE.chain,
|
||||
),
|
||||
},
|
||||
|
||||
bookings: {
|
||||
list: endpoint<
|
||||
{ filter?: BookingListFilter },
|
||||
PaginatedResponse<Freight.IBooking>
|
||||
>("bookings", "list", ({ filter }) => bookingsService.list(filter)),
|
||||
list: endpoint<{ filter?: BookingListFilter }, PaginatedBookings>(
|
||||
"bookings",
|
||||
"list",
|
||||
({ filter }) => bookingsService.list(filter),
|
||||
({ filter }) => QUERY_KEYS.BOOKINGS.list(filter),
|
||||
),
|
||||
|
||||
getById: endpoint<{ id: string }, Freight.IBooking>(
|
||||
getById: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"getById",
|
||||
({ id }) => bookingsService.getById(id),
|
||||
),
|
||||
|
||||
updateStatus: endpoint<
|
||||
{ id: string; action: string; reason?: string },
|
||||
Freight.IBooking
|
||||
>("bookings", "updateStatus", ({ id, action, reason }) =>
|
||||
bookingsService.updateStatus(id, { action, reason }),
|
||||
({ id }) => QUERY_KEYS.BOOKINGS.byId(id),
|
||||
),
|
||||
|
||||
remove: endpoint<{ id: string }, void>(
|
||||
@@ -247,5 +255,84 @@ export const api = {
|
||||
"remove",
|
||||
({ id }) => bookingsService.remove(id),
|
||||
),
|
||||
|
||||
staffAccept: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"staffAccept",
|
||||
({ id }) => bookingsService.staffAccept(id),
|
||||
),
|
||||
|
||||
requestChanges: endpoint<{ id: string; note: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"requestChanges",
|
||||
({ id, note }) => bookingsService.requestChanges(id, note),
|
||||
),
|
||||
|
||||
staffReject: endpoint<{ id: string; reason: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"staffReject",
|
||||
({ id, reason }) => bookingsService.staffReject(id, reason),
|
||||
),
|
||||
|
||||
approveStep: endpoint<ApproveStepPayload, BookingDetail>(
|
||||
"bookings",
|
||||
"approveStep",
|
||||
(payload) => bookingsService.approveStep(payload),
|
||||
),
|
||||
|
||||
rejectStep: endpoint<RejectStepPayload, BookingDetail>(
|
||||
"bookings",
|
||||
"rejectStep",
|
||||
(payload) => bookingsService.rejectStep(payload),
|
||||
),
|
||||
|
||||
generateContract: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"generateContract",
|
||||
({ id }) => bookingsService.generateContract(id),
|
||||
),
|
||||
|
||||
getContractView: endpoint<{ id: string }, import("./bookings.service").ContractView>(
|
||||
"bookings",
|
||||
"getContractView",
|
||||
({ id }) => bookingsService.getContractView(id),
|
||||
),
|
||||
|
||||
signContract: endpoint<
|
||||
{ id: string } & import("./bookings.service").SignContractPayload,
|
||||
BookingDetail
|
||||
>("bookings", "signContract", ({ id, ...payload }) =>
|
||||
bookingsService.signContract(id, payload),
|
||||
),
|
||||
|
||||
generatePnr: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"generatePnr",
|
||||
({ id }) => bookingsService.generatePnr(id),
|
||||
),
|
||||
|
||||
verifyPayment: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"verifyPayment",
|
||||
({ id }) => bookingsService.verifyPayment(id),
|
||||
),
|
||||
|
||||
startTransit: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"startTransit",
|
||||
({ id }) => bookingsService.startTransit(id),
|
||||
),
|
||||
|
||||
complete: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"complete",
|
||||
({ id }) => bookingsService.complete(id),
|
||||
),
|
||||
|
||||
cancel: endpoint<{ id: string; reason: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"cancel",
|
||||
({ id, reason }) => bookingsService.cancel(id, reason),
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user