31 lines
895 B
TypeScript

import { createAsyncThunk } from '@reduxjs/toolkit';
import { deliveryPartnerLocation, toggleStatus as toggleStatusApi } from '@api';
import {
DeliveryPartnerLocationRequest,
ToggleStatusPayload,
} from '@interfaces';
export const toggleStatus = createAsyncThunk(
'dashboard/toggleStatus',
async (payload: ToggleStatusPayload, { rejectWithValue }) => {
try {
const response = await toggleStatusApi(payload);
return response;
} catch (error: unknown) {
return rejectWithValue(error);
}
},
);
export const updateDeliveryPartnerLocation = createAsyncThunk(
'dashboard/updateDeliveryPartnerLocation',
async (payload: DeliveryPartnerLocationRequest, { rejectWithValue }) => {
try {
const response = await deliveryPartnerLocation(payload);
return response;
} catch (error: unknown) {
return rejectWithValue(error);
}
},
);