@burdenoff/microfe-store 2026.514.1 → 2026.518.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useBackendCart.js","names":[],"sources":["../../src/hooks/useBackendCart.ts"],"sourcesContent":["/**\n * Backend Cart Hook\n *\n * Provides cart operations that interact with the backend store service.\n * All cart data is stored on the backend, not in localStorage.\n */\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useStoreGraphQLWithContext } from './useStoreGraphQLWithContext';\nimport {\n GetCartDocument,\n AddToCartDocument,\n UpdateCartItemDocument,\n RemoveFromCartDocument,\n ClearCartDocument,\n CreateStoreOrderDocument,\n} from '../generated/global-operations';\nimport { type AddToCartInput, type CreateStoreOrderInput } from '../generated/global-types';\n\n// Cart types - defined locally since operations.ts doesn't export them\nexport interface Cart {\n id: string;\n userId?: string;\n organizationId?: string;\n sessionId?: string;\n status: 'ACTIVE' | 'ABANDONED' | 'CONVERTED' | 'EXPIRED';\n currency: string;\n subtotal: number;\n total: number;\n itemCount: number;\n notes?: string;\n expiresAt?: string;\n lastActivityAt: string;\n createdAt: string;\n updatedAt: string;\n requiresShipping: boolean;\n isEmpty: boolean;\n items: CartItem[];\n}\n\nexport interface CartItem {\n id: string;\n cartId: string;\n productId: string;\n variantId?: string;\n itemType: 'DIGITAL' | 'PHYSICAL' | 'BUNDLE';\n quantity: number;\n unitPrice: number;\n compareAtPrice?: number;\n subtotal: number;\n workspaceId?: string;\n productName: string;\n variantName?: string;\n productIcon?: string;\n product?: {\n id: string;\n name: string;\n slug?: string;\n icon?: string;\n price?: number;\n pricingModel?: string;\n };\n addedAt: string;\n updatedAt: string;\n}\n\ninterface CartError {\n field?: string;\n message: string;\n code: string;\n}\n\ninterface CartItemPayload {\n cartItem?: CartItem;\n cart?: Cart;\n errors?: CartError[];\n}\n\ninterface CartPayload {\n cart?: Cart;\n errors?: CartError[];\n}\n\n/**\n * Hook for backend cart operations\n */\nexport function useBackendCart() {\n const globalClient = useApolloClient();\n const {\n query: queryWithContext,\n mutate: mutateWithContext,\n hasOrganizationContext,\n } = useStoreGraphQLWithContext();\n const [cart, setCart] = useState<Cart | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [addingToCart, setAddingToCart] = useState(false);\n const [updatingCartItem, setUpdatingCartItem] = useState(false);\n const [removingFromCart, setRemovingFromCart] = useState(false);\n const [clearingCart, setClearingCart] = useState(false);\n const [checkingOut, setCheckingOut] = useState(false);\n\n // Fetch cart from backend\n const fetchCart = useCallback(\n async (forceNetwork = false) => {\n setLoading(true);\n setError(null);\n try {\n // Use organization-aware query if organization context is available\n if (hasOrganizationContext) {\n const result = (await queryWithContext({\n query: GetCartDocument,\n fetchPolicy: forceNetwork ? 'network-only' : 'cache-first',\n })) as { data?: { myCart: Cart | null } };\n setCart(result.data?.myCart || null);\n } else {\n // Fallback to regular client without organization context\n const result = await globalClient.query<{ myCart: Cart | null }>({\n query: GetCartDocument,\n fetchPolicy: forceNetwork ? 'network-only' : 'cache-first',\n });\n setCart(result.data?.myCart || null);\n }\n } catch (err) {\n setError(err as Error);\n console.error('Failed to fetch cart:', err);\n } finally {\n setLoading(false);\n }\n },\n [globalClient, queryWithContext, hasOrganizationContext]\n );\n\n // Fetch cart on mount and when globalClient changes\n useEffect(() => {\n fetchCart();\n }, [fetchCart]);\n\n // Add product to cart\n const addProductToCart = useCallback(\n async (input: AddToCartInput) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setAddingToCart(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: AddToCartDocument,\n variables: { input },\n })) as { data?: { addToCart: CartItemPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ addToCart: CartItemPayload }>({\n mutation: AddToCartDocument,\n variables: { input },\n });\n }\n\n if (result.data?.addToCart.errors && result.data.addToCart.errors.length > 0) {\n throw new Error(result.data.addToCart.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.addToCart.cart) {\n setCart(result.data.addToCart.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.addToCart.cart;\n } catch (error) {\n console.error('Failed to add product to cart:', error);\n throw error;\n } finally {\n setAddingToCart(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n // Update cart item quantity\n const updateQuantity = useCallback(\n async (cartItemId: string, quantity: number) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setUpdatingCartItem(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: UpdateCartItemDocument,\n variables: { input: { cartItemId, quantity } },\n })) as { data?: { updateCartItem: CartItemPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ updateCartItem: CartItemPayload }>({\n mutation: UpdateCartItemDocument,\n variables: { input: { cartItemId, quantity } },\n });\n }\n\n if (result.data?.updateCartItem.errors && result.data.updateCartItem.errors.length > 0) {\n throw new Error(result.data.updateCartItem.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.updateCartItem.cart) {\n setCart(result.data.updateCartItem.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.updateCartItem.cart;\n } catch (error) {\n console.error('Failed to update cart item:', error);\n throw error;\n } finally {\n setUpdatingCartItem(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n // Remove product from cart\n const removeProductFromCart = useCallback(\n async (cartItemId: string) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setRemovingFromCart(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: RemoveFromCartDocument,\n variables: { cartItemId },\n })) as { data?: { removeFromCart: CartPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ removeFromCart: CartPayload }>({\n mutation: RemoveFromCartDocument,\n variables: { cartItemId },\n });\n }\n\n if (result.data?.removeFromCart.errors && result.data.removeFromCart.errors.length > 0) {\n throw new Error(result.data.removeFromCart.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.removeFromCart.cart) {\n setCart(result.data.removeFromCart.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.removeFromCart.cart;\n } catch (error) {\n console.error('Failed to remove product from cart:', error);\n throw error;\n } finally {\n setRemovingFromCart(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n // Clear all items from cart\n const clearAllItems = useCallback(async () => {\n setClearingCart(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: ClearCartDocument,\n })) as { data?: { clearCart: CartPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ clearCart: CartPayload }>({\n mutation: ClearCartDocument,\n });\n }\n\n if (result.data?.clearCart.errors && result.data.clearCart.errors.length > 0) {\n throw new Error(result.data.clearCart.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.clearCart.cart) {\n setCart(result.data.clearCart.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.clearCart.cart;\n } catch (error) {\n console.error('Failed to clear cart:', error);\n throw error;\n } finally {\n setClearingCart(false);\n }\n }, [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]);\n\n // CreateStoreOrder response type\n interface CreateStoreOrderResponse {\n createStoreOrder: { id: string } | null;\n }\n\n // Create store order from cart\n const createOrder = useCallback(\n async (input: CreateStoreOrderInput) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setCheckingOut(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: CreateStoreOrderDocument,\n variables: { input },\n })) as { data?: CreateStoreOrderResponse };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<CreateStoreOrderResponse>({\n mutation: CreateStoreOrderDocument,\n variables: { input },\n });\n }\n\n if (!result.data?.createStoreOrder?.id) {\n throw new Error('Failed to create order');\n }\n\n // Refetch cart after order creation (should be empty or converted)\n await fetchCart(true);\n\n return result.data.createStoreOrder;\n } catch (error) {\n console.error('Failed to create order:', error);\n throw error;\n } finally {\n setCheckingOut(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n const cartItems = cart?.items || [];\n const itemCount = cart?.itemCount || 0;\n const subtotal = cart?.subtotal || 0;\n const total = cart?.total || 0;\n const tax = total - subtotal; // Tax is calculated as difference between total and subtotal\n const currency = cart?.currency || 'USD';\n\n return {\n // Cart data\n cart,\n cartItems,\n itemCount,\n subtotal,\n tax,\n total,\n currency,\n\n // Loading states\n loading,\n addingToCart,\n updatingCartItem,\n removingFromCart,\n clearingCart,\n checkingOut,\n\n // Error state\n error,\n\n // Actions\n addProductToCart,\n updateQuantity,\n removeProductFromCart,\n clearAllItems,\n createOrder,\n refetchCart: fetchCart,\n };\n}\n"],"mappings":";;;;;AAuFA,SAAgB,IAAiB;CAC/B,IAAM,IAAe,GAAiB,EAChC,EACJ,OAAO,GACP,QAAQ,GACR,8BACE,GAA4B,EAC1B,CAAC,GAAM,KAAW,EAAsB,KAAK,EAC7C,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAuB,KAAK,EAChD,CAAC,GAAc,KAAmB,EAAS,GAAM,EACjD,CAAC,GAAkB,KAAuB,EAAS,GAAM,EACzD,CAAC,GAAkB,KAAuB,EAAS,GAAM,EACzD,CAAC,GAAc,KAAmB,EAAS,GAAM,EACjD,CAAC,GAAa,KAAkB,EAAS,GAAM,EAG/C,IAAY,EAChB,OAAO,IAAe,OAAU;AAE9B,EADA,EAAW,GAAK,EAChB,EAAS,KAAK;AACd,MAAI;AAEF,GAKE,E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,aAAa;EACd"}
1
+ {"version":3,"file":"useBackendCart.js","names":[],"sources":["../../src/hooks/useBackendCart.ts"],"sourcesContent":["/**\n * Backend Cart Hook\n *\n * Provides cart operations that interact with the backend store service.\n * All cart data is stored on the backend, not in localStorage.\n */\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useStoreGraphQLWithContext } from './useStoreGraphQLWithContext';\nimport {\n GetCartDocument,\n AddToCartDocument,\n UpdateCartItemDocument,\n RemoveFromCartDocument,\n ClearCartDocument,\n CreateStoreOrderDocument,\n} from '../generated/global-operations';\nimport { type AddToCartInput, type CreateStoreOrderInput } from '../generated/global-types';\n\n// Cart types - defined locally since operations.ts doesn't export them\nexport interface Cart {\n id: string;\n userId?: string;\n organizationId?: string;\n sessionId?: string;\n status: 'ACTIVE' | 'ABANDONED' | 'CONVERTED' | 'EXPIRED';\n currency: string;\n subtotal: number;\n total: number;\n itemCount: number;\n notes?: string;\n expiresAt?: string;\n lastActivityAt: string;\n createdAt: string;\n updatedAt: string;\n requiresShipping: boolean;\n isEmpty: boolean;\n items: CartItem[];\n}\n\nexport interface CartItem {\n id: string;\n cartId: string;\n productId: string;\n variantId?: string;\n itemType: 'DIGITAL' | 'PHYSICAL' | 'BUNDLE';\n quantity: number;\n unitPrice: number;\n compareAtPrice?: number;\n subtotal: number;\n workspaceId?: string;\n productName: string;\n variantName?: string;\n productIcon?: string;\n product?: {\n id: string;\n name: string;\n slug?: string;\n icon?: string;\n price?: number;\n pricingModel?: string;\n };\n addedAt: string;\n updatedAt: string;\n}\n\ninterface CartError {\n field?: string;\n message: string;\n code: string;\n}\n\ninterface CartItemPayload {\n cartItem?: CartItem;\n cart?: Cart;\n errors?: CartError[];\n}\n\ninterface CartPayload {\n cart?: Cart;\n errors?: CartError[];\n}\n\n/**\n * Hook for backend cart operations\n */\nexport function useBackendCart() {\n const globalClient = useApolloClient();\n const {\n query: queryWithContext,\n mutate: mutateWithContext,\n hasOrganizationContext,\n } = useStoreGraphQLWithContext();\n const [cart, setCart] = useState<Cart | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [addingToCart, setAddingToCart] = useState(false);\n const [updatingCartItem, setUpdatingCartItem] = useState(false);\n const [removingFromCart, setRemovingFromCart] = useState(false);\n const [clearingCart, setClearingCart] = useState(false);\n const [checkingOut, setCheckingOut] = useState(false);\n\n // Fetch cart from backend\n const fetchCart = useCallback(\n async (forceNetwork = false) => {\n setLoading(true);\n setError(null);\n try {\n // Use organization-aware query if organization context is available\n if (hasOrganizationContext) {\n const result = (await queryWithContext({\n query: GetCartDocument,\n fetchPolicy: forceNetwork ? 'network-only' : 'cache-first',\n })) as { data?: { myCart: Cart | null } };\n setCart(result.data?.myCart || null);\n } else {\n // Fallback to regular client without organization context\n const result = await globalClient.query<{ myCart: Cart | null }>({\n query: GetCartDocument,\n fetchPolicy: forceNetwork ? 'network-only' : 'cache-first',\n });\n setCart(result.data?.myCart || null);\n }\n } catch (err) {\n setError(err as Error);\n } finally {\n setLoading(false);\n }\n },\n [globalClient, queryWithContext, hasOrganizationContext]\n );\n\n // Fetch cart on mount and when globalClient changes\n useEffect(() => {\n fetchCart();\n }, [fetchCart]);\n\n // Add product to cart\n const addProductToCart = useCallback(\n async (input: AddToCartInput) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setAddingToCart(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: AddToCartDocument,\n variables: { input },\n })) as { data?: { addToCart: CartItemPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ addToCart: CartItemPayload }>({\n mutation: AddToCartDocument,\n variables: { input },\n });\n }\n\n if (result.data?.addToCart.errors && result.data.addToCart.errors.length > 0) {\n throw new Error(result.data.addToCart.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.addToCart.cart) {\n setCart(result.data.addToCart.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.addToCart.cart;\n } finally {\n setAddingToCart(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n // Update cart item quantity\n const updateQuantity = useCallback(\n async (cartItemId: string, quantity: number) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setUpdatingCartItem(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: UpdateCartItemDocument,\n variables: { input: { cartItemId, quantity } },\n })) as { data?: { updateCartItem: CartItemPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ updateCartItem: CartItemPayload }>({\n mutation: UpdateCartItemDocument,\n variables: { input: { cartItemId, quantity } },\n });\n }\n\n if (result.data?.updateCartItem.errors && result.data.updateCartItem.errors.length > 0) {\n throw new Error(result.data.updateCartItem.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.updateCartItem.cart) {\n setCart(result.data.updateCartItem.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.updateCartItem.cart;\n } finally {\n setUpdatingCartItem(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n // Remove product from cart\n const removeProductFromCart = useCallback(\n async (cartItemId: string) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setRemovingFromCart(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: RemoveFromCartDocument,\n variables: { cartItemId },\n })) as { data?: { removeFromCart: CartPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ removeFromCart: CartPayload }>({\n mutation: RemoveFromCartDocument,\n variables: { cartItemId },\n });\n }\n\n if (result.data?.removeFromCart.errors && result.data.removeFromCart.errors.length > 0) {\n throw new Error(result.data.removeFromCart.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.removeFromCart.cart) {\n setCart(result.data.removeFromCart.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.removeFromCart.cart;\n } finally {\n setRemovingFromCart(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n // Clear all items from cart\n const clearAllItems = useCallback(async () => {\n setClearingCart(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: ClearCartDocument,\n })) as { data?: { clearCart: CartPayload } };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<{ clearCart: CartPayload }>({\n mutation: ClearCartDocument,\n });\n }\n\n if (result.data?.clearCart.errors && result.data.clearCart.errors.length > 0) {\n throw new Error(result.data.clearCart.errors[0].message);\n }\n\n // Update local cart state\n if (result.data?.clearCart.cart) {\n setCart(result.data.clearCart.cart);\n }\n\n // Refetch to ensure consistency\n await fetchCart(true);\n\n return result.data?.clearCart.cart;\n } finally {\n setClearingCart(false);\n }\n }, [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]);\n\n // CreateStoreOrder response type\n interface CreateStoreOrderResponse {\n createStoreOrder: { id: string } | null;\n }\n\n // Create store order from cart\n const createOrder = useCallback(\n async (input: CreateStoreOrderInput) => {\n if (!globalClient) {\n throw new Error('Global client not initialized');\n }\n\n setCheckingOut(true);\n try {\n let result;\n\n if (hasOrganizationContext) {\n // Use organization-aware mutation\n result = (await mutateWithContext({\n mutation: CreateStoreOrderDocument,\n variables: { input },\n })) as { data?: CreateStoreOrderResponse };\n } else {\n // Fallback to global client without organization context\n result = await globalClient.mutate<CreateStoreOrderResponse>({\n mutation: CreateStoreOrderDocument,\n variables: { input },\n });\n }\n\n if (!result.data?.createStoreOrder?.id) {\n throw new Error('Failed to create order');\n }\n\n // Refetch cart after order creation (should be empty or converted)\n await fetchCart(true);\n\n return result.data.createStoreOrder;\n } finally {\n setCheckingOut(false);\n }\n },\n [mutateWithContext, globalClient, hasOrganizationContext, fetchCart]\n );\n\n const cartItems = cart?.items || [];\n const itemCount = cart?.itemCount || 0;\n const subtotal = cart?.subtotal || 0;\n const total = cart?.total || 0;\n const tax = total - subtotal; // Tax is calculated as difference between total and subtotal\n const currency = cart?.currency || 'USD';\n\n return {\n // Cart data\n cart,\n cartItems,\n itemCount,\n subtotal,\n tax,\n total,\n currency,\n\n // Loading states\n loading,\n addingToCart,\n updatingCartItem,\n removingFromCart,\n clearingCart,\n checkingOut,\n\n // Error state\n error,\n\n // Actions\n addProductToCart,\n updateQuantity,\n removeProductFromCart,\n clearAllItems,\n createOrder,\n refetchCart: fetchCart,\n };\n}\n"],"mappings":";;;;;AAuFA,SAAgB,IAAiB;CAC/B,IAAM,IAAe,GAAiB,EAChC,EACJ,OAAO,GACP,QAAQ,GACR,8BACE,GAA4B,EAC1B,CAAC,GAAM,KAAW,EAAsB,KAAK,EAC7C,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAuB,KAAK,EAChD,CAAC,GAAc,KAAmB,EAAS,GAAM,EACjD,CAAC,GAAkB,KAAuB,EAAS,GAAM,EACzD,CAAC,GAAkB,KAAuB,EAAS,GAAM,EACzD,CAAC,GAAc,KAAmB,EAAS,GAAM,EACjD,CAAC,GAAa,KAAkB,EAAS,GAAM,EAG/C,IAAY,EAChB,OAAO,IAAe,OAAU;AAE9B,EADA,EAAW,GAAK,EAChB,EAAS,KAAK;AACd,MAAI;AAEF,GAKE,EALE,KACc,MAAM,EAAiB;IACrC,OAAO;IACP,aAAa,IAAe,iBAAiB;IAC9C,CAAC,EACa,MAAM,UAAU,QAGhB,MAAM,EAAa,MAA+B;IAC/D,OAAO;IACP,aAAa,IAAe,iBAAiB;IAC9C,CAAC,EACa,MAAM,UAAU,KAAK;WAE/B,GAAK;AACZ,KAAS,EAAa;YACd;AACR,KAAW,GAAM;;IAGrB;EAAC;EAAc;EAAkB;EAAuB,CACzD;AAGD,SAAgB;AACd,KAAW;IACV,CAAC,EAAU,CAAC;CAGf,IA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E,IAEQ,MAAM,EAAkB;IAChC,UAAU;IACV,WAAW,EAAE,UAAO;IACrB,CAAC,GAGO,MAAM,EAAa,OAAiC;IAC3D,UAAU;IACV,WAAW,EAAE,UAAO;IACrB,CAAC,EAGA,CAAC,EAAO,MAAM,kBAAkB,GAClC,OAAU,MAAM,yBAAyB;AAM3C,UAFA,MAAM,EAAU,GAAK,EAEd,EAAO,KAAK;YACX;AACR,KAAe,GAAM;;IAGzB;EAAC;EAAmB;EAAc;EAAwB;EAAU,CACrE,EAEK,IAAY,GAAM,SAAS,EAAE,EAC7B,IAAY,GAAM,aAAa,GAC/B,IAAW,GAAM,YAAY,GAC7B,IAAQ,GAAM,SAAS;AAI7B,QAAO;EAEL;EACA;EACA;EACA;EACA,KATU,IAAQ;EAUlB;EACA,UAVe,GAAM,YAAY;EAajC;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EACA;EACA;EACA,aAAa;EACd"}
package/dist/index.js CHANGED
@@ -4,10 +4,10 @@ import { useStoreStore as r } from "./store/storeStore.js";
4
4
  import { AddToCartDocument as i, BrowseStoreDocument as a, CategoriesDocument as o, CheckEntitlementDocument as s, CheckoutDocument as c, ClearCartDocument as l, CreateProductForPublisherDocument as u, CreateReviewDocument as d, CreateStoreOrderDocument as f, DeleteReviewDocument as p, DeveloperEarningsDocument as m, FeaturedProductsDocument as h, FilterOptionsDocument as g, GetCartDocument as _, GetMyOrdersDocument as v, GetMyStoreInstallationsDocument as y, GetProductDocument as b, GetProductsDocument as x, GetStoreAppInstallationDocument as S, HomeGroupedProductsDocument as C, InstallationStatusUpdatedDocument as w, LicenseStatusUpdatedDocument as T, MarkReviewHelpfulDocument as E, MyEntitlementsDocument as D, MyPublishedProductsDocument as O, OrderStatusUpdatedDocument as k, ProductReviewsDocument as A, RecordAppUninstallationDocument as j, RemoveFromCartDocument as M, SearchSuggestionsDocument as N, StoreProductDetailsDocument as P, SubmissionStatusUpdatedDocument as F, TrendingSearchesDocument as I, UpdateCartItemDocument as L, UpdateReviewDocument as R, UserReviewForProductDocument as z, WorkspaceStoreOrdersDocument as B, useAddToCartMutation as V, useBrowseStoreLazyQuery as H, useBrowseStoreQuery as U, useBrowseStoreSuspenseQuery as W, useCategoriesLazyQuery as G, useCategoriesQuery as K, useCategoriesSuspenseQuery as q, useCheckEntitlementLazyQuery as J, useCheckEntitlementQuery as Y, useCheckEntitlementSuspenseQuery as X, useCheckoutMutation as Z, useClearCartMutation as Q, useCreateProductForPublisherMutation as $, useCreateReviewMutation as ee, useCreateStoreOrderMutation as te, useDeleteReviewMutation as ne, useDeveloperEarningsLazyQuery as re, useDeveloperEarningsQuery as ie, useDeveloperEarningsSuspenseQuery as ae, useFeaturedProductsLazyQuery as oe, useFeaturedProductsQuery as se, useFeaturedProductsSuspenseQuery as ce, useFilterOptionsLazyQuery as le, useFilterOptionsQuery as ue, useFilterOptionsSuspenseQuery as de, useGetCartLazyQuery as fe, useGetCartQuery as pe, useGetCartSuspenseQuery as me, useGetMyOrdersLazyQuery as he, useGetMyOrdersQuery as ge, useGetMyOrdersSuspenseQuery as _e, useGetMyStoreInstallationsLazyQuery as ve, useGetMyStoreInstallationsQuery as ye, useGetMyStoreInstallationsSuspenseQuery as be, useGetProductLazyQuery as xe, useGetProductQuery as Se, useGetProductSuspenseQuery as Ce, useGetProductsLazyQuery as we, useGetProductsQuery as Te, useGetProductsSuspenseQuery as Ee, useGetStoreAppInstallationLazyQuery as De, useGetStoreAppInstallationQuery as Oe, useGetStoreAppInstallationSuspenseQuery as ke, useHomeGroupedProductsLazyQuery as Ae, useHomeGroupedProductsQuery as je, useHomeGroupedProductsSuspenseQuery as Me, useInstallationStatusUpdatedSubscription as Ne, useLicenseStatusUpdatedSubscription as Pe, useMarkReviewHelpfulMutation as Fe, useMyEntitlementsLazyQuery as Ie, useMyEntitlementsQuery as Le, useMyEntitlementsSuspenseQuery as Re, useMyPublishedProductsLazyQuery as ze, useMyPublishedProductsQuery as Be, useMyPublishedProductsSuspenseQuery as Ve, useOrderStatusUpdatedSubscription as He, useProductReviewsLazyQuery as Ue, useProductReviewsQuery as We, useProductReviewsSuspenseQuery as Ge, useRecordAppUninstallationMutation as Ke, useRemoveFromCartMutation as qe, useSearchSuggestionsLazyQuery as Je, useSearchSuggestionsQuery as Ye, useSearchSuggestionsSuspenseQuery as Xe, useStoreProductDetailsLazyQuery as Ze, useStoreProductDetailsQuery as Qe, useStoreProductDetailsSuspenseQuery as $e, useSubmissionStatusUpdatedSubscription as et, useTrendingSearchesLazyQuery as tt, useTrendingSearchesQuery as nt, useTrendingSearchesSuspenseQuery as rt, useUpdateCartItemMutation as it, useUpdateReviewMutation as at, useUserReviewForProductLazyQuery as ot, useUserReviewForProductQuery as st, useUserReviewForProductSuspenseQuery as ct, useWorkspaceStoreOrdersLazyQuery as lt, useWorkspaceStoreOrdersQuery as ut, useWorkspaceStoreOrdersSuspenseQuery as dt } from "./generated/global-operations.js";
5
5
  import { useBackendCart as ft } from "./hooks/useBackendCart.js";
6
6
  import { useCart as pt } from "./hooks/useCart.js";
7
- import { calculateCartTotals as mt, debounce as ht, formatFileSize as gt, formatNumber as _t, formatPrice as vt, generateCartItemId as yt, getDaysUntilExpiry as bt, getItemTypeName as xt, getPricingModelName as St, getRatingStars as Ct, getStatusColor as wt, isLicenseExpiringSoon as Tt, maskLicenseKey as Et, truncate as Dt, validateLicenseKey as Ot } from "./utils/index.js";
8
- import { useBrowseStore as kt, useBrowseStoreWithContext as At, useCategories as jt, useCheckEntitlement as Mt, useCreateReview as Nt, useDeleteReview as Pt, useDeveloperEarnings as Ft, useFeaturedProducts as It, useFilterOptions as Lt, useHomeGroupedProducts as Rt, useLazyBrowseStore as zt, useLazySearchSuggestions as Bt, useLazyStoreProductDetails as Vt, useMarkReviewHelpful as Ht, useMyEntitlements as Ut, useMyPublishedProducts as Wt, useProductReviews as Gt, useSearchSuggestions as Kt, useStoreProductDetails as qt, useTrendingSearches as Jt, useUpdateReview as Yt, useUserReviewForProduct as Xt, useWorkspaceStoreOrders as Zt } from "./hooks/useStoreGraphQL.js";
9
- import { StoreRoot as Qt } from "./StoreRoot.js";
10
- import { StoreAdminRoot as $t } from "./StoreAdminRoot.js";
11
- import { useProductSearch as en } from "./hooks/useProductSearch.js";
7
+ import { StoreRoot as mt } from "./StoreRoot.js";
8
+ import { StoreAdminRoot as ht } from "./StoreAdminRoot.js";
9
+ import { useProductSearch as gt } from "./hooks/useProductSearch.js";
10
+ import { calculateCartTotals as _t, debounce as vt, formatFileSize as yt, formatNumber as bt, formatPrice as xt, generateCartItemId as St, getDaysUntilExpiry as Ct, getItemTypeName as wt, getPricingModelName as Tt, getRatingStars as Et, getStatusColor as Dt, isLicenseExpiringSoon as Ot, maskLicenseKey as kt, truncate as At, validateLicenseKey as jt } from "./utils/index.js";
11
+ import { useBrowseStore as Mt, useBrowseStoreWithContext as Nt, useCategories as Pt, useCheckEntitlement as Ft, useCreateReview as It, useDeleteReview as Lt, useDeveloperEarnings as Rt, useFeaturedProducts as zt, useFilterOptions as Bt, useHomeGroupedProducts as Vt, useLazyBrowseStore as Ht, useLazySearchSuggestions as Ut, useLazyStoreProductDetails as Wt, useMarkReviewHelpful as Gt, useMyEntitlements as Kt, useMyPublishedProducts as qt, useProductReviews as Jt, useSearchSuggestions as Yt, useStoreProductDetails as Xt, useTrendingSearches as Zt, useUpdateReview as Qt, useUserReviewForProduct as $t, useWorkspaceStoreOrders as en } from "./hooks/useStoreGraphQL.js";
12
12
  import { enTranslations as tn } from "./translations/en.js";
13
- export { i as AddToCartDocument, a as BrowseStoreDocument, o as CategoriesDocument, s as CheckEntitlementDocument, c as CheckoutDocument, l as ClearCartDocument, u as CreateProductForPublisherDocument, d as CreateReviewDocument, f as CreateStoreOrderDocument, p as DeleteReviewDocument, m as DeveloperEarningsDocument, h as FeaturedProductsDocument, g as FilterOptionsDocument, _ as GetCartDocument, v as GetMyOrdersDocument, y as GetMyStoreInstallationsDocument, b as GetProductDocument, x as GetProductsDocument, S as GetStoreAppInstallationDocument, C as HomeGroupedProductsDocument, w as InstallationStatusUpdatedDocument, T as LicenseStatusUpdatedDocument, E as MarkReviewHelpfulDocument, D as MyEntitlementsDocument, O as MyPublishedProductsDocument, k as OrderStatusUpdatedDocument, A as ProductReviewsDocument, j as RecordAppUninstallationDocument, M as RemoveFromCartDocument, t as STORE_PERMISSIONS, N as SearchSuggestionsDocument, $t as StoreAdminRoot, P as StoreProductDetailsDocument, Qt as StoreRoot, F as SubmissionStatusUpdatedDocument, I as TrendingSearchesDocument, L as UpdateCartItemDocument, R as UpdateReviewDocument, z as UserReviewForProductDocument, B as WorkspaceStoreOrdersDocument, mt as calculateCartTotals, ht as debounce, gt as formatFileSize, _t as formatNumber, vt as formatPrice, yt as generateCartItemId, bt as getDaysUntilExpiry, xt as getItemTypeName, St as getPricingModelName, Ct as getRatingStars, wt as getStatusColor, Tt as isLicenseExpiringSoon, Et as maskLicenseKey, tn as storeTranslations, Dt as truncate, V as useAddToCartMutation, ft as useBackendCart, kt as useBrowseStore, H as useBrowseStoreLazyQuery, U as useBrowseStoreQuery, W as useBrowseStoreSuspenseQuery, At as useBrowseStoreWithContext, pt as useCart, jt as useCategories, G as useCategoriesLazyQuery, K as useCategoriesQuery, q as useCategoriesSuspenseQuery, Mt as useCheckEntitlement, J as useCheckEntitlementLazyQuery, Y as useCheckEntitlementQuery, X as useCheckEntitlementSuspenseQuery, Z as useCheckoutMutation, Q as useClearCartMutation, $ as useCreateProductForPublisherMutation, Nt as useCreateReview, ee as useCreateReviewMutation, te as useCreateStoreOrderMutation, Pt as useDeleteReview, ne as useDeleteReviewMutation, Ft as useDeveloperEarnings, re as useDeveloperEarningsLazyQuery, ie as useDeveloperEarningsQuery, ae as useDeveloperEarningsSuspenseQuery, It as useFeaturedProducts, oe as useFeaturedProductsLazyQuery, se as useFeaturedProductsQuery, ce as useFeaturedProductsSuspenseQuery, Lt as useFilterOptions, le as useFilterOptionsLazyQuery, ue as useFilterOptionsQuery, de as useFilterOptionsSuspenseQuery, fe as useGetCartLazyQuery, pe as useGetCartQuery, me as useGetCartSuspenseQuery, he as useGetMyOrdersLazyQuery, ge as useGetMyOrdersQuery, _e as useGetMyOrdersSuspenseQuery, ve as useGetMyStoreInstallationsLazyQuery, ye as useGetMyStoreInstallationsQuery, be as useGetMyStoreInstallationsSuspenseQuery, xe as useGetProductLazyQuery, Se as useGetProductQuery, Ce as useGetProductSuspenseQuery, we as useGetProductsLazyQuery, Te as useGetProductsQuery, Ee as useGetProductsSuspenseQuery, De as useGetStoreAppInstallationLazyQuery, Oe as useGetStoreAppInstallationQuery, ke as useGetStoreAppInstallationSuspenseQuery, Rt as useHomeGroupedProducts, Ae as useHomeGroupedProductsLazyQuery, je as useHomeGroupedProductsQuery, Me as useHomeGroupedProductsSuspenseQuery, Ne as useInstallationStatusUpdatedSubscription, zt as useLazyBrowseStore, Bt as useLazySearchSuggestions, Vt as useLazyStoreProductDetails, Pe as useLicenseStatusUpdatedSubscription, Ht as useMarkReviewHelpful, Fe as useMarkReviewHelpfulMutation, Ut as useMyEntitlements, Ie as useMyEntitlementsLazyQuery, Le as useMyEntitlementsQuery, Re as useMyEntitlementsSuspenseQuery, Wt as useMyPublishedProducts, ze as useMyPublishedProductsLazyQuery, Be as useMyPublishedProductsQuery, Ve as useMyPublishedProductsSuspenseQuery, He as useOrderStatusUpdatedSubscription, Gt as useProductReviews, Ue as useProductReviewsLazyQuery, We as useProductReviewsQuery, Ge as useProductReviewsSuspenseQuery, en as useProductSearch, Ke as useRecordAppUninstallationMutation, qe as useRemoveFromCartMutation, Kt as useSearchSuggestions, Je as useSearchSuggestionsLazyQuery, Ye as useSearchSuggestionsQuery, Xe as useSearchSuggestionsSuspenseQuery, e as useStore, n as useStorePermissions, qt as useStoreProductDetails, Ze as useStoreProductDetailsLazyQuery, Qe as useStoreProductDetailsQuery, $e as useStoreProductDetailsSuspenseQuery, r as useStoreStore, et as useSubmissionStatusUpdatedSubscription, Jt as useTrendingSearches, tt as useTrendingSearchesLazyQuery, nt as useTrendingSearchesQuery, rt as useTrendingSearchesSuspenseQuery, it as useUpdateCartItemMutation, Yt as useUpdateReview, at as useUpdateReviewMutation, Xt as useUserReviewForProduct, ot as useUserReviewForProductLazyQuery, st as useUserReviewForProductQuery, ct as useUserReviewForProductSuspenseQuery, Zt as useWorkspaceStoreOrders, lt as useWorkspaceStoreOrdersLazyQuery, ut as useWorkspaceStoreOrdersQuery, dt as useWorkspaceStoreOrdersSuspenseQuery, Ot as validateLicenseKey };
13
+ export { i as AddToCartDocument, a as BrowseStoreDocument, o as CategoriesDocument, s as CheckEntitlementDocument, c as CheckoutDocument, l as ClearCartDocument, u as CreateProductForPublisherDocument, d as CreateReviewDocument, f as CreateStoreOrderDocument, p as DeleteReviewDocument, m as DeveloperEarningsDocument, h as FeaturedProductsDocument, g as FilterOptionsDocument, _ as GetCartDocument, v as GetMyOrdersDocument, y as GetMyStoreInstallationsDocument, b as GetProductDocument, x as GetProductsDocument, S as GetStoreAppInstallationDocument, C as HomeGroupedProductsDocument, w as InstallationStatusUpdatedDocument, T as LicenseStatusUpdatedDocument, E as MarkReviewHelpfulDocument, D as MyEntitlementsDocument, O as MyPublishedProductsDocument, k as OrderStatusUpdatedDocument, A as ProductReviewsDocument, j as RecordAppUninstallationDocument, M as RemoveFromCartDocument, t as STORE_PERMISSIONS, N as SearchSuggestionsDocument, ht as StoreAdminRoot, P as StoreProductDetailsDocument, mt as StoreRoot, F as SubmissionStatusUpdatedDocument, I as TrendingSearchesDocument, L as UpdateCartItemDocument, R as UpdateReviewDocument, z as UserReviewForProductDocument, B as WorkspaceStoreOrdersDocument, _t as calculateCartTotals, vt as debounce, yt as formatFileSize, bt as formatNumber, xt as formatPrice, St as generateCartItemId, Ct as getDaysUntilExpiry, wt as getItemTypeName, Tt as getPricingModelName, Et as getRatingStars, Dt as getStatusColor, Ot as isLicenseExpiringSoon, kt as maskLicenseKey, tn as storeTranslations, At as truncate, V as useAddToCartMutation, ft as useBackendCart, Mt as useBrowseStore, H as useBrowseStoreLazyQuery, U as useBrowseStoreQuery, W as useBrowseStoreSuspenseQuery, Nt as useBrowseStoreWithContext, pt as useCart, Pt as useCategories, G as useCategoriesLazyQuery, K as useCategoriesQuery, q as useCategoriesSuspenseQuery, Ft as useCheckEntitlement, J as useCheckEntitlementLazyQuery, Y as useCheckEntitlementQuery, X as useCheckEntitlementSuspenseQuery, Z as useCheckoutMutation, Q as useClearCartMutation, $ as useCreateProductForPublisherMutation, It as useCreateReview, ee as useCreateReviewMutation, te as useCreateStoreOrderMutation, Lt as useDeleteReview, ne as useDeleteReviewMutation, Rt as useDeveloperEarnings, re as useDeveloperEarningsLazyQuery, ie as useDeveloperEarningsQuery, ae as useDeveloperEarningsSuspenseQuery, zt as useFeaturedProducts, oe as useFeaturedProductsLazyQuery, se as useFeaturedProductsQuery, ce as useFeaturedProductsSuspenseQuery, Bt as useFilterOptions, le as useFilterOptionsLazyQuery, ue as useFilterOptionsQuery, de as useFilterOptionsSuspenseQuery, fe as useGetCartLazyQuery, pe as useGetCartQuery, me as useGetCartSuspenseQuery, he as useGetMyOrdersLazyQuery, ge as useGetMyOrdersQuery, _e as useGetMyOrdersSuspenseQuery, ve as useGetMyStoreInstallationsLazyQuery, ye as useGetMyStoreInstallationsQuery, be as useGetMyStoreInstallationsSuspenseQuery, xe as useGetProductLazyQuery, Se as useGetProductQuery, Ce as useGetProductSuspenseQuery, we as useGetProductsLazyQuery, Te as useGetProductsQuery, Ee as useGetProductsSuspenseQuery, De as useGetStoreAppInstallationLazyQuery, Oe as useGetStoreAppInstallationQuery, ke as useGetStoreAppInstallationSuspenseQuery, Vt as useHomeGroupedProducts, Ae as useHomeGroupedProductsLazyQuery, je as useHomeGroupedProductsQuery, Me as useHomeGroupedProductsSuspenseQuery, Ne as useInstallationStatusUpdatedSubscription, Ht as useLazyBrowseStore, Ut as useLazySearchSuggestions, Wt as useLazyStoreProductDetails, Pe as useLicenseStatusUpdatedSubscription, Gt as useMarkReviewHelpful, Fe as useMarkReviewHelpfulMutation, Kt as useMyEntitlements, Ie as useMyEntitlementsLazyQuery, Le as useMyEntitlementsQuery, Re as useMyEntitlementsSuspenseQuery, qt as useMyPublishedProducts, ze as useMyPublishedProductsLazyQuery, Be as useMyPublishedProductsQuery, Ve as useMyPublishedProductsSuspenseQuery, He as useOrderStatusUpdatedSubscription, Jt as useProductReviews, Ue as useProductReviewsLazyQuery, We as useProductReviewsQuery, Ge as useProductReviewsSuspenseQuery, gt as useProductSearch, Ke as useRecordAppUninstallationMutation, qe as useRemoveFromCartMutation, Yt as useSearchSuggestions, Je as useSearchSuggestionsLazyQuery, Ye as useSearchSuggestionsQuery, Xe as useSearchSuggestionsSuspenseQuery, e as useStore, n as useStorePermissions, Xt as useStoreProductDetails, Ze as useStoreProductDetailsLazyQuery, Qe as useStoreProductDetailsQuery, $e as useStoreProductDetailsSuspenseQuery, r as useStoreStore, et as useSubmissionStatusUpdatedSubscription, Zt as useTrendingSearches, tt as useTrendingSearchesLazyQuery, nt as useTrendingSearchesQuery, rt as useTrendingSearchesSuspenseQuery, it as useUpdateCartItemMutation, Qt as useUpdateReview, at as useUpdateReviewMutation, $t as useUserReviewForProduct, ot as useUserReviewForProductLazyQuery, st as useUserReviewForProductQuery, ct as useUserReviewForProductSuspenseQuery, en as useWorkspaceStoreOrders, lt as useWorkspaceStoreOrdersLazyQuery, ut as useWorkspaceStoreOrdersQuery, dt as useWorkspaceStoreOrdersSuspenseQuery, jt as validateLicenseKey };
@@ -6,12 +6,12 @@ import { useI18n as i } from "@burdenoff/fe-libs/shared/providers/shell/I18nProv
6
6
  import { ArrowLeft as a, Loader2 as o, Minus as s, Plus as c, ShoppingBag as l, ShoppingCart as u, Tag as d, Trash2 as f, Zap as p } from "lucide-react";
7
7
  import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
8
8
  import { useNavigate as _ } from "react-router-dom";
9
- import { useQuotaErrorToast as v } from "@burdenoff/fe-libs/shared/hooks";
9
+ import { isQuotaExhaustedError as v } from "@burdenoff/fe-libs/shared/utils";
10
10
  import { useEventBus as y } from "@burdenoff/fe-libs/shared/events";
11
- import { isQuotaExhaustedError as b } from "@burdenoff/fe-libs/shared/utils";
11
+ import { useQuotaErrorToast as b } from "@burdenoff/fe-libs/shared/hooks";
12
12
  //#region src/pages/CartPage.tsx
13
13
  var x = () => {
14
- let x = _(), { basePath: S } = e(), { cartItems: C, itemCount: w, total: T, updateQuantity: E, removeProduct: D, clearCart: O, createOrder: k } = t(), [A, j] = r(!1), [M, N] = r(null), { t: P } = i(), F = y(), { report: I } = v(), L = async () => {
14
+ let x = _(), { basePath: S } = e(), { cartItems: C, itemCount: w, total: T, updateQuantity: E, removeProduct: D, clearCart: O, createOrder: k } = t(), [A, j] = r(!1), [M, N] = r(null), { t: P } = i(), F = y(), { report: I } = b(), L = async () => {
15
15
  try {
16
16
  j(!0), N(null), F.emit("store.cart.checkout_started", {
17
17
  cartId: "",
@@ -38,7 +38,7 @@ var x = () => {
38
38
  itemCount: w
39
39
  }), O().catch(() => {}), x(`/billing/checkout/store/${e.id}`)) : (N(P("pages.cart.failedToCreate", { defaultValue: "Failed to create order. Please try again." })), j(!1));
40
40
  } catch (e) {
41
- if (console.error("Checkout error:", e), b(e)) {
41
+ if (console.error("Checkout error:", e), v(e)) {
42
42
  I(e), j(!1);
43
43
  return;
44
44
  }
@@ -1,7 +1,7 @@
1
1
  import { useStore as e } from "../providers/StoreProvider.js";
2
2
  import { useInstallationStatusUpdatedSubscription as t } from "../generated/global-operations.js";
3
- import { StoreInstallationStatus as n } from "../generated/global-types.js";
4
- import { useInstallations as r } from "../hooks/useInstallations.js";
3
+ import { useInstallations as n } from "../hooks/useInstallations.js";
4
+ import { StoreInstallationStatus as r } from "../generated/global-types.js";
5
5
  import { useMemo as i, useState as a } from "react";
6
6
  import { useI18n as o } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
7
7
  import { AlertCircle as s, Loader2 as c, Package as l, Plus as u, RefreshCw as d, Trash2 as f } from "lucide-react";
@@ -15,30 +15,30 @@ var g = [
15
15
  },
16
16
  {
17
17
  label: "Active",
18
- value: n.Active
18
+ value: r.Active
19
19
  },
20
20
  {
21
21
  label: "Inactive",
22
- value: n.Inactive
22
+ value: r.Inactive
23
23
  },
24
24
  {
25
25
  label: "Pending",
26
- value: n.Pending
26
+ value: r.Pending
27
27
  },
28
28
  {
29
29
  label: "Installing",
30
- value: n.Installing
30
+ value: r.Installing
31
31
  },
32
32
  {
33
33
  label: "Failed",
34
- value: n.Failed
34
+ value: r.Failed
35
35
  },
36
36
  {
37
37
  label: "Uninstalled",
38
- value: n.Uninstalled
38
+ value: r.Uninstalled
39
39
  }
40
- ], _ = (e) => e === n.Active ? "bg-status-success-bg-subtle text-status-success-text" : e === n.Pending || e === n.Installing || e === n.Inactive ? "bg-status-warning-bg-subtle text-status-warning-text" : e === n.Failed ? "bg-status-error-bg-subtle text-status-error-text" : "bg-bg-sunken text-text-muted", v = () => {
41
- let v = h(), { basePath: y, workspaceId: b } = e(), { t: x } = o(), [S, C] = a("all"), [w, T] = a(null), [E, D] = a(null), { installations: O, totalCount: k, hasMore: A, loading: j, error: M, uninstall: N, uninstallingIds: P, refetch: F, loadMore: I } = r({ filter: i(() => S === "all" ? void 0 : { status: S }, [S]) });
40
+ ], _ = (e) => e === r.Active ? "bg-status-success-bg-subtle text-status-success-text" : e === r.Pending || e === r.Installing || e === r.Inactive ? "bg-status-warning-bg-subtle text-status-warning-text" : e === r.Failed ? "bg-status-error-bg-subtle text-status-error-text" : "bg-bg-sunken text-text-muted", v = () => {
41
+ let v = h(), { basePath: y, workspaceId: b } = e(), { t: x } = o(), [S, C] = a("all"), [w, T] = a(null), [E, D] = a(null), { installations: O, totalCount: k, hasMore: A, loading: j, error: M, uninstall: N, uninstallingIds: P, refetch: F, loadMore: I } = n({ filter: i(() => S === "all" ? void 0 : { status: S }, [S]) });
42
42
  t({
43
43
  variables: { workspaceId: b ?? "" },
44
44
  skip: !b,
@@ -204,7 +204,7 @@ var g = [
204
204
  className: "cursor-pointer rounded-lg border border-border-default px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
205
205
  children: "View Product"
206
206
  }),
207
- e.status !== n.Uninstalled && /* @__PURE__ */ m("button", {
207
+ e.status !== r.Uninstalled && /* @__PURE__ */ m("button", {
208
208
  onClick: () => D(e),
209
209
  disabled: t,
210
210
  className: "cursor-pointer inline-flex items-center gap-1.5 rounded-lg border border-status-error-border px-3 py-2 text-sm font-medium text-status-error-text hover:bg-status-error-bg-subtle disabled:opacity-60",