/* eslint-disable import/no-unresolved */ /* eslint-disable import/order */ import { sageService } from '@/service/sageService'; import { Fournisseur, FournisseurRequest, FournisseurUpdateRequest } from '@/types/fournisseurType'; import { createAsyncThunk } from '@reduxjs/toolkit'; /** * get all fournisseurs */ export const getFournisseurs = createAsyncThunk( 'fournisseur/getFournisseurs', async (): Promise => { try { return await sageService.getFournisseurs(); } catch (err) { throw err; } } ); /** * add fournisseur */ export const addFournisseur = createAsyncThunk( 'fournisseur/addFournisseur', async (data: FournisseurRequest): Promise => { try { return await sageService.addFournisseur(data); } catch (err) { throw err; } } ); /** * update fournisseur */ export const updateFournisseur = createAsyncThunk( 'fournisseur/updateFournisseur', async ( { numero, data }: { numero: string; data: FournisseurUpdateRequest } ): Promise => { try { return await sageService.updateFournisseur(numero, data); } catch (err) { throw err; } } );