@burdenoff/microfe-store 2026.831.1 → 2026.912.1
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.
- package/dist/generated/global-operations.d.ts +7 -0
- package/dist/generated/global-operations.js +6 -0
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/hooks/useOrders.d.ts +16 -0
- package/dist/hooks/useOrders.js.map +1 -1
- package/dist/pages/OrdersPage.js +213 -201
- package/dist/pages/OrdersPage.js.map +1 -1
- package/dist/providers/StoreProvider.js +35 -35
- package/dist/providers/StoreProvider.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,22 @@ interface StoreOrder {
|
|
|
5
5
|
status: string;
|
|
6
6
|
total: number;
|
|
7
7
|
currency: string;
|
|
8
|
+
/**
|
|
9
|
+
* The billing Transaction actually charged for this order, when one
|
|
10
|
+
* exists (absent for e.g. a pending order with no payment attempt yet).
|
|
11
|
+
* `amount`/`currency` here are the gateway's own bookkeeping (often the
|
|
12
|
+
* pre-tax subtotal); the real subtotal/tax/total actually charged is in
|
|
13
|
+
* `metadata` (`subtotal`/`taxAmount`/`total`) — see BOFF-7192: an INR
|
|
14
|
+
* Razorpay payment with GST was showing as USD with $0.00 tax because
|
|
15
|
+
* this order-level total/currency are the order's OWN catalog-native
|
|
16
|
+
* bookkeeping, not what was actually charged.
|
|
17
|
+
*/
|
|
18
|
+
transaction?: {
|
|
19
|
+
id: string;
|
|
20
|
+
currency: string;
|
|
21
|
+
amount: number;
|
|
22
|
+
metadata?: Record<string, unknown> | null;
|
|
23
|
+
} | null;
|
|
8
24
|
lineItems: Array<{
|
|
9
25
|
productId: string;
|
|
10
26
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOrders.js","names":[],"sources":["../../src/hooks/useOrders.ts"],"sourcesContent":["/**\n * Orders Hook\n *\n * Provides order operations that interact with the backend store service.\n * All order data is fetched from the backend via GraphQL.\n */\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport { GetMyOrdersDocument } from '../generated/global-operations';\nimport type { OrderStatus } from '../generated/global-types';\nimport { useStoreGraphQLWithContext } from './useStoreGraphQLWithContext';\n\nconst DEFAULT_PAGE_SIZE = 20;\n\n// Local type definition until schema is fully generated\ninterface StoreOrder {\n id: string;\n status: string;\n total: number;\n currency: string;\n lineItems: Array<{\n productId: string;\n name: string;\n quantity: number;\n unitPrice: number;\n subtotal: number;\n itemType?: string;\n pricingModel?: string;\n productType?: string;\n productIcon?: string;\n variantId?: string;\n variantName?: string;\n version?: string;\n }>;\n createdAt: string;\n updatedAt: string;\n fulfillment?: {\n status?: string | null;\n trackingNumber?: string | null;\n trackingUrl?: string | null;\n carrier?: string | null;\n estimatedDeliveryDate?: string | null;\n } | null;\n}\n\n/**\n * Hook for fetching and managing orders with offset-based pagination.\n */\nexport function useOrders(options?: { limit?: number; offset?: number; status?: OrderStatus }) {\n const { query: queryWithContext, hasOrganizationContext } = useStoreGraphQLWithContext();\n const globalClient = useApolloClient();\n\n const limit = options?.limit ?? DEFAULT_PAGE_SIZE;\n const [offset, setOffset] = useState(options?.offset ?? 0);\n const [status] = useState<OrderStatus | undefined>(options?.status);\n\n const [allOrders, setAllOrders] = useState<StoreOrder[]>([]);\n const [hasMore, setHasMore] = useState(false);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchOrders = useCallback(\n async (fetchOffset: number = 0, append = false) => {\n setLoading(true);\n setError(null);\n try {\n const variables = { limit, offset: fetchOffset, status: status ?? null };\n let result;\n\n if (hasOrganizationContext) {\n result = (await queryWithContext({\n query: GetMyOrdersDocument,\n variables,\n fetchPolicy: 'network-only',\n })) as { data?: { myOrders: StoreOrder[] } };\n } else {\n result = await globalClient.query<{ myOrders: StoreOrder[] }>({\n query: GetMyOrdersDocument,\n variables,\n fetchPolicy: 'network-only',\n });\n }\n\n const fetched = (result.data?.myOrders ?? []).map((order) => {\n let parsedLineItems: StoreOrder['lineItems'] = [];\n if (order.lineItems) {\n if (typeof order.lineItems === 'string') {\n try {\n parsedLineItems = JSON.parse(order.lineItems);\n } catch (parseErr) {\n console.error('Failed to parse order lineItems JSON:', parseErr);\n parsedLineItems = [];\n }\n } else {\n parsedLineItems = order.lineItems;\n }\n }\n return { ...order, lineItems: parsedLineItems };\n });\n\n if (append) {\n setAllOrders((prev) => [...prev, ...fetched]);\n } else {\n setAllOrders(fetched);\n }\n setHasMore(fetched.length === limit);\n setOffset(fetchOffset);\n } catch (err) {\n setError(err as Error);\n console.error('Failed to fetch orders:', err);\n } finally {\n setLoading(false);\n }\n },\n [queryWithContext, globalClient, hasOrganizationContext, limit, status]\n );\n\n useEffect(() => {\n fetchOrders(0);\n }, [fetchOrders]);\n\n const loadMore = useCallback(() => {\n if (!hasMore || loading) return;\n fetchOrders(offset + limit, true);\n }, [fetchOrders, hasMore, loading, offset, limit]);\n\n return {\n orders: allOrders,\n hasMore,\n loading,\n error,\n refetchOrders: () => fetchOrders(0),\n loadMore,\n };\n}\n"],"mappings":";;;;;AAaA,IAAM,IAAoB;
|
|
1
|
+
{"version":3,"file":"useOrders.js","names":[],"sources":["../../src/hooks/useOrders.ts"],"sourcesContent":["/**\n * Orders Hook\n *\n * Provides order operations that interact with the backend store service.\n * All order data is fetched from the backend via GraphQL.\n */\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport { GetMyOrdersDocument } from '../generated/global-operations';\nimport type { OrderStatus } from '../generated/global-types';\nimport { useStoreGraphQLWithContext } from './useStoreGraphQLWithContext';\n\nconst DEFAULT_PAGE_SIZE = 20;\n\n// Local type definition until schema is fully generated\ninterface StoreOrder {\n id: string;\n status: string;\n total: number;\n currency: string;\n /**\n * The billing Transaction actually charged for this order, when one\n * exists (absent for e.g. a pending order with no payment attempt yet).\n * `amount`/`currency` here are the gateway's own bookkeeping (often the\n * pre-tax subtotal); the real subtotal/tax/total actually charged is in\n * `metadata` (`subtotal`/`taxAmount`/`total`) — see BOFF-7192: an INR\n * Razorpay payment with GST was showing as USD with $0.00 tax because\n * this order-level total/currency are the order's OWN catalog-native\n * bookkeeping, not what was actually charged.\n */\n transaction?: {\n id: string;\n currency: string;\n amount: number;\n metadata?: Record<string, unknown> | null;\n } | null;\n lineItems: Array<{\n productId: string;\n name: string;\n quantity: number;\n unitPrice: number;\n subtotal: number;\n itemType?: string;\n pricingModel?: string;\n productType?: string;\n productIcon?: string;\n variantId?: string;\n variantName?: string;\n version?: string;\n }>;\n createdAt: string;\n updatedAt: string;\n fulfillment?: {\n status?: string | null;\n trackingNumber?: string | null;\n trackingUrl?: string | null;\n carrier?: string | null;\n estimatedDeliveryDate?: string | null;\n } | null;\n}\n\n/**\n * Hook for fetching and managing orders with offset-based pagination.\n */\nexport function useOrders(options?: { limit?: number; offset?: number; status?: OrderStatus }) {\n const { query: queryWithContext, hasOrganizationContext } = useStoreGraphQLWithContext();\n const globalClient = useApolloClient();\n\n const limit = options?.limit ?? DEFAULT_PAGE_SIZE;\n const [offset, setOffset] = useState(options?.offset ?? 0);\n const [status] = useState<OrderStatus | undefined>(options?.status);\n\n const [allOrders, setAllOrders] = useState<StoreOrder[]>([]);\n const [hasMore, setHasMore] = useState(false);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchOrders = useCallback(\n async (fetchOffset: number = 0, append = false) => {\n setLoading(true);\n setError(null);\n try {\n const variables = { limit, offset: fetchOffset, status: status ?? null };\n let result;\n\n if (hasOrganizationContext) {\n result = (await queryWithContext({\n query: GetMyOrdersDocument,\n variables,\n fetchPolicy: 'network-only',\n })) as { data?: { myOrders: StoreOrder[] } };\n } else {\n result = await globalClient.query<{ myOrders: StoreOrder[] }>({\n query: GetMyOrdersDocument,\n variables,\n fetchPolicy: 'network-only',\n });\n }\n\n const fetched = (result.data?.myOrders ?? []).map((order) => {\n let parsedLineItems: StoreOrder['lineItems'] = [];\n if (order.lineItems) {\n if (typeof order.lineItems === 'string') {\n try {\n parsedLineItems = JSON.parse(order.lineItems);\n } catch (parseErr) {\n console.error('Failed to parse order lineItems JSON:', parseErr);\n parsedLineItems = [];\n }\n } else {\n parsedLineItems = order.lineItems;\n }\n }\n return { ...order, lineItems: parsedLineItems };\n });\n\n if (append) {\n setAllOrders((prev) => [...prev, ...fetched]);\n } else {\n setAllOrders(fetched);\n }\n setHasMore(fetched.length === limit);\n setOffset(fetchOffset);\n } catch (err) {\n setError(err as Error);\n console.error('Failed to fetch orders:', err);\n } finally {\n setLoading(false);\n }\n },\n [queryWithContext, globalClient, hasOrganizationContext, limit, status]\n );\n\n useEffect(() => {\n fetchOrders(0);\n }, [fetchOrders]);\n\n const loadMore = useCallback(() => {\n if (!hasMore || loading) return;\n fetchOrders(offset + limit, true);\n }, [fetchOrders, hasMore, loading, offset, limit]);\n\n return {\n orders: allOrders,\n hasMore,\n loading,\n error,\n refetchOrders: () => fetchOrders(0),\n loadMore,\n };\n}\n"],"mappings":";;;;;AAaA,IAAM,IAAoB;AAoD1B,SAAgB,EAAU,GAAqE;CAC7F,IAAM,EAAE,OAAO,GAAkB,8BAA2B,GAA4B,EAClF,IAAe,GAAiB,EAEhC,IAAQ,GAAS,SAAS,GAC1B,CAAC,GAAQ,KAAa,EAAS,GAAS,UAAU,EAAE,EACpD,CAAC,KAAU,EAAkC,GAAS,OAAO,EAE7D,CAAC,GAAW,KAAgB,EAAuB,EAAE,CAAC,EACtD,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAuB,KAAK,EAEhD,IAAc,EAClB,OAAO,IAAsB,GAAG,IAAS,OAAU;AAEjD,EADA,EAAW,GAAK,EAChB,EAAS,KAAK;AACd,MAAI;GACF,IAAM,IAAY;IAAE;IAAO,QAAQ;IAAa,QAAQ,KAAU;IAAM,EACpE;AAEJ,GAOE,IAPE,IACQ,MAAM,EAAiB;IAC/B,OAAO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