import apiFetch from '@wordpress/api-fetch' export type BookedOrder = { orderRef: string serviceCode: string } export type PrintResult = { printJobIds: Array unassigned: Array failed: Array } export const printBookedLabels = async ( booked: Array ): Promise => { if (booked.length === 0) { return { printJobIds: [], unassigned: [], failed: [] } } try { const result = await apiFetch>({ path: '/posten-bring-checkout/printing/jobs', method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ orders: booked }), }) return { printJobIds: result?.printJobIds ?? [], unassigned: result?.unassigned ?? [], failed: result?.failed ?? [], } // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (error: unknown) { return undefined } }