✨ feat(skus): migrate SkuListsContainer and AvailabilityContainer to hooks#731
Draft
✨ feat(skus): migrate SkuListsContainer and AvailabilityContainer to hooks#731
Conversation
…source-delete-button Add `PaymentSourceDeleteButton`
Fix vulnerabilities
Fix disable place order button and givex show errors
Reset payment source when it is expired
Brings in bug fixes from v4.29.4→v4.29.6: PlaceOrderButton gift card error handling, PlaceOrderReducer org config fetch fix, PrivacyAndTermsCheckbox org config fallback, payment component validation fixes, Adyen dropin fix, and security dep upgrades. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 📦 Add getSkus, retrieveSku, updateSku functions to core package - 🪝 Add useSkus hook to hooks package with full test coverage - 🐛 Fix extender.ts accessToken type and use() call - 📈 Improve usePrices/useSkus coverage: dataRef tracks get-action data only - 🔒 Replace non-null assertions with null guards in SWR fetcher - 🧪 Add vitest setup file with extended asyncUtilTimeout for coverage runs - 🔧 Update pre-commit hook to scope build/test to core and hooks only - 🐶 Fix husky deprecated shell preamble in pre-commit hook
…ucer Closes #727. Replaces useReducer + getSku manual SDK calls with the useSkus hook from @commercelayer/hooks. SkuReducer now only exports the SkuState type. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…drop old tests Closes #728. Updates peerDependencies to react >=19.0.0, adds babel-plugin-react-compiler to the vitest config, and removes all legacy specs written against the React 18 + reducer architecture. New tests will be added incrementally per feature.
- Add specs/skus/skus-container.spec.tsx with 6 tests covering code fields, count, name, image_url, empty skus, and queryParams filter - Wrap each render with SWRConfig provider for isolated cache per test - Fix clearSkus unhandled promise rejection by chaining .catch() on mutate - Add babel-plugin-react-compiler and SWR to react-components vitest config - Add workspace aliases for @commercelayer/hooks and @commercelayer/core
…hooks - Add getSkuLists/retrieveSkuList functions to @commercelayer/core - Add getSkuAvailability function to @commercelayer/core - Create useSkuLists hook in @commercelayer/hooks (with SWR caching) - Create useAvailability hook in @commercelayer/hooks (with SWR caching) - Refactor SkuListsContainer to use useSkuLists — proper registration pattern via registerListId callback instead of direct array mutation - Refactor AvailabilityContainer to use useAvailability, removing useReducer and AvailabilityReducer dependency - Update SkuList to call registerListId instead of mutating listIds - Update AvailabilityTemplate to import DeliveryLeadTime from core - Fix Skus component to use sku.id as key instead of array index - Fix AddToCartButton to use sku.code from typed Sku[] context - Add sku_lists* to MSW bypass handlers - Add tests: availability-container, sku-lists-container, core specs - Add AvailabilityContext and SkuListsContext types Closes #730
- Add specs for CommerceLayer auth component - Add unit tests for SkusContainer, SkuListsContainer, AvailabilityContainer, AvailabilityTemplate, DeliveryLeadTime, SkuField, Parent components - Add unit tests for useCustomContext hook - Migrate vitest config to vitest.config.mts (drop _vitest.config.mts prefix) - Remove outdated e2e specs replaced by unit tests
Member
Author
Updates✅ Unit tests & coverage
🔨 Build: migrate from
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #730
Migrates all remaining skus-folder components to use dedicated hooks from
@commercelayer/hooks, removing direct API calls from reducers — following the same pattern established in #720 forSkusContainer.getSkuList/retrieveSkuListfunctions to@commercelayer/coregetSkuInventoryfunction to@commercelayer/coreuseSkuListshook in@commercelayer/hooksuseAvailabilityhook in@commercelayer/hooksSkuListsContainerto useuseSkuListsAvailabilityContainerto useuseAvailabilityTest plan
🤖 Generated with Claude Code