generated from laioutr/app-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassthroughTokens.ts
More file actions
23 lines (17 loc) · 1.21 KB
/
passthroughTokens.ts
File metadata and controls
23 lines (17 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { createPassthroughToken } from '#imports';
import { ShopwareCart, ShopwareCategory, ShopwareProduct } from '../types/shopware';
export const currentProductIdsToken = createPassthroughToken<string[]>('@laioutr/app-shopware/currentProductIdsFragment');
export const categoriesToken = createPassthroughToken<ShopwareCategory[]>('@laioutr/app-shopware/categories');
/**
* Product ids returned by the storefront api may actually be variant-ids.
* In order for the Product.variants link to work, we need to know the parent-id of the products.
* If no parent-id is given here, assume that the product-id is the parent-id.
*
* We cannot let the product-queries return the parent-ids, because the parents contain no data.
*/
export const parentIdToDefaultVariantIdToken = createPassthroughToken<Record<string, string>>(
'@laioutr/app-shopware/parentIdToDefaultVariantId'
);
export const productsFragmentToken = createPassthroughToken<ShopwareProduct[]>('@laioutr/app-shopware/productsFragment');
export const productVariantsToken = createPassthroughToken<ShopwareProduct[]>('@laioutr/app-shopware/productVariants');
export const cartFragmentToken = createPassthroughToken<ShopwareCart>('@laioutr-app/shopify/cartFragment');