fix(api): remove unused listOrdersByConsumer helper
The function performed client-side filtering on top of listOrders but was never called by any page. listPlayersByShop is kept as-is since the backend has no dedicated shop players endpoint.
This commit is contained in:
+14
-9
@@ -79,25 +79,30 @@ export async function getOrderById(orderId: string): Promise<Order | undefined>
|
||||
}
|
||||
}
|
||||
|
||||
export async function listOrdersByConsumer(consumerId: string): Promise<Order[]> {
|
||||
const items = await listOrders({ role: "consumer" })
|
||||
return items.filter((order) => order.consumerId === consumerId)
|
||||
}
|
||||
|
||||
interface CreatePaidOrderInput {
|
||||
playerId: string
|
||||
serviceId: string
|
||||
shopId?: string
|
||||
playerId: string | number
|
||||
serviceId: string | number
|
||||
shopId?: string | number
|
||||
quantity: number
|
||||
note?: string
|
||||
}
|
||||
|
||||
function createOrderJson(input: CreatePaidOrderInput) {
|
||||
return {
|
||||
playerId: Number(input.playerId),
|
||||
serviceId: Number(input.serviceId),
|
||||
...(input.shopId ? { shopId: Number(input.shopId) } : {}),
|
||||
quantity: input.quantity,
|
||||
...(input.note ? { note: input.note } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
export async function createPaidOrder(input: CreatePaidOrderInput): Promise<ActionResult> {
|
||||
try {
|
||||
const res = await httpJson<unknown>("/api/v1/orders/paid", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
json: input,
|
||||
json: createOrderJson(input),
|
||||
})
|
||||
const order = unwrapOrder(res)
|
||||
if (!order) {
|
||||
|
||||
Reference in New Issue
Block a user