@proveanything/smartlinks-utils-ui 1.14.3 → 1.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1820,6 +1820,12 @@ interface UseProductChildrenArgs {
|
|
|
1820
1820
|
/** Which child kind to fetch. Hooks only fire when both productId and kind are set. */
|
|
1821
1821
|
kind: 'variant' | 'batch' | null;
|
|
1822
1822
|
enabled?: boolean;
|
|
1823
|
+
/**
|
|
1824
|
+
* When true, include children whose `deleted` flag is true. Defaults to
|
|
1825
|
+
* false — the admin API returns deleted rows and we filter them out so
|
|
1826
|
+
* the rail matches what non-admin surfaces show.
|
|
1827
|
+
*/
|
|
1828
|
+
includeDeleted?: boolean;
|
|
1823
1829
|
}
|
|
1824
1830
|
/**
|
|
1825
1831
|
* Lazy children loader. When `kind` is `null` or `productId` is missing the
|
|
@@ -1325,11 +1325,11 @@ var batchToItem = (b) => {
|
|
|
1325
1325
|
};
|
|
1326
1326
|
};
|
|
1327
1327
|
var useProductChildren = (args) => {
|
|
1328
|
-
const { SL, collectionId, productId, kind, enabled = true } = args;
|
|
1328
|
+
const { SL, collectionId, productId, kind, enabled = true, includeDeleted = false } = args;
|
|
1329
1329
|
const queryClient = useQueryClient();
|
|
1330
1330
|
const queryKey = useMemo(
|
|
1331
|
-
() => [...QK4, collectionId, productId ?? null, kind],
|
|
1332
|
-
[collectionId, productId, kind]
|
|
1331
|
+
() => [...QK4, collectionId, productId ?? null, kind, includeDeleted],
|
|
1332
|
+
[collectionId, productId, kind, includeDeleted]
|
|
1333
1333
|
);
|
|
1334
1334
|
const query = useQuery({
|
|
1335
1335
|
queryKey,
|
|
@@ -1337,12 +1337,13 @@ var useProductChildren = (args) => {
|
|
|
1337
1337
|
staleTime: 3e4,
|
|
1338
1338
|
queryFn: async () => {
|
|
1339
1339
|
if (!productId || !kind) return [];
|
|
1340
|
+
const keep = (row) => includeDeleted || row?.deleted !== true;
|
|
1340
1341
|
if (kind === "variant") {
|
|
1341
1342
|
const res2 = await SL.variant.list(collectionId, productId);
|
|
1342
|
-
return (res2 ?? []).map(variantToItem);
|
|
1343
|
+
return (res2 ?? []).filter(keep).map(variantToItem);
|
|
1343
1344
|
}
|
|
1344
1345
|
const res = await SL.batch.list(collectionId, productId);
|
|
1345
|
-
return (res ?? []).map(batchToItem);
|
|
1346
|
+
return (res ?? []).filter(keep).map(batchToItem);
|
|
1346
1347
|
}
|
|
1347
1348
|
});
|
|
1348
1349
|
const refetch = () => queryClient.invalidateQueries({
|