feat: product images upload and display
This commit is contained in:
@ -60,7 +60,6 @@ import {
|
||||
getMarketplaces,
|
||||
getProductBarcodePdf,
|
||||
getProducts,
|
||||
getProject,
|
||||
getProjects,
|
||||
getServiceCategories,
|
||||
getServices,
|
||||
@ -85,6 +84,7 @@ import {
|
||||
updateServiceCategory,
|
||||
updateServicesKit,
|
||||
updateStatus,
|
||||
uploadProductImage,
|
||||
type Options,
|
||||
} from "../sdk.gen";
|
||||
import type {
|
||||
@ -215,7 +215,6 @@ import type {
|
||||
GetProductsData,
|
||||
GetProductsError,
|
||||
GetProductsResponse2,
|
||||
GetProjectData,
|
||||
GetProjectsData,
|
||||
GetServiceCategoriesData,
|
||||
GetServicesData,
|
||||
@ -276,6 +275,9 @@ import type {
|
||||
UpdateStatusData,
|
||||
UpdateStatusError,
|
||||
UpdateStatusResponse2,
|
||||
UploadProductImageData,
|
||||
UploadProductImageError,
|
||||
UploadProductImageResponse,
|
||||
} from "../types.gen";
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
@ -2188,6 +2190,57 @@ export const updateProductMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const uploadProductImageQueryKey = (
|
||||
options: Options<UploadProductImageData>
|
||||
) => createQueryKey("uploadProductImage", options);
|
||||
|
||||
/**
|
||||
* Upload Product Image
|
||||
*/
|
||||
export const uploadProductImageOptions = (
|
||||
options: Options<UploadProductImageData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await uploadProductImage({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: uploadProductImageQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Upload Product Image
|
||||
*/
|
||||
export const uploadProductImageMutation = (
|
||||
options?: Partial<Options<UploadProductImageData>>
|
||||
): UseMutationOptions<
|
||||
UploadProductImageResponse,
|
||||
AxiosError<UploadProductImageError>,
|
||||
Options<UploadProductImageData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UploadProductImageResponse,
|
||||
AxiosError<UploadProductImageError>,
|
||||
Options<UploadProductImageData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await uploadProductImage({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getProductBarcodePdfQueryKey = (
|
||||
options: Options<GetProductBarcodePdfData>
|
||||
) => createQueryKey("getProductBarcodePdf", options);
|
||||
@ -2716,27 +2769,6 @@ export const deleteProjectMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getProjectQueryKey = (options: Options<GetProjectData>) =>
|
||||
createQueryKey("getProject", options);
|
||||
|
||||
/**
|
||||
* Get Project
|
||||
*/
|
||||
export const getProjectOptions = (options: Options<GetProjectData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getProject({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getProjectQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Project
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user