Skip to content

Commit ffd859f

Browse files
committed
feat: add loader to payment step with third party payment providers
1 parent bb4cdb2 commit ffd859f

11 files changed

Lines changed: 394 additions & 397 deletions

components/composite/Checkout/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ const Checkout: React.FC<Props> = ({
116116
)
117117
}
118118

119+
const isPaymentLoading = checkoutAlreadyStarted && !ctx.isComplete
120+
119121
const renderSteps = () => {
120122
return (
121123
<CustomerContainer isGuest={ctx.isGuest}>
@@ -223,7 +225,7 @@ const Checkout: React.FC<Props> = ({
223225
}
224226
>
225227
<div>
226-
<StepPayment />
228+
<StepPayment isPaymentLoading={isPaymentLoading} />
227229
</div>
228230
</AccordionItem>
229231
<StepPlaceOrder

components/composite/StepPayment/CheckoutCustomerPayment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface Props {
2323
hasTitle: boolean
2424
autoSelectCallback: () => void
2525
hasSubscriptions: boolean
26+
isPaymentLoading: boolean
2627
}
2728

2829
type TTemplateCustomerCards = Parameters<
@@ -95,11 +96,13 @@ export const CheckoutCustomerPayment: React.FC<Props> = ({
9596
hasTitle,
9697
autoSelectCallback,
9798
hasSubscriptions,
99+
isPaymentLoading,
98100
}) => {
99101
return (
100102
<>
101103
<PaymentMethod
102104
autoSelectSinglePaymentMethod={autoSelectCallback}
105+
showLoader={isPaymentLoading}
103106
activeClass="active group"
104107
className="payment"
105108
loader={<PaymentSkeleton />}

components/composite/StepPayment/CheckoutPayment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ interface Props {
1212
selectPayment: Parameters<typeof PaymentMethod>[0]["onClick"]
1313
hasTitle: boolean
1414
autoSelectCallback: () => void
15+
isPaymentLoading: boolean
1516
}
1617

1718
export const CheckoutPayment = ({
1819
selectPayment,
1920
hasTitle,
2021
autoSelectCallback,
22+
isPaymentLoading,
2123
}: Props): JSX.Element => {
2224
return (
2325
<PaymentMethod
26+
showLoader={isPaymentLoading}
2427
autoSelectSinglePaymentMethod={autoSelectCallback}
2528
activeClass="active"
2629
className="payment group"

components/composite/StepPayment/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export const StepHeaderPayment: React.FC<HeaderProps> = ({ step }) => {
8080
)
8181
}
8282

83-
export const StepPayment: React.FC = () => {
83+
export const StepPayment: React.FC<{ isPaymentLoading: boolean }> = ({
84+
isPaymentLoading,
85+
}) => {
8486
const appCtx = useContext(AppContext)
8587
const accordionCtx = useContext(AccordionContext)
8688
const [hasMultiplePaymentMethods, setHasMultiplePaymentMethods] =
@@ -135,13 +137,15 @@ export const StepPayment: React.FC = () => {
135137
{isPaymentRequired ? (
136138
isGuest ? (
137139
<CheckoutPayment
140+
isPaymentLoading={isPaymentLoading}
138141
selectPayment={selectPayment}
139142
autoSelectCallback={autoSelectCallback}
140143
hasTitle={hasTitle}
141144
/>
142145
) : (
143146
<>
144147
<CheckoutCustomerPayment
148+
isPaymentLoading={isPaymentLoading}
145149
selectPayment={selectPayment}
146150
autoSelectCallback={autoSelectCallback}
147151
hasTitle={hasTitle}

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@
7575
"dependencies": {
7676
"@commercelayer/js-auth": "^6.7.2",
7777
"@commercelayer/organization-config": "^2.3.0",
78-
"@commercelayer/react-components": "4.25.1",
79-
"@commercelayer/sdk": "^6.44.0",
80-
"@faker-js/faker": "^9.8.0",
81-
"@headlessui/react": "^2.2.4",
82-
"@next/bundle-analyzer": "^15.3.4",
83-
"@next/eslint-plugin-next": "^15.3.4",
78+
"@commercelayer/react-components": "4.25.2",
79+
"@commercelayer/sdk": "^6.45.0",
80+
"@faker-js/faker": "^9.9.0",
81+
"@headlessui/react": "^2.2.5",
82+
"@next/bundle-analyzer": "^15.4.3",
83+
"@next/eslint-plugin-next": "^15.4.3",
8484
"@tailwindcss/forms": "^0.5.10",
8585
"@types/async-retry": "1.4.8",
8686
"@types/node": "^22.15.29",
@@ -95,34 +95,34 @@
9595
"cron-parser": "^5.3.0",
9696
"cronstrue": "^2.61.0",
9797
"dotenv": "^16.5.0",
98-
"i18next": "^25.2.1",
99-
"next": "^15.3.4",
98+
"i18next": "^25.3.2",
99+
"next": "^15.4.3",
100100
"next-build-id": "^3.0.0",
101101
"next-i18next": "^15.4.2",
102102
"postcss": "^8.5.6",
103103
"react": "^18.3.1",
104104
"react-dom": "^18.3.1",
105105
"react-gtm-module": "^2.0.11",
106-
"react-i18next": "^15.5.3",
106+
"react-i18next": "^15.6.1",
107107
"react-router-dom": "^6.28.0",
108108
"styled-components": "^6.1.19",
109109
"tailwindcss": "^3.4.14",
110110
"twin.macro": "^3.4.1",
111111
"typescript": "^5.8.3"
112112
},
113113
"devDependencies": {
114-
"@biomejs/biome": "^2.0.0",
115-
"@playwright/test": "1.53.1",
114+
"@biomejs/biome": "^2.1.2",
115+
"@playwright/test": "1.54.1",
116116
"@semantic-release/changelog": "^6.0.3",
117117
"@semantic-release/commit-analyzer": "^13.0.1",
118118
"@semantic-release/git": "^10.0.1",
119119
"@semantic-release/github": "^11.0.3",
120-
"@semantic-release/npm": "^12.0.1",
120+
"@semantic-release/npm": "^12.0.2",
121121
"@semantic-release/release-notes-generator": "^14.0.3",
122-
"npm-check-updates": "^18.0.1",
123-
"semantic-release": "^24.2.5",
122+
"npm-check-updates": "^18.0.2",
123+
"semantic-release": "^24.2.7",
124124
"serve": "^14.2.4",
125-
"stylelint": "^16.21.0",
125+
"stylelint": "^16.22.0",
126126
"stylelint-config-standard": "^36.0.1"
127127
},
128128
"resolutions": {

playwright.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { type PlaywrightTestConfig, devices } from "@playwright/test"
2-
import dotenv from "dotenv"
3-
41
import path from "node:path"
2+
import { devices, type PlaywrightTestConfig } from "@playwright/test"
3+
import dotenv from "dotenv"
54

65
dotenv.config({ path: path.resolve(__dirname, "./.env.local") })
76

0 commit comments

Comments
 (0)