63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import {
|
|
DeliveryAction,
|
|
RespondToOfferResponse,
|
|
PendingOfferResponse,
|
|
PickupOrderResponse,
|
|
DeliveryDetailsResponse,
|
|
OrderHistoryResponse,
|
|
} from '@interfaces';
|
|
import { apiClient } from '@services';
|
|
|
|
/**
|
|
* POST /delivery-partners/deliveries/{id}/respond
|
|
* Accept or reject a delivery offer.
|
|
*/
|
|
export const respondToOffer = async (
|
|
deliveryId: string,
|
|
action: DeliveryAction,
|
|
): Promise<RespondToOfferResponse> => {
|
|
const response = await apiClient.post<RespondToOfferResponse>(
|
|
`/delivery-partners/deliveries/${deliveryId}/respond`,
|
|
{ action },
|
|
);
|
|
return response;
|
|
};
|
|
|
|
/**
|
|
* GET /delivery-partners/deliveries/pending-offer
|
|
* Check if there is a pending offer for the current partner (e.g. after app restart).
|
|
*/
|
|
export const getPendingOffer = async (): Promise<PendingOfferResponse> => {
|
|
const response = await apiClient.get<PendingOfferResponse>(
|
|
'/delivery-partners/deliveries/pending-offer',
|
|
);
|
|
return response;
|
|
};
|
|
|
|
export const getActiveDeliveries =
|
|
async (): Promise<DeliveryDetailsResponse> => {
|
|
const response = await apiClient.get<DeliveryDetailsResponse>(
|
|
'/delivery-partners/deliveries/active',
|
|
);
|
|
return response;
|
|
};
|
|
|
|
export const changeOrderStatus = async (
|
|
deliveryId: string,
|
|
action: string,
|
|
proofKey?: string,
|
|
): Promise<PickupOrderResponse> => {
|
|
const response = await apiClient.post<PickupOrderResponse>(
|
|
`/delivery-partners/deliveries/${deliveryId}/status`,
|
|
{ action, proofKey },
|
|
);
|
|
return response;
|
|
};
|
|
|
|
export const completedDeliveries = async (): Promise<OrderHistoryResponse> => {
|
|
const response = await apiClient.get<OrderHistoryResponse>(
|
|
'/delivery-partners/deliveries/history',
|
|
);
|
|
return response;
|
|
};
|