@akinon/next 1.54.0 → 1.55.0

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,13 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.55.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1448a96: ZERO-2612: add errors type in CheckoutState
8
+ - 75080fd: ZERO-2630: Add max limit to postcode area
9
+ - eecb282: ZERO-2607: Update address-related functions to include invalidateTag option
10
+
3
11
  ## 1.54.0
4
12
 
5
13
  ### Minor Changes
@@ -39,7 +39,10 @@ const addressApi = api.injectEndpoints({
39
39
  query: (city) =>
40
40
  buildClientRequestUrl(address.getRetailStoreTownships(city))
41
41
  }),
42
- addAddress: builder.mutation<Address, Partial<Address>>({
42
+ addAddress: builder.mutation<
43
+ Address,
44
+ Partial<Address> & { invalidateTag?: 'Addresses' | 'Checkout' }
45
+ >({
43
46
  query: (body) => ({
44
47
  url: buildClientRequestUrl(address.base, {
45
48
  contentType: 'application/json'
@@ -50,9 +53,16 @@ const addressApi = api.injectEndpoints({
50
53
  type: body.is_corporate === 'true' ? 'corporate' : 'personal'
51
54
  }
52
55
  }),
53
- invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout'])
56
+ invalidatesTags: (_, error, arg) => {
57
+ if (error) return [];
58
+ if (arg.invalidateTag) return [arg.invalidateTag];
59
+ return ['Addresses', 'Checkout'];
60
+ }
54
61
  }),
55
- editAddress: builder.mutation<Address, Partial<Address>>({
62
+ editAddress: builder.mutation<
63
+ Address,
64
+ Partial<Address> & { invalidateTag?: 'Addresses' | 'Checkout' }
65
+ >({
56
66
  query: ({ pk, ...body }) => ({
57
67
  url: buildClientRequestUrl(address.editAddress(pk), {
58
68
  contentType: 'application/json'
@@ -64,14 +74,28 @@ const addressApi = api.injectEndpoints({
64
74
  type: body.is_corporate === 'true' ? 'corporate' : 'personal'
65
75
  }
66
76
  }),
67
- invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
77
+ invalidatesTags: (_, error, arg) => {
78
+ if (error) return [];
79
+ if (arg.invalidateTag) return [arg.invalidateTag];
80
+ return ['Addresses', 'Checkout'];
81
+ }
68
82
  }),
69
- removeAddress: builder.mutation<void, number>({
70
- query: (id) => ({
71
- url: buildClientRequestUrl(address.removeAddress(id)),
83
+ removeAddress: builder.mutation<
84
+ void,
85
+ number | { id: number; invalidateTag: 'Addresses' | 'Checkout' }
86
+ >({
87
+ query: (arg) => ({
88
+ url: buildClientRequestUrl(
89
+ address.removeAddress(typeof arg === 'number' ? arg : arg.id)
90
+ ),
72
91
  method: 'DELETE'
73
92
  }),
74
- invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
93
+ invalidatesTags: (_, error, arg) => {
94
+ if (error) return [];
95
+ if (typeof arg === 'object' && arg.invalidateTag)
96
+ return [arg.invalidateTag];
97
+ return ['Addresses', 'Checkout'];
98
+ }
75
99
  }),
76
100
  setDefaultAddress: builder.mutation<Address, Partial<Address>>({
77
101
  query: ({ pk, primary }) => ({
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.54.0",
4
+ "version": "1.55.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -29,7 +29,7 @@
29
29
  "set-cookie-parser": "2.6.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@akinon/eslint-plugin-projectzero": "1.54.0",
32
+ "@akinon/eslint-plugin-projectzero": "1.55.0",
33
33
  "@types/react-redux": "7.1.30",
34
34
  "@types/set-cookie-parser": "2.4.7",
35
35
  "@typescript-eslint/eslint-plugin": "6.7.4",
@@ -29,7 +29,7 @@ import { showMobile3dIframe } from '../../utils/mobile-3d-iframe';
29
29
 
30
30
  interface CheckoutResult {
31
31
  payload: {
32
- errors?: any;
32
+ errors?: Record<string, string[]>;
33
33
  pre_order?: PreOrder;
34
34
  context_list?: CheckoutContext[];
35
35
  };
@@ -18,8 +18,7 @@ import {
18
18
  } from '../../types';
19
19
 
20
20
  export interface CheckoutState {
21
- // TODO: Add types
22
- errors: any;
21
+ errors: Record<string, string[]>;
23
22
  hasGiftBox: boolean;
24
23
  canGuestPurchase: boolean;
25
24
  steps: {
@@ -6,6 +6,8 @@ import { Config } from '../../types';
6
6
  const initialState: Config = {
7
7
  user_phone_regex: '^(05)\\d{9}$',
8
8
  user_phone_format: '05999999999',
9
+ user_post_code_regex: '^\\d{5}$',
10
+ user_post_code_format: '99999',
9
11
  country: {
10
12
  pk: 1,
11
13
  name: 'Türkiye',
@@ -2,6 +2,8 @@ import { District } from './address';
2
2
  export interface Config {
3
3
  user_phone_regex: string;
4
4
  user_phone_format: string;
5
+ user_post_code_regex: string;
6
+ user_post_code_format: string;
5
7
  country: {
6
8
  pk: number;
7
9
  name: string;