feat: deal attributes with select and options
This commit is contained in:
@ -53,6 +53,8 @@ import {
|
||||
duplicateProductServices,
|
||||
getAttributes,
|
||||
getAttributeTypes,
|
||||
getAttrSelectOptions,
|
||||
getAttrSelects,
|
||||
getBarcodeTemplateAttributes,
|
||||
getBarcodeTemplates,
|
||||
getBarcodeTemplateSizes,
|
||||
@ -230,6 +232,8 @@ import type {
|
||||
DuplicateProductServicesResponse,
|
||||
GetAttributesData,
|
||||
GetAttributeTypesData,
|
||||
GetAttrSelectOptionsData,
|
||||
GetAttrSelectsData,
|
||||
GetBarcodeTemplateAttributesData,
|
||||
GetBarcodeTemplatesData,
|
||||
GetBarcodeTemplateSizesData,
|
||||
@ -374,6 +378,53 @@ const createQueryKey = <TOptions extends Options>(
|
||||
return [params];
|
||||
};
|
||||
|
||||
export const getAttrSelectsQueryKey = (options?: Options<GetAttrSelectsData>) =>
|
||||
createQueryKey("getAttrSelects", options);
|
||||
|
||||
/**
|
||||
* Get Attr Selects
|
||||
*/
|
||||
export const getAttrSelectsOptions = (
|
||||
options?: Options<GetAttrSelectsData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getAttrSelects({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getAttrSelectsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const getAttrSelectOptionsQueryKey = (
|
||||
options: Options<GetAttrSelectOptionsData>
|
||||
) => createQueryKey("getAttrSelectOptions", options);
|
||||
|
||||
/**
|
||||
* Get Attr Select Options
|
||||
*/
|
||||
export const getAttrSelectOptionsOptions = (
|
||||
options: Options<GetAttrSelectOptionsData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getAttrSelectOptions({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getAttrSelectOptionsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const getAttributesQueryKey = (options?: Options<GetAttributesData>) =>
|
||||
createQueryKey("getAttributes", options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user