@akinon/next 1.13.0 → 1.14.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/.editorconfig +7 -0
- package/.eslintrc.js +40 -40
- package/.prettierrc +13 -13
- package/CHANGELOG.md +19 -0
- package/api/auth.ts +231 -231
- package/api/cache.ts +44 -44
- package/api/client.ts +174 -174
- package/api/logout.ts +42 -42
- package/assets/styles/index.scss +28 -28
- package/bin/pz-check-dependencies.js +98 -98
- package/bin/pz-install-plugins.js +33 -33
- package/bin/pz-install-theme.js +58 -58
- package/bin/pz-postbuild.js +1 -1
- package/bin/pz-postdev.js +1 -1
- package/bin/pz-postinstall.js +6 -6
- package/bin/pz-poststart.js +1 -1
- package/bin/pz-prebuild.js +4 -4
- package/bin/pz-predev.js +4 -4
- package/bin/pz-prestart.js +1 -1
- package/bin/run-script.js +44 -44
- package/components/accordion.tsx +52 -0
- package/components/button.tsx +46 -0
- package/components/client-root.tsx +19 -19
- package/components/icon.tsx +18 -18
- package/components/image.tsx +133 -133
- package/components/index.ts +17 -1
- package/components/input.tsx +110 -0
- package/components/lazy-component.tsx +33 -33
- package/components/loader-spinner.tsx +23 -23
- package/components/mobile-app-toggler.tsx +26 -26
- package/components/oauth-login.tsx +24 -24
- package/components/plugin-module.tsx +11 -8
- package/components/price.tsx +55 -0
- package/components/pz-providers.tsx +24 -24
- package/components/pz-root.tsx +21 -21
- package/components/radio.tsx +18 -18
- package/components/react-portal.tsx +45 -45
- package/components/redirect-three-d/content/index.tsx +74 -74
- package/components/redirect-three-d/index.tsx +17 -17
- package/components/selected-payment-option-view.tsx +7 -0
- package/components/trans.tsx +39 -39
- package/data/client/account.ts +208 -208
- package/data/client/address.ts +107 -107
- package/data/client/api.ts +85 -84
- package/data/client/b2b.ts +106 -106
- package/data/client/basket.ts +82 -82
- package/data/client/checkout.ts +516 -479
- package/data/client/misc.ts +101 -101
- package/data/client/product.ts +89 -89
- package/data/client/user.ts +99 -99
- package/data/client/wishlist.ts +118 -88
- package/data/server/category.ts +132 -128
- package/data/server/flatpage.ts +21 -21
- package/data/server/form.ts +22 -22
- package/data/server/index.ts +10 -10
- package/data/server/landingpage.ts +24 -24
- package/data/server/list.ts +67 -62
- package/data/server/menu.ts +35 -35
- package/data/server/product.ts +86 -86
- package/data/server/seo.ts +48 -48
- package/data/server/special-page.ts +47 -47
- package/data/server/widget.ts +27 -27
- package/data/urls.ts +221 -210
- package/hocs/client/index.ts +1 -1
- package/hocs/client/with-segment-defaults.tsx +25 -25
- package/hocs/server/index.ts +1 -1
- package/hocs/server/with-segment-defaults.tsx +85 -85
- package/hooks/index.ts +10 -10
- package/hooks/use-captcha.tsx +76 -76
- package/hooks/use-common-product-attributes.ts +36 -36
- package/hooks/use-debounce.ts +20 -20
- package/hooks/use-localization.ts +78 -78
- package/hooks/use-media-query.ts +36 -36
- package/hooks/use-mobile-iframe-handler.ts +23 -23
- package/hooks/use-on-click-outside.tsx +28 -28
- package/hooks/use-payment-options.ts +12 -16
- package/hooks/use-router.ts +45 -45
- package/hooks/use-translation.ts +14 -14
- package/lib/cache.ts +215 -215
- package/localization/index.ts +5 -5
- package/localization/provider.tsx +58 -58
- package/middlewares/currency.ts +100 -100
- package/middlewares/default.ts +256 -256
- package/middlewares/index.ts +29 -29
- package/middlewares/locale.ts +68 -68
- package/middlewares/oauth-login.ts +79 -79
- package/middlewares/pretty-url.ts +104 -104
- package/middlewares/redirection-payment.ts +160 -160
- package/middlewares/three-d-redirection.ts +159 -159
- package/middlewares/url-redirection.ts +65 -65
- package/package.json +2 -2
- package/plugins.js +2 -1
- package/redux/hooks.ts +7 -7
- package/redux/middlewares/checkout.ts +265 -260
- package/redux/middlewares/index.ts +50 -50
- package/redux/reducers/checkout.ts +184 -171
- package/redux/reducers/config.ts +28 -28
- package/redux/reducers/header.ts +59 -59
- package/redux/reducers/index.ts +14 -14
- package/redux/reducers/root.ts +61 -61
- package/sentry/index.ts +27 -27
- package/tailwind/rtl.js +137 -137
- package/types/commerce/account.ts +64 -64
- package/types/commerce/address.ts +94 -94
- package/types/commerce/b2b.ts +117 -117
- package/types/commerce/basket.ts +43 -43
- package/types/commerce/category.ts +114 -114
- package/types/commerce/checkout.ts +143 -136
- package/types/commerce/flatpage.ts +7 -7
- package/types/commerce/form.ts +66 -66
- package/types/commerce/index.ts +12 -12
- package/types/commerce/landingpage.ts +7 -7
- package/types/commerce/misc.ts +127 -127
- package/types/commerce/order.ts +119 -119
- package/types/commerce/product.ts +109 -109
- package/types/commerce/widget.ts +28 -28
- package/types/gtm.ts +16 -16
- package/types/index.ts +274 -237
- package/types/metadata.ts +7 -7
- package/types/next-auth.d.ts +24 -24
- package/utils/app-fetch.ts +69 -69
- package/utils/deep-merge.js +24 -24
- package/utils/generate-commerce-search-params.ts +22 -22
- package/utils/get-currency.ts +29 -29
- package/utils/image-loader.ts +31 -31
- package/utils/index.ts +150 -150
- package/utils/localization.ts +29 -29
- package/utils/log.ts +138 -138
- package/utils/menu-generator.ts +27 -27
- package/utils/mobile-3d-iframe.ts +77 -77
- package/utils/server-translation.ts +57 -57
- package/utils/server-variables.ts +9 -9
- package/with-pz-config.js +94 -94
package/data/urls.ts
CHANGED
|
@@ -1,210 +1,221 @@
|
|
|
1
|
-
/* eslint-disable @akinon/projectzero/client-url */
|
|
2
|
-
import Settings from 'settings';
|
|
3
|
-
|
|
4
|
-
const API_URL = Settings.commerceUrl;
|
|
5
|
-
|
|
6
|
-
export const account = {
|
|
7
|
-
order: '/users/orders/',
|
|
8
|
-
orderId: (id: string | string[]) => `/users/orders/${id}/`,
|
|
9
|
-
cancelOrder: (id: string) => `/orders/${id}/cancel/`,
|
|
10
|
-
bulkCancellationRequest: '/users/orders/bulk_cancellation_requests/',
|
|
11
|
-
cancellationReasons: '/users/orders/cancellation_reasons/',
|
|
12
|
-
updatePassword: '/users/password/change/',
|
|
13
|
-
updateEmail: '/users/email-change/',
|
|
14
|
-
updateProfile: '/users/profile/',
|
|
15
|
-
getContactSubjects: '/users/contact-us-subjects/',
|
|
16
|
-
getOrders: ({
|
|
17
|
-
page,
|
|
18
|
-
limit,
|
|
19
|
-
createdDate
|
|
20
|
-
}: {
|
|
21
|
-
page?: number;
|
|
22
|
-
limit?: number;
|
|
23
|
-
createdDate?: string;
|
|
24
|
-
}) =>
|
|
25
|
-
`/users/orders/?page=${page || 1}&limit=${limit || 12} ${
|
|
26
|
-
createdDate ? `&created_date__gte=${createdDate}` : ''
|
|
27
|
-
}`,
|
|
28
|
-
getQuotations: '/b2b/my-quotations',
|
|
29
|
-
sendContact: '/users/contact-us',
|
|
30
|
-
passwordReset: (slug: string) => `/users/reset/${slug}`,
|
|
31
|
-
anonymize: '/users/anonymize/',
|
|
32
|
-
loyaltyBalance: '/account/loyalty-account-balance/',
|
|
33
|
-
loyaltyTransactions: '/account/loyalty/'
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const address = {
|
|
37
|
-
base: '/address/',
|
|
38
|
-
countries: '/address/country/',
|
|
39
|
-
getAddresses: '/address/detailed/',
|
|
40
|
-
getCities: (country: string) => `/address/city/?country=${country}`,
|
|
41
|
-
getTownships: (city: string) => `/address/township/?city=${city}`,
|
|
42
|
-
getDistricts: (township: string) => `/address/district/?township=${township}`,
|
|
43
|
-
getRetailStore: '/address/city/?retailstore__isnull=false',
|
|
44
|
-
getRetailStoreCities: (country: string) =>
|
|
45
|
-
`/address/city/?retailstore__isnull=false&country=${country}`,
|
|
46
|
-
getRetailStoreTownships: (city: string) =>
|
|
47
|
-
`/address/township/?retailstore__isnull=false&city=${city}`,
|
|
48
|
-
editAddress: (pk: number) => `/address/${pk}/`,
|
|
49
|
-
removeAddress: (id: number) => `/address/${id}/`,
|
|
50
|
-
setDefaultAddress: (pk: number) => `/address/${pk}/`
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const basket = {
|
|
54
|
-
getBasket: '/baskets/basket/'
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const category = {
|
|
58
|
-
list: '/list/',
|
|
59
|
-
getCategoryByPk: (pk: number) => `/category/${pk}/`,
|
|
60
|
-
getCategoryBySlug: (slug: string) => `/${slug}/`,
|
|
61
|
-
getSpecialPageByPk: (pk: number) => `/special-page/${pk}/`
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const checkout = {
|
|
65
|
-
get3dRedirectForm: '/orders/redirect-three-d/',
|
|
66
|
-
fetchCheckout: '/orders/checkout/',
|
|
67
|
-
fetchCheckoutResult: (token: string) =>
|
|
68
|
-
`/orders/completed/${token}/?format=json`,
|
|
69
|
-
getContract: (slug: string) => `/orders/contract/?contract_name=${slug}`,
|
|
70
|
-
completeCreditCardPayment:
|
|
71
|
-
'/orders/checkout/?page=CreditCardConfirmationPage',
|
|
72
|
-
completeFundsTransfer: '/orders/checkout/?page=FundsTransferPage',
|
|
73
|
-
guestLogin: '/orders/checkout/?page=IndexPage',
|
|
74
|
-
setDeliveryOption: '/orders/checkout/?page=DeliveryOptionSelectionPage',
|
|
75
|
-
setAddresses: '/orders/checkout/?page=AddressSelectionPage',
|
|
76
|
-
setShippingOption: '/orders/checkout/?page=ShippingOptionSelectionPage',
|
|
77
|
-
setPaymentOption: '/orders/checkout/?page=PaymentOptionSelectionPage',
|
|
78
|
-
setBinNumber: '/orders/checkout/?page=BinNumberPage',
|
|
79
|
-
setMasterpassBinNumber: '/orders/checkout/?page=MasterpassBinNumberPage',
|
|
80
|
-
setInstallmentOption: '/orders/checkout/?page=InstallmentSelectionPage',
|
|
81
|
-
setMasterPassInstallmentOption:
|
|
82
|
-
'/orders/checkout/?page=MasterpassInstallmentPage',
|
|
83
|
-
setFundsTransferOption: '/orders/checkout/?page=FundsTransferChoicePage',
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
'/orders/checkout/?page=
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
|
|
1
|
+
/* eslint-disable @akinon/projectzero/client-url */
|
|
2
|
+
import Settings from 'settings';
|
|
3
|
+
|
|
4
|
+
const API_URL = Settings.commerceUrl;
|
|
5
|
+
|
|
6
|
+
export const account = {
|
|
7
|
+
order: '/users/orders/',
|
|
8
|
+
orderId: (id: string | string[]) => `/users/orders/${id}/`,
|
|
9
|
+
cancelOrder: (id: string) => `/orders/${id}/cancel/`,
|
|
10
|
+
bulkCancellationRequest: '/users/orders/bulk_cancellation_requests/',
|
|
11
|
+
cancellationReasons: '/users/orders/cancellation_reasons/',
|
|
12
|
+
updatePassword: '/users/password/change/',
|
|
13
|
+
updateEmail: '/users/email-change/',
|
|
14
|
+
updateProfile: '/users/profile/',
|
|
15
|
+
getContactSubjects: '/users/contact-us-subjects/',
|
|
16
|
+
getOrders: ({
|
|
17
|
+
page,
|
|
18
|
+
limit,
|
|
19
|
+
createdDate
|
|
20
|
+
}: {
|
|
21
|
+
page?: number;
|
|
22
|
+
limit?: number;
|
|
23
|
+
createdDate?: string;
|
|
24
|
+
}) =>
|
|
25
|
+
`/users/orders/?page=${page || 1}&limit=${limit || 12} ${
|
|
26
|
+
createdDate ? `&created_date__gte=${createdDate}` : ''
|
|
27
|
+
}`,
|
|
28
|
+
getQuotations: '/b2b/my-quotations',
|
|
29
|
+
sendContact: '/users/contact-us',
|
|
30
|
+
passwordReset: (slug: string) => `/users/reset/${slug}`,
|
|
31
|
+
anonymize: '/users/anonymize/',
|
|
32
|
+
loyaltyBalance: '/account/loyalty-account-balance/',
|
|
33
|
+
loyaltyTransactions: '/account/loyalty/'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const address = {
|
|
37
|
+
base: '/address/',
|
|
38
|
+
countries: '/address/country/',
|
|
39
|
+
getAddresses: '/address/detailed/',
|
|
40
|
+
getCities: (country: string) => `/address/city/?country=${country}`,
|
|
41
|
+
getTownships: (city: string) => `/address/township/?city=${city}`,
|
|
42
|
+
getDistricts: (township: string) => `/address/district/?township=${township}`,
|
|
43
|
+
getRetailStore: '/address/city/?retailstore__isnull=false',
|
|
44
|
+
getRetailStoreCities: (country: string) =>
|
|
45
|
+
`/address/city/?retailstore__isnull=false&country=${country}`,
|
|
46
|
+
getRetailStoreTownships: (city: string) =>
|
|
47
|
+
`/address/township/?retailstore__isnull=false&city=${city}`,
|
|
48
|
+
editAddress: (pk: number) => `/address/${pk}/`,
|
|
49
|
+
removeAddress: (id: number) => `/address/${id}/`,
|
|
50
|
+
setDefaultAddress: (pk: number) => `/address/${pk}/`
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const basket = {
|
|
54
|
+
getBasket: '/baskets/basket/'
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const category = {
|
|
58
|
+
list: '/list/',
|
|
59
|
+
getCategoryByPk: (pk: number) => `/category/${pk}/`,
|
|
60
|
+
getCategoryBySlug: (slug: string) => `/${slug}/`,
|
|
61
|
+
getSpecialPageByPk: (pk: number) => `/special-page/${pk}/`
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const checkout = {
|
|
65
|
+
get3dRedirectForm: '/orders/redirect-three-d/',
|
|
66
|
+
fetchCheckout: '/orders/checkout/',
|
|
67
|
+
fetchCheckoutResult: (token: string) =>
|
|
68
|
+
`/orders/completed/${token}/?format=json`,
|
|
69
|
+
getContract: (slug: string) => `/orders/contract/?contract_name=${slug}`,
|
|
70
|
+
completeCreditCardPayment:
|
|
71
|
+
'/orders/checkout/?page=CreditCardConfirmationPage',
|
|
72
|
+
completeFundsTransfer: '/orders/checkout/?page=FundsTransferPage',
|
|
73
|
+
guestLogin: '/orders/checkout/?page=IndexPage',
|
|
74
|
+
setDeliveryOption: '/orders/checkout/?page=DeliveryOptionSelectionPage',
|
|
75
|
+
setAddresses: '/orders/checkout/?page=AddressSelectionPage',
|
|
76
|
+
setShippingOption: '/orders/checkout/?page=ShippingOptionSelectionPage',
|
|
77
|
+
setPaymentOption: '/orders/checkout/?page=PaymentOptionSelectionPage',
|
|
78
|
+
setBinNumber: '/orders/checkout/?page=BinNumberPage',
|
|
79
|
+
setMasterpassBinNumber: '/orders/checkout/?page=MasterpassBinNumberPage',
|
|
80
|
+
setInstallmentOption: '/orders/checkout/?page=InstallmentSelectionPage',
|
|
81
|
+
setMasterPassInstallmentOption:
|
|
82
|
+
'/orders/checkout/?page=MasterpassInstallmentPage',
|
|
83
|
+
setFundsTransferOption: '/orders/checkout/?page=FundsTransferChoicePage',
|
|
84
|
+
setCreditPaymentOption: '/orders/checkout/?page=CreditPaymentSelectionPage',
|
|
85
|
+
confirmationCreditPayment:
|
|
86
|
+
'/orders/checkout/?page=CreditPaymentConfirmationPage',
|
|
87
|
+
getCheckoutProviders: '/orders/checkout-provider-list/',
|
|
88
|
+
getCheckoutProvidersIndex: '/orders/checkout/?page=CheckoutProviderIndexPage',
|
|
89
|
+
setCheckoutProvider: '/orders/checkout/?page=CheckoutProviderSelectionPage',
|
|
90
|
+
completeRedirectionPayment:
|
|
91
|
+
'/orders/checkout/?page=RedirectionPaymentSelectedPage',
|
|
92
|
+
confirmationPaymentSelect:
|
|
93
|
+
'/orders/checkout/?page=ConfirmationPaymentSelectedPage',
|
|
94
|
+
confirmationQuery: '/orders/checkout/?page=ConfirmationPaymentQueryPage',
|
|
95
|
+
confirmationComplete:
|
|
96
|
+
'/orders/checkout/?page=ConfirmationPaymentCompletePage',
|
|
97
|
+
completeLoyaltyPayment: '/orders/checkout/?page=LoyaltyPaymentSelectedPage',
|
|
98
|
+
loyaltyMoneyUsage: '/orders/checkout/?page=LoyaltyMoneyUsagePage',
|
|
99
|
+
setOrderNote: '/orders/checkout/?page=OrderNotePage'
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const flatpage = {
|
|
103
|
+
getFlatPageByPk: (pk: number) => `/shop-flat-page/${pk}/`
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const landingpage = {
|
|
107
|
+
getLandingPageByPk: (pk: number) => `/landing-page/${pk}/`
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const misc = {
|
|
111
|
+
autocomplete: '/autocomplete/',
|
|
112
|
+
stores: '/stores/',
|
|
113
|
+
menu: '/misc/menus/generate/',
|
|
114
|
+
prettyUrl: (pathname: string) => `/misc/pretty-url${pathname}/`,
|
|
115
|
+
prettyUrls: (pathname: string) => `/pretty_urls/?new_path__exact=${pathname}`,
|
|
116
|
+
emailSubscription: '/email-subscription/',
|
|
117
|
+
menus: (depthHeight: number, parent?: string) =>
|
|
118
|
+
`/menus/generate/?depth_height=${depthHeight}${
|
|
119
|
+
parent ? `&parent=${parent}` : ''
|
|
120
|
+
}`,
|
|
121
|
+
cmsSeo: (slug: string | string[]) => `/cms/seo/?url=${slug ? slug : '/'}`,
|
|
122
|
+
setCurrency: '/users/activate-currency/'
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const product = {
|
|
126
|
+
category: (productId: number) => `/product/${productId}/category/`,
|
|
127
|
+
installments: (productId: number) => `/payments/cards/product/${productId}/`,
|
|
128
|
+
getProductByPk: (pk: number) => `/product/${pk}/`,
|
|
129
|
+
getGroupProductByPk: (pk: number) => `/group-product/${pk}/`,
|
|
130
|
+
getRetailStoreStock: (productPk: string, queryString: string) =>
|
|
131
|
+
`/retail_store_stock/${productPk}/?${queryString}`,
|
|
132
|
+
addProduct: '/baskets/basket/',
|
|
133
|
+
slug: (slug: string) => `/${slug}/`,
|
|
134
|
+
categoryUrl: (pk: number) => `/products/${pk}/category_nodes/?limit=1`,
|
|
135
|
+
breadcrumbUrl: (menuitemmodel: string) =>
|
|
136
|
+
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const wishlist = {
|
|
140
|
+
getFavorites: ({ page, limit }: { page?: number; limit?: number }) =>
|
|
141
|
+
`/wishlists/favourite-products/?limit=${limit || 12}&page=${page || 1}`,
|
|
142
|
+
addFavorite: '/wishlists/favourite-products/',
|
|
143
|
+
removeFavorite: (favPk: number) => `/wishlists/favourite-products/${favPk}/`,
|
|
144
|
+
addStockAlert: '/wishlists/product-alerts/',
|
|
145
|
+
getStockAlerts: ({
|
|
146
|
+
page = 1,
|
|
147
|
+
limit = 12
|
|
148
|
+
}: {
|
|
149
|
+
page?: number;
|
|
150
|
+
limit?: number;
|
|
151
|
+
}) => `/wishlists/product-alerts/?limit=${limit}&page=${page}`,
|
|
152
|
+
deleteStockAlert: (pk: number) => `/wishlists/product-alerts/${pk}/`
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const user = {
|
|
156
|
+
currentUser: '/current_user/',
|
|
157
|
+
login: '/users/login/',
|
|
158
|
+
register: '/users/registration/',
|
|
159
|
+
logout: '/users/logout',
|
|
160
|
+
captcha: '/users/pz-captcha/',
|
|
161
|
+
profiles: '/users/profile/',
|
|
162
|
+
forgotPassword: '/users/password/reset/',
|
|
163
|
+
changeEmailVerification: (token: string) =>
|
|
164
|
+
`/users/email-set-primary/${token}/`,
|
|
165
|
+
confirmEmailVerification: (token: string) =>
|
|
166
|
+
`/users/registration/account-confirm-email/${token}/`,
|
|
167
|
+
csrfToken: '/csrf_token/'
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const b2b = {
|
|
171
|
+
basket: '/b2b/basket/',
|
|
172
|
+
saveBasket: '/b2b/basket/save/',
|
|
173
|
+
draftBaskets: '/b2b/basket/drafts/',
|
|
174
|
+
divisions: '/b2b/my-divisions/',
|
|
175
|
+
myQuotations: '/b2b/my-quotations/',
|
|
176
|
+
loadBasket: (id) => `/b2b/basket/${id}/load/`
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const widgets = {
|
|
180
|
+
getWidget: (slug: string) => `/widgets/${slug}/`
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const form = {
|
|
184
|
+
getForm: (pk: number) => `/forms/${pk}/generate/`
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const URLS = {
|
|
188
|
+
account,
|
|
189
|
+
address,
|
|
190
|
+
basket,
|
|
191
|
+
category,
|
|
192
|
+
checkout,
|
|
193
|
+
flatpage,
|
|
194
|
+
misc,
|
|
195
|
+
product,
|
|
196
|
+
wishlist,
|
|
197
|
+
user,
|
|
198
|
+
widgets,
|
|
199
|
+
form
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const UrlProxyHandler = {
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
204
|
+
get(target, prop, receiver) {
|
|
205
|
+
if (typeof target[prop] === 'function') {
|
|
206
|
+
return new Proxy(target[prop], {
|
|
207
|
+
apply(target, thisArgs, argumentList) {
|
|
208
|
+
return `${API_URL}${target(...argumentList)}`;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return `${API_URL}${target[prop]}`;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
Object.keys(URLS).forEach((key) => {
|
|
218
|
+
URLS[key] = new Proxy(URLS[key], UrlProxyHandler);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
export { URLS };
|
package/hocs/client/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './with-segment-defaults';
|
|
1
|
+
export * from './with-segment-defaults';
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { LayoutProps, PageProps, RootLayoutProps } from '../../types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
type SegmentType = 'client-root' | 'layout' | 'page';
|
|
5
|
-
|
|
6
|
-
interface SegmentDefaultsOptions {
|
|
7
|
-
segmentType: SegmentType;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const withSegmentDefaults =
|
|
11
|
-
<T extends PageProps | LayoutProps | RootLayoutProps>(
|
|
12
|
-
Component: (
|
|
13
|
-
props?: T
|
|
14
|
-
) => null | JSX.Element | Promise<JSX.Element> | Promise<JSX.Element[]>,
|
|
15
|
-
options: SegmentDefaultsOptions
|
|
16
|
-
) =>
|
|
17
|
-
(props: T) => {
|
|
18
|
-
const componentProps = { ...props };
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
<Component {...componentProps} />
|
|
23
|
-
</>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
1
|
+
import { LayoutProps, PageProps, RootLayoutProps } from '../../types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
type SegmentType = 'client-root' | 'layout' | 'page';
|
|
5
|
+
|
|
6
|
+
interface SegmentDefaultsOptions {
|
|
7
|
+
segmentType: SegmentType;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const withSegmentDefaults =
|
|
11
|
+
<T extends PageProps | LayoutProps | RootLayoutProps>(
|
|
12
|
+
Component: (
|
|
13
|
+
props?: T
|
|
14
|
+
) => null | JSX.Element | Promise<JSX.Element> | Promise<JSX.Element[]>,
|
|
15
|
+
options: SegmentDefaultsOptions
|
|
16
|
+
) =>
|
|
17
|
+
(props: T) => {
|
|
18
|
+
const componentProps = { ...props };
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<Component {...componentProps} />
|
|
23
|
+
</>
|
|
24
|
+
);
|
|
25
|
+
};
|
package/hocs/server/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './with-segment-defaults';
|
|
1
|
+
export * from './with-segment-defaults';
|