Conversation
- Introduced new inventory routes including overview, orders, and statistics. - Updated the app sidebar to include an inventory section with links to the new routes. - Enhanced the route tree to accommodate the new inventory structure. - Exported inventory schema from the database schema for integration. - Removed the "filename-case" lint rule for cleaner linting configuration.
- Added @base-ui/react and @base-ui/utils to dependencies in package.json and bun.lock for enhanced UI components. - Removed the "react-perf/jsx-no-jsx-as-prop" rule from .oxlintrc.json to simplify linting rules. - Made minor adjustments to button, input, and textarea components for improved styling and accessibility.
- Added functionality to manage order reference prefixes, including creation, updating, and deletion. - Updated inventory-related queries to support pagination and filtering by archived status. - Improved product and order handling by integrating archived state checks. - Enhanced the order creation process to allow for reference prefixes, ensuring unique order references. - Updated various components and functions to accommodate new inventory schema changes.
…omponents - Upgraded @tanstack/react-router and related packages to version 1.157.3 for enhanced routing capabilities. - Added a new settings route for inventory management, allowing users to configure order reference prefixes. - Integrated a combobox for selecting order reference prefixes in the OrderCart component, improving user experience. - Enhanced the TagSelector and ProductForm components with combobox functionality for better tag and label management. - Implemented date range selection in orders and stats routes for improved filtering options. - Updated various components to support new inventory features and improve overall accessibility.
…uct selection - Introduced a new state for managing selected product details in the OrderCart component, streamlining the item addition process. - Updated the addItem function to utilize the new product state, ensuring accurate item handling. - Enhanced the Combobox in OrderCart for product selection, including improved item display with stock information. - Added itemToStringLabel functionality in ProductForm's Combobox for better label representation, improving user experience.
- Added functionality for creating, updating, and deleting inventory tags and production cost labels. - Integrated new UI components for managing tags and labels, including forms and tables for display. - Updated query handling to ensure data consistency for tags and labels in the inventory settings. - Improved user experience with toast notifications for successful operations on tags and labels.
…mproved data handling - Replaced useQuery with useSuspenseQuery in OrderCart, OrderDetail, ProductForm, and settings components for better loading state management. - Updated query handling in routes to ensure data is available before rendering, enhancing user experience. - Improved loader functions in various routes to utilize ensureQueryData for more efficient data fetching.
…iguration - Refactored state initialization in ProductForm to use existing product data, enhancing edit functionality. - Updated ESLint configuration to enforce strict equality checks while allowing null comparisons.
…gement - Replaced manual state management with useForm for handling form inputs in ProductForm, enhancing code readability and maintainability. - Introduced default values for form fields based on existing product data, improving the edit functionality. - Updated tag and production cost management to utilize form state, streamlining the addition and removal of tags and costs. - Enhanced user experience with improved form submission handling and validation feedback.
- Deleted the ProductForm component from the inventory section, streamlining the codebase. - This change may be part of a larger refactor or replacement with a new implementation.
…d simplifying tag/label management - Removed the use of inline mutations for creating tags and labels, enhancing code clarity and maintainability. - Simplified the ProductForm component by directly managing tag and production cost inputs through form state. - Updated the ProductFormTagIds and ProductFormProductionCosts components to reflect these changes, improving user experience with cleaner UI interactions. - Deleted the now-unnecessary useProductInlineMutations file, further reducing code complexity.
- Added a new linting rule to enforce the use of non-deprecated TypeScript features. - Simplified the ProductForm component by removing unnecessary variable assignments and improving error handling in form submission. - Updated the product form schema to utilize UUID validation for tag IDs, enhancing data integrity. - Refactored date validation in inventory functions to use ISO datetime format for consistency.
…duction costs - Updated ProductFormProductionCosts to display labels with color indicators for better visual context. - Enhanced ProductFormTagIds to apply background colors to tags based on their associated colors, improving UI clarity. - Modified inventory route to include tags and total production costs in product listings, enriching data presentation. - Implemented mutation logic for archiving products, providing users with a streamlined way to manage product visibility.
…agement and UI components - Updated OrderCart to use a more structured state for prefix and product selection, improving clarity and maintainability. - Refactored Combobox components in OrderCart, ProductFormProductionCosts, and ProductFormTagIds to utilize item objects directly, enhancing user experience with better item representation. - Improved handling of selected tags and labels in ProductForm components, streamlining the addition and removal process. - Enhanced the TagSelector component for better tag selection and interaction, improving overall usability.
- Updated ComboboxList in OrderCart, ProductFormProductionCosts, ProductFormTagIds, and TagSelector to support generic item types, improving type safety and flexibility. - Introduced a new ComboboxListProps interface to streamline the handling of item types across various components, enhancing code maintainability and readability.
- Updated OrderCart to conditionally include the newly added product in the items list, enhancing user experience during product selection. - Refactored TagSelector to utilize a generic type for the Combobox, improving type safety and consistency in item representation.
- Updated TagSelector to explicitly define the value type for the Combobox as TimeEntryTag | null, enhancing type safety and clarity in tag selection.
…eters - Updated ComboboxList in OrderCart, ProductFormProductionCosts, ProductFormTagIds, and TagSelector to remove explicit type parameters, simplifying the component interface and improving code readability.
- Refactored OrderCart, ProductFormProductionCosts, ProductFormTagIds, and TagSelector to utilize a new createCombobox function, enhancing code consistency and reducing redundancy. - Updated components to leverage generic types for improved type safety and maintainability in item handling.
- Upgraded @tanstack/react-router, @tanstack/react-router-ssr-query, and @tanstack/react-start to version 1.157.9 for improved functionality and bug fixes. - Updated corresponding devtools and router plugin dependencies to maintain compatibility. - Removed outdated inventory improvement plans to clean up the project structure.
- Moved radius-related CSS variables from the code block to the :root selector, enhancing global accessibility and maintainability of styling. - This change improves the clarity of variable usage across the stylesheet.
…t section - Changed the sidebar title from 'Overview' to 'Products' for better clarity in navigation. - Added a new section for 'Inventory' in the routes, providing a description and link for managing inventory and customer orders.
- Added a TagCombobox component to enable filtering of products by tags in the inventory route. - Updated the search schema to include tagIds for improved product querying. - Enhanced the loader function to fetch inventory tags alongside products, ensuring a cohesive user experience. - Modified the UI to display selected tags and allow for tag-based filtering, improving product management capabilities.
- Replaced the existing inline implementation of order reference prefixes, product tags, and production cost labels with dedicated sections for improved readability and maintainability. - Removed unused state management and mutation logic, streamlining the component's functionality. - Enhanced the overall organization of the inventory settings page, making it easier to manage and extend in the future.
- Reorganized the inventory component by replacing inline implementations with dedicated sections for product filters, stats, and tables, enhancing readability and maintainability. - Removed unused state management and mutation logic, simplifying the component's functionality. - Improved the overall structure of the inventory management interface, making it easier to navigate and extend.
- Introduced new components for displaying sales statistics, stock value, and top products in the inventory stats route. - Implemented a SalesStatsSection to visualize sales data, including total sales and revenue charts. - Created a StockStatsSection to present stock value, production costs, and potential benefits, with filtering options for production cost labels. - Added a TopProductsSection to showcase the top products by revenue, benefit, and quantity sold, enhancing the inventory management interface. - Updated the inventory stats route to integrate these new sections, improving data presentation and user experience.
- Deleted the inventory.ts file, which contained various functions related to inventory management, including product and order handling. - This cleanup reduces code complexity and removes unused functionality, streamlining the project structure.
- Updated import paths for various inventory-related functions to reflect a more modular structure, enhancing code organization and maintainability. - Removed the now obsolete inventory.ts file, streamlining the project and reducing complexity.
…istency - Updated the button padding in the SettingsSection component to enhance the visual layout and user experience. - This change ensures a more uniform appearance across the settings interface, contributing to better usability.
…tory sections - Updated multiple inventory components to use the new Section component instead of the deprecated SettingsSection, enhancing code consistency and maintainability. - Removed the SettingsSection file to streamline the project structure and reduce complexity.
…and add title attribute to product links - Changed the default value of the archived filter from 'all' to 'active' in the inventory search schema, refining the initial data displayed to users. - Added a title attribute to product links in the ProductTable component to improve accessibility and provide additional context for users when hovering over product names.
… styling - Updated the ProductFiltersSection to allow for a larger input width, improving user experience for search functionality. - Adjusted the SelectTrigger in DateRangeSelect to ensure consistent minimum width, enhancing layout stability. - Refactored function declarations in DateRangeSelect for improved readability and consistency.
- Introduced the ability to create and apply order price modification presets in the OrderCart component, enhancing pricing flexibility. - Updated the order cart form schema to include unit price fields for items, allowing for price adjustments. - Integrated new UI components for selecting and managing price modification presets, improving user interaction. - Enhanced the overall order calculation logic to reflect applied modifications accurately.
…in OrderCart - Redesigned the price modification UI in the OrderCart component for better organization and usability. - Replaced flexbox layout with a grid layout to enhance alignment and spacing of input fields. - Streamlined the component structure by consolidating related elements, improving overall readability and interaction.
…tionPresetsSection - Changed event type for handleCreate and handleUpdate functions from React.FormEvent to React.SubmitEvent for better type accuracy. - Improved form layout by switching from flexbox to a grid layout, enhancing alignment and spacing of input fields. - Consolidated label elements for better organization and readability within the form.
… structure - Removed the OrderCart component and replaced it with OrderCartForm to enhance modularity and maintainability. - Updated the new order route to reflect this change, ensuring a cleaner integration of the order cart functionality. - Streamlined the order processing logic by consolidating related components, improving overall code organization.
…ions - Introduced a new utility function, getNextOrderReferenceForPrefix, to streamline the process of generating the next order reference based on a given prefix. - Updated the $createOrder function to utilize the new utility, improving code readability and maintainability. - Refactored the order reference retrieval logic to support both database and transaction contexts, enhancing flexibility in order processing.
…r cart - Added functionality to allow multiple price modifications per order item, stored in a new JSONB column `price_modifications` in the database. - Updated the order creation process to accept and persist modifications for each item, ensuring they are displayed in the order detail view. - Enhanced the client-side order cart to manage modifications per line, including UI updates for adding and displaying modifications. - Implemented utility functions for applying modifications to prices, improving the overall pricing logic in the order cart. - Ensured backward compatibility for existing orders while introducing the new modifications feature.
…nents - Merged type imports for better organization in order cart item list. - Replaced array slicing with spread operator for clarity in modification handling. - Removed the OrderCartPriceModificationSection component to streamline the order cart functionality, as its features are now integrated elsewhere. - Updated related components to ensure consistent handling of price modifications across the order cart.
- Increased the width of the PopoverContent for better visibility of modification options. - Updated various child elements to use min-width for improved layout consistency. - Enhanced the overall structure of the component to ensure better alignment and usability of input fields.
…ine modifications - Deleted the plan files for order price modification and presets, as well as per-line modifications, which are no longer relevant to the current implementation. - These plans contained detailed specifications and architecture that have been superseded by recent updates in the order cart functionality.
- Eliminated the AddModificationPopover component and its associated logic from OrderCartItemsList, streamlining the item display process. - Updated the component to utilize OrderCartItemRow for rendering items, enhancing code clarity and maintainability. - Removed unused imports and reduced complexity in the item list rendering, focusing on essential functionalities.
- Removed unused type imports and the custom ProductCombobox creation, simplifying the component structure. - Updated the import statements for better organization and clarity. - Enhanced overall readability by reducing unnecessary complexity in the product form bundle items logic.
- Changed import statements in fetch.ts to use absolute paths for better clarity and organization. - Improved code maintainability by ensuring consistent import structure across utility files.
- Bumped bun version from 1.3.7 to 1.3.8 for enhanced performance. - Updated better-auth package from 1.4.17 to 1.4.18 to incorporate latest features and fixes. - Upgraded @types/node from 25.0.10 to 25.1.0 for improved type definitions. - Adjusted @typescript/native-preview version from 7.0.0-dev.20260128.1 to 7.0.0-dev.20260129.1 for better compatibility. - Incremented oxlint-tsgolint version from 0.11.2 to 0.11.3 to address linting improvements. - Updated vite from 8.0.0-beta.10 to 8.0.0-beta.11 for the latest enhancements and bug fixes. - Removed unused imports in textarea component and streamlined inventory route components for better clarity.
There was a problem hiding this comment.
Pull request overview
Adds a new Inventory application area with products, orders, cash tracking, settings, and statistics, plus supporting server APIs/migrations and some UI component upgrades.
Changes:
- Added inventory server functions (stats, tags, currency, cash, prefixes, presets) and DB migrations/schema exports.
- Added inventory UI routes/pages (products, orders, stats, cash, settings) and new UI primitives (combobox, date range select, input group, radio group).
- Replaced previous error middleware with zod-capture + custom fetch error handling.
Reviewed changes
Copilot reviewed 106 out of 110 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| test/server/functions/inventory/orders-bundles.test.ts | Adds tests for bundle quantity expansion logic |
| test/lib/forms/product-bundle.test.ts | Adds tests for bundle validation in product form schema |
| src/styles.css | Refactors radius tokens into dedicated :root section |
| src/start.tsx | Switches middleware + registers custom serverFns fetch |
| src/server/middlewares/zod-capture.ts | New middleware to surface Zod errors to UI |
| src/server/middlewares/emit-errors.ts | Removes old generalized client error emitter |
| src/server/functions/inventory/utils.ts | Adds inventory utility calculations |
| src/server/functions/inventory/stats.ts | Adds inventory sales/stock stats server APIs |
| src/server/functions/inventory/production-cost-labels.ts | CRUD server APIs for production cost labels |
| src/server/functions/inventory/order-reference-prefixes.ts | CRUD + next-reference generation for order prefixes |
| src/server/functions/inventory/order-price-modification-presets.ts | CRUD server APIs for price modification presets |
| src/server/functions/inventory/inventory-tags.ts | CRUD server APIs for inventory product tags |
| src/server/functions/inventory/currency.ts | Get/set inventory currency setting |
| src/server/functions/inventory/cash.ts | CRUD + reorder server APIs for cash rows |
| src/server/db/utils.ts | Adds shared Transaction / DbOrTransaction types |
| src/server/db/schema.ts | Exports inventory schema from the DB schema barrel |
| src/routes/index.tsx | Adds Inventory entry to app list |
| src/routes/_authed/inventory/stats.tsx | Adds inventory stats route/page |
| src/routes/_authed/inventory/settings.tsx | Adds inventory settings route/page |
| src/routes/_authed/inventory/route.tsx | Adds inventory parent route loader |
| src/routes/_authed/inventory/products/new.tsx | Adds “new product” page |
| src/routes/_authed/inventory/products/$productId.tsx | Adds “edit product” page |
| src/routes/_authed/inventory/orders/route.tsx | Adds orders route wrapper |
| src/routes/_authed/inventory/orders/new.tsx | Adds new order page |
| src/routes/_authed/inventory/orders/index.tsx | Adds orders list page |
| src/routes/_authed/inventory/orders/$orderId.tsx | Adds order detail page |
| src/routes/_authed/inventory/index.tsx | Adds products list page |
| src/routes/_authed/inventory/cash.tsx | Adds cash page |
| src/lib/utils/format-money.ts | Adds money formatting helpers |
| src/lib/utils/fetch.ts | Adds custom fetch wrapper for unified error handling |
| src/lib/utils/date-range.ts | Adds date range preset utilities |
| src/lib/utils/color.ts | Adds contrast text helper for colored tags/labels |
| src/lib/forms/product.ts | Adds product form schema including bundle validation |
| src/lib/forms/order-cart.ts | Adds order cart submit schema |
| src/components/ui/textarea.tsx | Removes explicit React type import (uses global React types) |
| src/components/ui/radio-group.tsx | Adds radio group UI primitive |
| src/components/ui/input.tsx | Updates input styling |
| src/components/ui/input-group.tsx | Adds input group UI primitive |
| src/components/ui/date-range-select.tsx | Adds date range select UI component |
| src/components/ui/combobox.tsx | Adds combobox component built on Base UI |
| src/components/ui/card.tsx | Updates card styling + adds size option |
| src/components/ui/button.tsx | Updates button API defaults + adds size variants/data attrs |
| src/components/nav/app-sidebar.tsx | Adds Inventory nav group |
| src/components/form/form-input.tsx | Expands FormInput props pass-through capability |
| src/components/data/data-table.tsx | Adds toolbar slot + column hiding UI |
| src/components/apps/time/tag-selector.tsx | Simplifies time tag selector UI |
| src/components/apps/inventory/stats/top-products-section.tsx | Adds top products stats component |
| src/components/apps/inventory/stats/stock-stats-section.tsx | Adds stock stats component + label filtering |
| src/components/apps/inventory/stats/sales-stats-section.tsx | Adds sales stats component + chart |
| src/components/apps/inventory/settings/production-cost-labels-section.tsx | Adds production cost labels settings UI |
| src/components/apps/inventory/settings/product-tags-section.tsx | Adds product tags settings UI |
| src/components/apps/inventory/settings/order-reference-prefixes-section.tsx | Adds order reference prefixes settings UI |
| src/components/apps/inventory/settings/order-price-modification-presets-section.tsx | Adds price modification presets settings UI |
| src/components/apps/inventory/settings/currency-section.tsx | Adds currency setting UI |
| src/components/apps/inventory/settings/color-input.tsx | Adds color picker input |
| src/components/apps/inventory/section.tsx | Adds reusable inventory section wrapper |
| src/components/apps/inventory/product-table.tsx | Adds product table component |
| src/components/apps/inventory/product-stats-section.tsx | Adds simple product stats cards |
| src/components/apps/inventory/product-form/use-product-mutations.ts | Adds product create/update mutation hooks |
| src/components/apps/inventory/product-form/types.ts | Adds product form types/default mapping |
| src/components/apps/inventory/product-form/product-form-tag-ids.tsx | Adds tag selection field for product form |
| src/components/apps/inventory/product-form/product-form-production-costs.tsx | Adds production costs editor for product form |
| src/components/apps/inventory/product-form/product-form-pricing.tsx | Adds pricing editor and computed incl-tax display |
| src/components/apps/inventory/product-form/product-form-bundle-items.tsx | Adds bundle components editor for product form |
| src/components/apps/inventory/product-form/product-form-basic-fields.tsx | Adds basic fields + kind selector for product form |
| src/components/apps/inventory/product-form/product-form-actions.tsx | Adds product form actions (create/update/archive) |
| src/components/apps/inventory/product-form/index.tsx | Adds full product form implementation |
| src/components/apps/inventory/product-filters-section.tsx | Adds product filtering controls |
| src/components/apps/inventory/order-detail.tsx | Adds order detail component |
| src/components/apps/inventory/order-cart/utils.ts | Adds price modification helpers |
| src/components/apps/inventory/order-cart/types.ts | Adds order cart types |
| src/components/apps/inventory/order-cart/order-cart-save-preset-dialog.tsx | Adds dialog to save a modification as preset |
| src/components/apps/inventory/order-cart/order-cart-items-list.tsx | Adds cart items list component |
| src/components/apps/inventory/order-cart/order-cart-item-row.tsx | Adds cart item row component |
| src/components/apps/inventory/order-cart/order-cart-form.tsx | Adds order creation form |
| src/components/apps/inventory/order-cart/order-cart-add-product-section.tsx | Adds add-product-to-cart component |
| src/components/apps/inventory/order-cart/next-reference.tsx | Adds next order reference preview component |
| src/components/apps/inventory/order-cart/comboboxes.ts | Adds typed combobox instances for order cart |
| src/components/apps/inventory/order-cart/add-modification-popover.tsx | Adds modification popover + preset application |
| src/components/apps/inventory/cash-table.tsx | Adds cash table UI |
| package.json | Adds deps and updates tooling versions/scripts |
| deployment/Dockerfile | Refactors Docker build into multi-stage install/build/prod |
| deployment/0.check.sh | Changes deployment check step to lint only |
| LICENSE | Updates copyright year |
| .vscode/settings.json | Updates TS import preferences + oxlint unused disables |
| .prototools | Updates bun version |
| .oxlintrc.json | Adjusts lint rules |
| .drizzle/meta/_journal.json | Adds inventory-related migrations to journal |
| .drizzle/0011_add_order_item_price_modifications.sql | Adds price modifications column to order items |
| .drizzle/0010_add_order_price_modification_preset.sql | Adds presets table migration |
| .drizzle/0009_product_bundles.sql | Adds product bundles schema |
| .drizzle/0008_inventory_add_setting_remove_prefix_sort_order.sql | Adds inventory settings table / removes prefix sort_order |
| .drizzle/0007_add_inventory_cash.sql | Adds inventory cash table |
| .drizzle/0006_inventory_reference_prefix_archived.sql | Adds order reference prefixes + product archived_at |
| .drizzle/0005_add_inventory.sql | Adds base inventory schema |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/apps/inventory/settings/production-cost-labels-section.tsx
Show resolved
Hide resolved
src/components/apps/inventory/settings/production-cost-labels-section.tsx
Show resolved
Hide resolved
src/components/apps/inventory/settings/order-reference-prefixes-section.tsx
Show resolved
Hide resolved
src/components/apps/inventory/settings/order-price-modification-presets-section.tsx
Show resolved
Hide resolved
src/components/apps/inventory/settings/order-price-modification-presets-section.tsx
Show resolved
Hide resolved
- Updated fetch utility to use globalThis for fetch calls, ensuring compatibility across different environments. - Modified error handling in zod-capture middleware to utilize globalThis for dispatching server error events. - Added tabIndex to the ProductTable component for improved accessibility and keyboard navigation.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 106 out of 110 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/apps/inventory/product-form/product-form-tag-ids.tsx
Outdated
Show resolved
Hide resolved
src/components/apps/inventory/product-form/product-form-tag-ids.tsx
Outdated
Show resolved
Hide resolved
- Updated the label and form field IDs in the ProductFormTagIds component from "tagsIds" to "tagIds" for consistency and accuracy. - Enhanced the handling of inventory statistics by adding a check for empty product lists, returning default values when no products are found. - Adjusted test case description for clarity regarding the behavior of mixed orders involving simple products and bundles.
- Updated multiple inventory-related functions to utilize database transactions, ensuring atomicity and consistency during updates and inserts. - Refactored the $reorderCashRow, $createOrderReferencePrefix, $markOrderPaid, and $createProduct functions to wrap database operations in a transaction context. - Enhanced error handling and data integrity by ensuring that all related database changes are committed or rolled back together.
…alidation - Consolidated import statements across inventory-related files for improved clarity and consistency. - Refactored product validation logic by moving validation functions to dedicated modules, enhancing maintainability. - Removed unused code and types from the products.ts file, simplifying the structure and improving readability.
…g exports - Removed extensive unused code related to order queries and validation schemas, streamlining the orders.ts file for better readability and maintainability. - Consolidated exports to focus on essential functionalities, enhancing clarity in the module's purpose. - Improved overall structure by eliminating redundant imports and functions, aligning with recent refactoring efforts in the inventory module.
…ucture - Updated import paths for order-related functions to separate mutations and queries, improving clarity and maintainability. - Removed the obsolete orders.ts file, consolidating functionality into more focused modules. - Streamlined inventory statistics imports to reflect recent structural changes, enhancing overall organization in the inventory module.
- Modified the lint script in package.json to remove type-checking, streamlining the linting process. - Added a new CI job for type-checking in the GitHub Actions workflow, ensuring type safety on pull requests. - Updated deployment script to include type-checking alongside linting, enhancing code quality checks during deployment.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 111 out of 116 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| endDate: z.string().min(1).max(50).optional(), | ||
| }) | ||
|
|
||
| export function getOrdersQueryOptions(params: z.input<typeof getOrdersSchema> = {}) { |
There was a problem hiding this comment.
Using the params object directly in the queryKey makes the key unstable (object identity changes easily), which can cause unnecessary cache misses/refetches. Use a normalized, serializable key derived from primitive fields (e.g. [...ordersQueryKey, page, size, reference ?? '', startDate ?? '', endDate ?? '']) or the constructed data object if it’s guaranteed to be stable.
| return queryOptions({ | ||
| queryKey: [...ordersQueryKey, params] as const, | ||
| queryFn: ({ signal }) => $getOrders({ signal, data }), | ||
| placeholderData: keepPreviousData, | ||
| staleTime: 1000 * 30, | ||
| }) | ||
| } |
There was a problem hiding this comment.
Using the params object directly in the queryKey makes the key unstable (object identity changes easily), which can cause unnecessary cache misses/refetches. Use a normalized, serializable key derived from primitive fields (e.g. [...ordersQueryKey, page, size, reference ?? '', startDate ?? '', endDate ?? '']) or the constructed data object if it’s guaranteed to be stable.
| const [raw, parsed] = tryInline(() => JSON.parse(body) as { error: string }) | ||
| if (raw) { | ||
| throw raw | ||
| } | ||
| globalThis.window?.dispatchEvent(new ServerErrorEvent({ body: parsed }, { sendToast: true })) | ||
| throw new Error(parsed.error) |
There was a problem hiding this comment.
This assumes every non-TSR Zod error response parses to { error: string }. If the server returns a different JSON shape (e.g. { body: { error: ... } } or { message: ... }), parsed.error will be undefined and you’ll throw a meaningless Error. Consider extracting the message more defensively (handle string bodies, { error }, { message }, and/or nested { body }), while still dispatching ServerErrorEvent with the appropriate payload.
No description provided.