@akinon/projectzero 2.0.32 → 2.0.33-rc.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 +8 -0
- package/app-template/.env.example +1 -0
- package/app-template/AGENTS.md +8 -0
- package/app-template/CHANGELOG.md +77 -0
- package/app-template/README.md +25 -1
- package/app-template/next.config.mjs +7 -1
- package/app-template/package.json +41 -41
- package/app-template/public/locales/en/checkout.json +50 -0
- package/app-template/public/locales/tr/checkout.json +50 -0
- package/app-template/src/app/[pz]/basket/page.tsx +33 -6
- package/app-template/src/app/[pz]/orders/checkout/page.tsx +57 -92
- package/app-template/src/app/api/theme-settings/route.ts +21 -2
- package/app-template/src/app/global-error.tsx +22 -0
- package/app-template/src/data/server/theme.ts +6 -25
- package/app-template/src/hooks/index.ts +2 -0
- package/app-template/src/plugins.js +1 -0
- package/app-template/src/proxy.ts +2 -1
- package/app-template/src/views/checkout/variants/basket-and-checkout/basket-section.tsx +149 -0
- package/app-template/src/views/checkout/variants/basket-and-checkout/index.tsx +132 -0
- package/app-template/src/views/checkout/variants/multi-step/index.tsx +73 -0
- package/app-template/src/views/checkout/variants/one-page/accordion-section.tsx +140 -0
- package/app-template/src/views/checkout/variants/one-page/hooks/use-checkout-funnel-gtm.ts +60 -0
- package/app-template/src/views/checkout/variants/one-page/hooks/use-section-state.ts +99 -0
- package/app-template/src/views/checkout/variants/one-page/index.tsx +125 -0
- package/app-template/src/views/checkout/variants/one-page/mobile-summary-sheet.tsx +109 -0
- package/app-template/src/views/checkout/variants/one-page/one-page-summary.tsx +237 -0
- package/app-template/src/views/checkout/variants/one-page/payment-options-grid.tsx +201 -0
- package/app-template/src/views/checkout/variants/one-page/sections/address-section.tsx +318 -0
- package/app-template/src/views/checkout/variants/one-page/sections/contact-section.tsx +62 -0
- package/app-template/src/views/checkout/variants/one-page/sections/payment-section.tsx +71 -0
- package/app-template/src/views/checkout/variants/one-page/sections/shipping-section.tsx +298 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/address-skeleton.tsx +25 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/checkout-skeleton.tsx +27 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/index.ts +6 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/payment-skeleton.tsx +23 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/section-skeleton.tsx +47 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/shipping-skeleton.tsx +20 -0
- package/app-template/src/views/checkout/variants/one-page/skeletons/summary-skeleton.tsx +38 -0
- package/app-template/src/views/checkout/variants/one-page/trust-badges.tsx +30 -0
- package/app-template/src/views/checkout/variants/registry.ts +32 -0
- package/app-template/src/views/checkout/variants/types.ts +30 -0
- package/app-template/src/views/checkout/variants/use-resolved-config.ts +89 -0
- package/app-template/src/views/header/search/index.tsx +13 -5
- package/app-template/src/views/product/slider.tsx +85 -38
- package/commands/plugins.ts +4 -0
- package/dist/commands/plugins.js +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useAppSelector } from '@akinon/next/redux/hooks';
|
|
4
|
+
import { useSetAddressesMutation } from '@akinon/next/data/client/checkout';
|
|
5
|
+
import { useAddAddressMutation } from '@akinon/next/data/client/address';
|
|
6
|
+
import { Button, Checkbox, Icon, Modal, Radio } from '@theme/components';
|
|
7
|
+
import { AddressForm } from '@theme/views/account/address-form';
|
|
8
|
+
import { useLocalization } from '@akinon/next/hooks';
|
|
9
|
+
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
10
|
+
import type { RootState } from '@theme/redux/store';
|
|
11
|
+
import type { Address } from '@akinon/next/types';
|
|
12
|
+
import AccordionSection, { SectionStatus } from '../accordion-section';
|
|
13
|
+
import { AddressListSkeleton } from '../skeletons/address-skeleton';
|
|
14
|
+
|
|
15
|
+
interface AddressSectionProps {
|
|
16
|
+
status: SectionStatus;
|
|
17
|
+
onEdit: () => void;
|
|
18
|
+
onComplete: () => void;
|
|
19
|
+
editable?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const AddressSection = ({
|
|
23
|
+
status,
|
|
24
|
+
onEdit,
|
|
25
|
+
onComplete,
|
|
26
|
+
editable = true
|
|
27
|
+
}: AddressSectionProps) => {
|
|
28
|
+
const { t } = useLocalization();
|
|
29
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
30
|
+
|
|
31
|
+
const addressList = useAppSelector(
|
|
32
|
+
(state: RootState) => state.checkout.addressList
|
|
33
|
+
);
|
|
34
|
+
const preOrder = useAppSelector(
|
|
35
|
+
(state: RootState) => state.checkout.preOrder
|
|
36
|
+
);
|
|
37
|
+
const {
|
|
38
|
+
shipping_address,
|
|
39
|
+
billing_address,
|
|
40
|
+
billing_and_shipping_same,
|
|
41
|
+
delivery_option
|
|
42
|
+
} = preOrder ?? {};
|
|
43
|
+
|
|
44
|
+
const [setAddresses, { isLoading: isSetting }] = useSetAddressesMutation();
|
|
45
|
+
const [addAddress, { isLoading: isAdding }] = useAddAddressMutation();
|
|
46
|
+
|
|
47
|
+
const [billingSameAsShipping, setBillingSameAsShipping] = useState(
|
|
48
|
+
billing_and_shipping_same ?? true
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setBillingSameAsShipping(billing_and_shipping_same ?? true);
|
|
53
|
+
}, [billing_and_shipping_same]);
|
|
54
|
+
|
|
55
|
+
const isRetailStore = delivery_option?.delivery_option_type === 'retail_store';
|
|
56
|
+
const billingMatchesShipping =
|
|
57
|
+
!!shipping_address?.pk &&
|
|
58
|
+
!!billing_address?.pk &&
|
|
59
|
+
shipping_address.pk === billing_address.pk;
|
|
60
|
+
|
|
61
|
+
const handleSelectShipping = async (address: Address) => {
|
|
62
|
+
const billingPk = billingSameAsShipping
|
|
63
|
+
? address.pk
|
|
64
|
+
: billing_address?.pk ?? address.pk;
|
|
65
|
+
await setAddresses({
|
|
66
|
+
shippingAddressPk: address.pk,
|
|
67
|
+
billingAddressPk: billingPk
|
|
68
|
+
})
|
|
69
|
+
.unwrap()
|
|
70
|
+
.catch(() => null);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleSelectBilling = async (address: Address) => {
|
|
74
|
+
if (!shipping_address?.pk) return;
|
|
75
|
+
await setAddresses({
|
|
76
|
+
shippingAddressPk: shipping_address.pk,
|
|
77
|
+
billingAddressPk: address.pk
|
|
78
|
+
})
|
|
79
|
+
.unwrap()
|
|
80
|
+
.catch(() => null);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleSameAddressToggle = async () => {
|
|
84
|
+
const next = !billingSameAsShipping;
|
|
85
|
+
setBillingSameAsShipping(next);
|
|
86
|
+
if (next && shipping_address?.pk) {
|
|
87
|
+
await setAddresses({
|
|
88
|
+
shippingAddressPk: shipping_address.pk,
|
|
89
|
+
billingAddressPk: shipping_address.pk
|
|
90
|
+
})
|
|
91
|
+
.unwrap()
|
|
92
|
+
.catch(() => null);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const handleAddAddress = async (data: Record<string, unknown>) => {
|
|
97
|
+
const response = await addAddress({
|
|
98
|
+
...data,
|
|
99
|
+
invalidateTag: 'Checkout'
|
|
100
|
+
})
|
|
101
|
+
.unwrap()
|
|
102
|
+
.catch(() => null);
|
|
103
|
+
setIsModalOpen(false);
|
|
104
|
+
if (response?.pk) {
|
|
105
|
+
const billingPk = billingSameAsShipping
|
|
106
|
+
? response.pk
|
|
107
|
+
: billing_address?.pk ?? response.pk;
|
|
108
|
+
await setAddresses({
|
|
109
|
+
shippingAddressPk: response.pk,
|
|
110
|
+
billingAddressPk: billingPk
|
|
111
|
+
})
|
|
112
|
+
.unwrap()
|
|
113
|
+
.catch(() => null);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const summary = useMemo(() => {
|
|
118
|
+
if (!shipping_address) return null;
|
|
119
|
+
return (
|
|
120
|
+
<div className="flex flex-col gap-1">
|
|
121
|
+
<span className="font-medium">{shipping_address.title}</span>
|
|
122
|
+
<span className="text-xs text-black-700">
|
|
123
|
+
{shipping_address.line} — {shipping_address.township?.name},{' '}
|
|
124
|
+
{shipping_address.city?.name}
|
|
125
|
+
</span>
|
|
126
|
+
{!billingSameAsShipping &&
|
|
127
|
+
billing_address &&
|
|
128
|
+
!billingMatchesShipping && (
|
|
129
|
+
<span className="text-xs italic text-gray-700">
|
|
130
|
+
{t('checkout.one_page.address.billing_label')}: {billing_address.title}
|
|
131
|
+
</span>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}, [
|
|
136
|
+
shipping_address,
|
|
137
|
+
billing_address,
|
|
138
|
+
billingSameAsShipping,
|
|
139
|
+
billingMatchesShipping,
|
|
140
|
+
t
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
const renderAddressCard = (
|
|
144
|
+
address: Address,
|
|
145
|
+
selected: boolean,
|
|
146
|
+
onClick: () => void,
|
|
147
|
+
name: string,
|
|
148
|
+
options?: { showSameBadge?: boolean }
|
|
149
|
+
) => (
|
|
150
|
+
<button
|
|
151
|
+
key={`${name}-${address.pk}`}
|
|
152
|
+
type="button"
|
|
153
|
+
role="radio"
|
|
154
|
+
aria-checked={selected}
|
|
155
|
+
onClick={onClick}
|
|
156
|
+
disabled={isSetting}
|
|
157
|
+
className={clsx(
|
|
158
|
+
'relative w-full rounded-sm border p-3 text-left shadow-sm transition-all',
|
|
159
|
+
'hover:border-secondary-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-secondary',
|
|
160
|
+
selected
|
|
161
|
+
? 'border-secondary-400 ring-2 ring-secondary-400/30'
|
|
162
|
+
: 'border-gray-300',
|
|
163
|
+
isSetting && 'opacity-60'
|
|
164
|
+
)}
|
|
165
|
+
data-testid={`${name}-address-${address.pk}`}
|
|
166
|
+
>
|
|
167
|
+
<div className="flex items-start gap-3">
|
|
168
|
+
<Radio name={name} checked={selected} onChange={() => null} />
|
|
169
|
+
<div className="flex flex-1 flex-col gap-1 text-xs leading-snug">
|
|
170
|
+
<div className="flex items-center gap-2">
|
|
171
|
+
<span className="font-medium text-black-800">{address.title}</span>
|
|
172
|
+
{options?.showSameBadge && (
|
|
173
|
+
<span className="rounded-sm bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-gray-700">
|
|
174
|
+
{t('checkout.one_page.address.same_as_shipping')}
|
|
175
|
+
</span>
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
178
|
+
<span className="text-black-700">{address.phone_number}</span>
|
|
179
|
+
<span className="line-clamp-2 text-black-700">{address.line}</span>
|
|
180
|
+
<span className="text-black-700">
|
|
181
|
+
{address.township?.name} / {address.city?.name}
|
|
182
|
+
</span>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</button>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const isLoadingFirstLoad = !preOrder && addressList.length === 0;
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<AccordionSection
|
|
192
|
+
step={2}
|
|
193
|
+
title={t('checkout.one_page.address.title')}
|
|
194
|
+
status={status}
|
|
195
|
+
onEdit={onEdit}
|
|
196
|
+
editable={editable}
|
|
197
|
+
summary={summary}
|
|
198
|
+
dataTestId="one-page-address"
|
|
199
|
+
>
|
|
200
|
+
{isLoadingFirstLoad ? (
|
|
201
|
+
<AddressListSkeleton />
|
|
202
|
+
) : (
|
|
203
|
+
<div className="flex flex-col gap-5">
|
|
204
|
+
<div>
|
|
205
|
+
<div className="mb-3 flex items-center justify-between gap-2">
|
|
206
|
+
<h3 className="text-sm font-medium text-black-800">
|
|
207
|
+
{t('checkout.one_page.address.shipping_label')}
|
|
208
|
+
</h3>
|
|
209
|
+
{!isRetailStore && (
|
|
210
|
+
<Checkbox
|
|
211
|
+
checked={billingSameAsShipping}
|
|
212
|
+
onChange={handleSameAddressToggle}
|
|
213
|
+
data-testid="one-page-billing-same"
|
|
214
|
+
>
|
|
215
|
+
<span className="text-xs">
|
|
216
|
+
{t('checkout.one_page.address.use_for_billing')}
|
|
217
|
+
</span>
|
|
218
|
+
</Checkbox>
|
|
219
|
+
)}
|
|
220
|
+
</div>
|
|
221
|
+
<div
|
|
222
|
+
className="grid grid-cols-1 gap-2 md:grid-cols-2"
|
|
223
|
+
role="radiogroup"
|
|
224
|
+
aria-label={t('checkout.one_page.address.shipping_label')}
|
|
225
|
+
>
|
|
226
|
+
{addressList.map((address) =>
|
|
227
|
+
renderAddressCard(
|
|
228
|
+
address,
|
|
229
|
+
shipping_address?.pk === address.pk,
|
|
230
|
+
() => handleSelectShipping(address),
|
|
231
|
+
'one-page-shipping'
|
|
232
|
+
)
|
|
233
|
+
)}
|
|
234
|
+
<PluginModule
|
|
235
|
+
component={Component.ClickCollect}
|
|
236
|
+
props={{ addressTypeParam: 'shippingAddressPk' }}
|
|
237
|
+
/>
|
|
238
|
+
<button
|
|
239
|
+
type="button"
|
|
240
|
+
onClick={() => setIsModalOpen(true)}
|
|
241
|
+
disabled={isAdding}
|
|
242
|
+
className={clsx(
|
|
243
|
+
'flex min-h-[5.5rem] items-center justify-center gap-2',
|
|
244
|
+
'rounded-sm border border-dashed border-gray-400 px-3 text-xs',
|
|
245
|
+
'text-black-700 transition-colors hover:border-secondary hover:text-secondary',
|
|
246
|
+
'focus:outline-none focus-visible:ring-2 focus-visible:ring-secondary',
|
|
247
|
+
'disabled:cursor-not-allowed disabled:opacity-50'
|
|
248
|
+
)}
|
|
249
|
+
data-testid="one-page-address-add"
|
|
250
|
+
>
|
|
251
|
+
<Icon name="plus" size={12} />
|
|
252
|
+
{t('checkout.address.add_new_address')}
|
|
253
|
+
</button>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
{!billingSameAsShipping && !isRetailStore && (
|
|
258
|
+
<div>
|
|
259
|
+
<div className="mb-3 flex items-center justify-between gap-2">
|
|
260
|
+
<h3 className="text-sm font-medium text-black-800">
|
|
261
|
+
{t('checkout.one_page.address.billing_label')}
|
|
262
|
+
</h3>
|
|
263
|
+
{billingMatchesShipping && (
|
|
264
|
+
<span className="text-xs italic text-gray-700">
|
|
265
|
+
{t('checkout.one_page.address.pick_different_billing')}
|
|
266
|
+
</span>
|
|
267
|
+
)}
|
|
268
|
+
</div>
|
|
269
|
+
<div
|
|
270
|
+
className="grid grid-cols-1 gap-2 md:grid-cols-2"
|
|
271
|
+
role="radiogroup"
|
|
272
|
+
aria-label={t('checkout.one_page.address.billing_label')}
|
|
273
|
+
>
|
|
274
|
+
{addressList.map((address) =>
|
|
275
|
+
renderAddressCard(
|
|
276
|
+
address,
|
|
277
|
+
billing_address?.pk === address.pk,
|
|
278
|
+
() => handleSelectBilling(address),
|
|
279
|
+
'one-page-billing',
|
|
280
|
+
{
|
|
281
|
+
showSameBadge:
|
|
282
|
+
billingMatchesShipping &&
|
|
283
|
+
billing_address?.pk === address.pk
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
)}
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
)}
|
|
290
|
+
|
|
291
|
+
<div className="flex justify-end">
|
|
292
|
+
<Button
|
|
293
|
+
disabled={
|
|
294
|
+
!shipping_address?.pk || !billing_address?.pk || isSetting
|
|
295
|
+
}
|
|
296
|
+
onClick={onComplete}
|
|
297
|
+
data-testid="one-page-address-continue"
|
|
298
|
+
>
|
|
299
|
+
{t('checkout.one_page.continue_to_shipping')}
|
|
300
|
+
</Button>
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
<Modal
|
|
304
|
+
portalId="one-page-add-address-modal"
|
|
305
|
+
title={t('checkout.address.add_new_address')}
|
|
306
|
+
open={isModalOpen}
|
|
307
|
+
setOpen={setIsModalOpen}
|
|
308
|
+
className="w-full max-h-[90vh] overflow-y-auto sm:w-[28rem]"
|
|
309
|
+
>
|
|
310
|
+
<AddressForm onSubmit={handleAddAddress} />
|
|
311
|
+
</Modal>
|
|
312
|
+
</div>
|
|
313
|
+
)}
|
|
314
|
+
</AccordionSection>
|
|
315
|
+
);
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export default AddressSection;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useSession } from 'next-auth/react';
|
|
2
|
+
import { useLocalization } from '@akinon/next/hooks';
|
|
3
|
+
import { Icon } from '@theme/components';
|
|
4
|
+
import AccordionSection, { SectionStatus } from '../accordion-section';
|
|
5
|
+
|
|
6
|
+
interface ContactSectionProps {
|
|
7
|
+
status: SectionStatus;
|
|
8
|
+
onEdit: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ContactSection = ({ status, onEdit }: ContactSectionProps) => {
|
|
12
|
+
const { t } = useLocalization();
|
|
13
|
+
const { data: session } = useSession();
|
|
14
|
+
|
|
15
|
+
const isGuest = !session?.user;
|
|
16
|
+
const email =
|
|
17
|
+
session?.user?.email || t('checkout.one_page.contact.guest_user');
|
|
18
|
+
const displayName = session?.user?.name || email;
|
|
19
|
+
|
|
20
|
+
const summary = (
|
|
21
|
+
<div className="flex items-center gap-2 text-sm text-black-700">
|
|
22
|
+
<Icon name="email" size={14} />
|
|
23
|
+
<span>{email}</span>
|
|
24
|
+
{isGuest && (
|
|
25
|
+
<span className="ml-2 rounded-sm border border-gray-400 px-2 py-0.5 text-xs uppercase text-gray-700">
|
|
26
|
+
{t('checkout.one_page.contact.guest_badge')}
|
|
27
|
+
</span>
|
|
28
|
+
)}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<AccordionSection
|
|
34
|
+
step={1}
|
|
35
|
+
title={t('checkout.one_page.contact.title')}
|
|
36
|
+
status={status}
|
|
37
|
+
onEdit={onEdit}
|
|
38
|
+
editable={false}
|
|
39
|
+
summary={summary}
|
|
40
|
+
dataTestId="one-page-contact"
|
|
41
|
+
>
|
|
42
|
+
<div className="flex flex-col gap-3">
|
|
43
|
+
<div className="flex items-start gap-3 rounded-sm border border-gray-200 bg-gray-50 px-4 py-3">
|
|
44
|
+
<Icon name="account" size={18} className="mt-0.5 fill-secondary" />
|
|
45
|
+
<div className="flex flex-col">
|
|
46
|
+
<span className="text-sm font-medium text-black-800">
|
|
47
|
+
{displayName}
|
|
48
|
+
</span>
|
|
49
|
+
<span className="text-xs text-black-700">{email}</span>
|
|
50
|
+
{isGuest && (
|
|
51
|
+
<span className="mt-1 text-xs italic text-gray-700">
|
|
52
|
+
{t('checkout.one_page.contact.guest_note')}
|
|
53
|
+
</span>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</AccordionSection>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default ContactSection;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { useAppSelector } from '@akinon/next/redux/hooks';
|
|
3
|
+
import { useLocalization } from '@akinon/next/hooks';
|
|
4
|
+
import SelectedPaymentOptionView from '@akinon/next/components/selected-payment-option-view';
|
|
5
|
+
import type { RootState } from '@theme/redux/store';
|
|
6
|
+
import AccordionSection, { SectionStatus } from '../accordion-section';
|
|
7
|
+
import PaymentOptionsGrid from '../payment-options-grid';
|
|
8
|
+
import { PaymentGridSkeleton } from '../skeletons/payment-skeleton';
|
|
9
|
+
|
|
10
|
+
interface PaymentSectionProps {
|
|
11
|
+
status: SectionStatus;
|
|
12
|
+
onEdit: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const PaymentSection = ({ status, onEdit }: PaymentSectionProps) => {
|
|
16
|
+
const { t } = useLocalization();
|
|
17
|
+
const isPaymentStepBusy = useAppSelector(
|
|
18
|
+
(state: RootState) => state.checkout.steps.payment.busy
|
|
19
|
+
);
|
|
20
|
+
const paymentOption = useAppSelector(
|
|
21
|
+
(state: RootState) => state.checkout.preOrder?.payment_option
|
|
22
|
+
);
|
|
23
|
+
const paymentOptionsCount = useAppSelector(
|
|
24
|
+
(state: RootState) => state.checkout.paymentOptions.length
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<AccordionSection
|
|
29
|
+
step={4}
|
|
30
|
+
title={t('checkout.one_page.payment.title')}
|
|
31
|
+
status={status}
|
|
32
|
+
onEdit={onEdit}
|
|
33
|
+
editable={false}
|
|
34
|
+
dataTestId="one-page-payment"
|
|
35
|
+
padded={false}
|
|
36
|
+
>
|
|
37
|
+
<div
|
|
38
|
+
className={clsx({
|
|
39
|
+
'pointer-events-none opacity-50': isPaymentStepBusy
|
|
40
|
+
})}
|
|
41
|
+
>
|
|
42
|
+
<div className="px-5 py-5">
|
|
43
|
+
{paymentOptionsCount === 0 ? (
|
|
44
|
+
<PaymentGridSkeleton />
|
|
45
|
+
) : (
|
|
46
|
+
<PaymentOptionsGrid />
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
{paymentOption && (
|
|
51
|
+
<div
|
|
52
|
+
className="border-t border-gray-200"
|
|
53
|
+
data-testid="one-page-selected-payment"
|
|
54
|
+
>
|
|
55
|
+
<SelectedPaymentOptionView />
|
|
56
|
+
</div>
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
{!paymentOption && paymentOptionsCount > 0 && (
|
|
60
|
+
<div className="border-t border-gray-200 bg-gray-50/30 px-5 py-4">
|
|
61
|
+
<p className="text-sm italic text-gray-700">
|
|
62
|
+
{t('checkout.one_page.payment.select_method')}
|
|
63
|
+
</p>
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
</AccordionSection>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default PaymentSection;
|