@akinon/next 1.81.0-rc.2 → 1.81.0-rc.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.81.0-rc.3
4
+
5
+ ### Minor Changes
6
+
7
+ - c0fef075: ZERO-3197: Refetch payment options after loyalty usage
8
+
3
9
  ## 1.81.0-rc.2
4
10
 
5
11
  ### Minor Changes
@@ -72,6 +72,7 @@ export const api = createApi({
72
72
  'DraftsB2b',
73
73
  'Product',
74
74
  'Checkout',
75
+ 'PaymentOptions',
75
76
  'Favorite',
76
77
  'Addresses',
77
78
  'Profile',
@@ -2,6 +2,7 @@ import {
2
2
  setBankAccounts,
3
3
  setCardType,
4
4
  setInstallmentOptions,
5
+ setPaymentOptions,
5
6
  setPaymentStepBusy,
6
7
  setSelectedBankAccountPk,
7
8
  setSelectedCreditPaymentPk,
@@ -424,6 +425,12 @@ export const checkoutApi = api.injectEndpoints({
424
425
  }
425
426
  })
426
427
  }),
428
+ fetchPaymentOptions: build.query<CheckoutResponse, void>({
429
+ query: () => ({
430
+ url: buildClientRequestUrl(checkout.setPaymentOption)
431
+ }),
432
+ providesTags: ['PaymentOptions']
433
+ }),
427
434
  setPaymentOption: build.mutation<CheckoutResponse, number>({
428
435
  query: (pk: number) => ({
429
436
  url: buildClientRequestUrl(checkout.setPaymentOption, {
@@ -737,7 +744,27 @@ export const checkoutApi = api.injectEndpoints({
737
744
  body: {
738
745
  loyalty_amount_to_use: amount
739
746
  }
740
- })
747
+ }),
748
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
749
+ dispatch(setPaymentStepBusy(true));
750
+ dispatch(setPaymentOptions([]));
751
+ await queryFulfilled;
752
+
753
+ const paymentOptionsData = await dispatch(
754
+ checkoutApi.endpoints.fetchPaymentOptions.initiate()
755
+ ).unwrap();
756
+
757
+ const paymentOptions = paymentOptionsData?.context_list?.find(
758
+ (context) => context?.page_name === 'PaymentOptionSelectionPage'
759
+ )?.page_context?.payment_options;
760
+
761
+ if (paymentOptions) {
762
+ dispatch(setPaymentOptions(paymentOptions));
763
+ }
764
+
765
+ dispatch(setPaymentStepBusy(false));
766
+ },
767
+ invalidatesTags: ['PaymentOptions']
741
768
  }),
742
769
  setOrderNote: build.mutation<CheckoutResponse, string>({
743
770
  query: (notes) => ({
@@ -840,6 +867,7 @@ export const {
840
867
  useSetAddressesMutation,
841
868
  useSetShippingOptionMutation,
842
869
  useSetDataSourceShippingOptionsMutation,
870
+ useFetchPaymentOptionsQuery,
843
871
  useSetPaymentOptionMutation,
844
872
  useSetBinNumberMutation,
845
873
  useSetInstallmentOptionMutation,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.81.0-rc.2",
4
+ "version": "1.81.0-rc.3",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "set-cookie-parser": "2.6.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@akinon/eslint-plugin-projectzero": "1.81.0-rc.2",
33
+ "@akinon/eslint-plugin-projectzero": "1.81.0-rc.3",
34
34
  "@types/react-redux": "7.1.30",
35
35
  "@types/set-cookie-parser": "2.4.7",
36
36
  "@typescript-eslint/eslint-plugin": "6.7.4",