19 lines
555 B
TypeScript

import { createAsyncThunk } from '@reduxjs/toolkit';
import { getProductDetailsApi } from '@api';
import { Product } from '@interfaces';
export const getProductDetailsThunk = createAsyncThunk<
Product,
string,
{ rejectValue: string }
>('providerDetails/getProductDetails', async (productId, { rejectWithValue }) => {
try {
const response = await getProductDetailsApi(productId);
return response;
} catch (error: any) {
return rejectWithValue(
error.response?.data?.message || 'Failed to fetch product details',
);
}
});