27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
import { USE_ADMIN_REFUNDS_MOCK, USE_CUSTOMER_REFUNDS_MOCK } from '../constants';
|
|
import type { RefundsApi } from '../types';
|
|
import { refundsClientApi } from './clientApi';
|
|
import { refundsMockApi } from './mockApi';
|
|
|
|
const customer = USE_CUSTOMER_REFUNDS_MOCK ? refundsMockApi : refundsClientApi;
|
|
const admin = USE_ADMIN_REFUNDS_MOCK ? refundsMockApi : refundsClientApi;
|
|
|
|
/**
|
|
* The selected `RefundsApi` implementation — the single seam the hooks import. The customer surface and
|
|
* the admin console are two independently-selected halves (`USE_CUSTOMER_REFUNDS_MOCK` /
|
|
* `USE_ADMIN_REFUNDS_MOCK`), composed into one object here rather than scattered `if (mock)` checks —
|
|
* see the constants for why the admin group must never be split across real and mock.
|
|
*/
|
|
export const refundsApi: RefundsApi = {
|
|
resolveCancellationPolicy: customer.resolveCancellationPolicy,
|
|
cancelBooking: customer.cancelBooking,
|
|
getRefundByBooking: customer.getRefundByBooking,
|
|
getRefund: customer.getRefund,
|
|
getMyRefunds: customer.getMyRefunds,
|
|
|
|
getRefundPreview: admin.getRefundPreview,
|
|
initiateRefund: admin.initiateRefund,
|
|
approveRefund: admin.approveRefund,
|
|
rejectRefund: admin.rejectRefund,
|
|
};
|