feat: deal attributes with select and options

This commit is contained in:
2025-10-29 19:36:58 +04:00
parent 8019fa566c
commit 4cc6360bb4
14 changed files with 489 additions and 20 deletions

View File

@ -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);