feat: clients page
This commit is contained in:
@ -13,6 +13,7 @@ import {
|
||||
addKitToDealProduct,
|
||||
createBarcodeTemplate,
|
||||
createBoard,
|
||||
createClient,
|
||||
createDeal,
|
||||
createDealProduct,
|
||||
createDealProductService,
|
||||
@ -25,6 +26,7 @@ import {
|
||||
createStatus,
|
||||
deleteBarcodeTemplate,
|
||||
deleteBoard,
|
||||
deleteClient,
|
||||
deleteDeal,
|
||||
deleteDealProduct,
|
||||
deleteDealProductService,
|
||||
@ -41,6 +43,7 @@ import {
|
||||
getBarcodeTemplateSizes,
|
||||
getBoards,
|
||||
getBuiltInModules,
|
||||
getClients,
|
||||
getDealProducts,
|
||||
getDeals,
|
||||
getDealServices,
|
||||
@ -53,6 +56,7 @@ import {
|
||||
getStatusHistory,
|
||||
updateBarcodeTemplate,
|
||||
updateBoard,
|
||||
updateClient,
|
||||
updateDeal,
|
||||
updateDealProduct,
|
||||
updateDealProductService,
|
||||
@ -78,6 +82,9 @@ import type {
|
||||
CreateBoardData,
|
||||
CreateBoardError,
|
||||
CreateBoardResponse2,
|
||||
CreateClientData,
|
||||
CreateClientError,
|
||||
CreateClientResponse2,
|
||||
CreateDealData,
|
||||
CreateDealError,
|
||||
CreateDealProductData,
|
||||
@ -114,6 +121,9 @@ import type {
|
||||
DeleteBoardData,
|
||||
DeleteBoardError,
|
||||
DeleteBoardResponse2,
|
||||
DeleteClientData,
|
||||
DeleteClientError,
|
||||
DeleteClientResponse2,
|
||||
DeleteDealData,
|
||||
DeleteDealError,
|
||||
DeleteDealProductData,
|
||||
@ -152,6 +162,7 @@ import type {
|
||||
GetBarcodeTemplateSizesData,
|
||||
GetBoardsData,
|
||||
GetBuiltInModulesData,
|
||||
GetClientsData,
|
||||
GetDealProductsData,
|
||||
GetDealsData,
|
||||
GetDealsError,
|
||||
@ -172,6 +183,9 @@ import type {
|
||||
UpdateBoardData,
|
||||
UpdateBoardError,
|
||||
UpdateBoardResponse2,
|
||||
UpdateClientData,
|
||||
UpdateClientError,
|
||||
UpdateClientResponse2,
|
||||
UpdateDealData,
|
||||
UpdateDealError,
|
||||
UpdateDealProductData,
|
||||
@ -865,6 +879,129 @@ export const getStatusHistoryOptions = (
|
||||
});
|
||||
};
|
||||
|
||||
export const getClientsQueryKey = (options?: Options<GetClientsData>) =>
|
||||
createQueryKey("getClients", options);
|
||||
|
||||
/**
|
||||
* Get Clients
|
||||
*/
|
||||
export const getClientsOptions = (options?: Options<GetClientsData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getClients({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getClientsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const createClientQueryKey = (options: Options<CreateClientData>) =>
|
||||
createQueryKey("createClient", options);
|
||||
|
||||
/**
|
||||
* Create Client
|
||||
*/
|
||||
export const createClientOptions = (options: Options<CreateClientData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createClient({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createClientQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Client
|
||||
*/
|
||||
export const createClientMutation = (
|
||||
options?: Partial<Options<CreateClientData>>
|
||||
): UseMutationOptions<
|
||||
CreateClientResponse2,
|
||||
AxiosError<CreateClientError>,
|
||||
Options<CreateClientData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateClientResponse2,
|
||||
AxiosError<CreateClientError>,
|
||||
Options<CreateClientData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createClient({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Product
|
||||
*/
|
||||
export const deleteClientMutation = (
|
||||
options?: Partial<Options<DeleteClientData>>
|
||||
): UseMutationOptions<
|
||||
DeleteClientResponse2,
|
||||
AxiosError<DeleteClientError>,
|
||||
Options<DeleteClientData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteClientResponse2,
|
||||
AxiosError<DeleteClientError>,
|
||||
Options<DeleteClientData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteClient({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Client
|
||||
*/
|
||||
export const updateClientMutation = (
|
||||
options?: Partial<Options<UpdateClientData>>
|
||||
): UseMutationOptions<
|
||||
UpdateClientResponse2,
|
||||
AxiosError<UpdateClientError>,
|
||||
Options<UpdateClientData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateClientResponse2,
|
||||
AxiosError<UpdateClientError>,
|
||||
Options<UpdateClientData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateClient({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getBarcodeTemplatesQueryKey = (
|
||||
options?: Options<GetBarcodeTemplatesData>
|
||||
) => createQueryKey("getBarcodeTemplates", options);
|
||||
|
||||
Reference in New Issue
Block a user