|
3 | 3 | import { getModalPositionCss, ShadowRoot, useConnectConfigContext, useTheme } from '@0xsequence/connect'
|
4 | 4 | import { Modal } from '@0xsequence/design-system'
|
5 | 5 | import { AnimatePresence } from 'motion/react'
|
6 |
| -import React, { useEffect, useState, type ReactNode } from 'react' |
| 6 | +import { useEffect, useState, type ReactNode } from 'react' |
7 | 7 |
|
8 | 8 | import {
|
9 | 9 | AddFundsContextProvider,
|
@@ -212,169 +212,167 @@ export const SequenceCheckoutProvider = ({ children, config }: SequenceCheckoutP
|
212 | 212 | forteWidgetUrl: config?.env?.forteWidgetUrl ?? 'https://client.payments.forte.io/forte-payments-widget.js'
|
213 | 213 | }}
|
214 | 214 | >
|
215 |
| - <FortePaymentControllerProvider> |
216 |
| - <SwapModalContextProvider |
| 215 | + <SwapModalContextProvider |
| 216 | + value={{ |
| 217 | + isSwapModalOpen: isOpenSwapModal, |
| 218 | + openSwapModal, |
| 219 | + closeSwapModal, |
| 220 | + swapModalSettings |
| 221 | + }} |
| 222 | + > |
| 223 | + <TransactionStatusModalContextProvider |
217 | 224 | value={{
|
218 |
| - isSwapModalOpen: isOpenSwapModal, |
219 |
| - openSwapModal, |
220 |
| - closeSwapModal, |
221 |
| - swapModalSettings |
| 225 | + openTransactionStatusModal: triggerTransactionStatusModal, |
| 226 | + closeTransactionStatusModal, |
| 227 | + transactionStatusSettings |
222 | 228 | }}
|
223 | 229 | >
|
224 |
| - <TransactionStatusModalContextProvider |
| 230 | + <SelectPaymentContextProvider |
225 | 231 | value={{
|
226 |
| - openTransactionStatusModal: triggerTransactionStatusModal, |
227 |
| - closeTransactionStatusModal, |
228 |
| - transactionStatusSettings |
| 232 | + openSelectPaymentModal, |
| 233 | + closeSelectPaymentModal, |
| 234 | + selectPaymentSettings |
229 | 235 | }}
|
230 | 236 | >
|
231 |
| - <SelectPaymentContextProvider |
| 237 | + <AddFundsContextProvider |
232 | 238 | value={{
|
233 |
| - openSelectPaymentModal, |
234 |
| - closeSelectPaymentModal, |
235 |
| - selectPaymentSettings |
| 239 | + isAddFundsModalOpen: openAddFundsModal, |
| 240 | + triggerAddFunds, |
| 241 | + closeAddFunds, |
| 242 | + addFundsSettings |
236 | 243 | }}
|
237 | 244 | >
|
238 |
| - <AddFundsContextProvider |
| 245 | + <CheckoutModalContextProvider |
239 | 246 | value={{
|
240 |
| - isAddFundsModalOpen: openAddFundsModal, |
241 |
| - triggerAddFunds, |
242 |
| - closeAddFunds, |
243 |
| - addFundsSettings |
| 247 | + triggerCheckout, |
| 248 | + closeCheckout, |
| 249 | + settings, |
| 250 | + theme |
244 | 251 | }}
|
245 | 252 | >
|
246 |
| - <CheckoutModalContextProvider |
| 253 | + <TransferFundsContextProvider |
247 | 254 | value={{
|
248 |
| - triggerCheckout, |
249 |
| - closeCheckout, |
250 |
| - settings, |
251 |
| - theme |
| 255 | + openTransferFundsModal: openTransferFunds, |
| 256 | + closeTransferFundsModal: closeTransferFunds, |
| 257 | + transferFundsSettings |
252 | 258 | }}
|
253 | 259 | >
|
254 |
| - <TransferFundsContextProvider |
255 |
| - value={{ |
256 |
| - openTransferFundsModal: openTransferFunds, |
257 |
| - closeTransferFundsModal: closeTransferFunds, |
258 |
| - transferFundsSettings |
259 |
| - }} |
260 |
| - > |
261 |
| - <NavigationContextProvider value={{ history, setHistory, defaultLocation: getDefaultLocation() }}> |
262 |
| - <ForteController> |
263 |
| - <ShadowRoot theme={theme} customCSS={customCSS}> |
264 |
| - <AnimatePresence> |
265 |
| - {openCheckoutModal && ( |
266 |
| - <Modal |
267 |
| - contentProps={{ |
268 |
| - style: { |
269 |
| - maxWidth: '540px', |
270 |
| - height: 'auto', |
271 |
| - ...getModalPositionCss(position) |
272 |
| - } |
273 |
| - }} |
274 |
| - scroll={false} |
275 |
| - onClose={() => setOpenCheckoutModal(false)} |
276 |
| - > |
277 |
| - <div id="sequence-kit-checkout-content"> |
278 |
| - {getCheckoutHeader()} |
279 |
| - {getCheckoutContent()} |
280 |
| - </div> |
281 |
| - </Modal> |
282 |
| - )} |
283 |
| - {openAddFundsModal && ( |
284 |
| - <Modal |
285 |
| - contentProps={{ |
286 |
| - style: { |
287 |
| - maxWidth: '540px', |
288 |
| - height: 'auto', |
289 |
| - ...getModalPositionCss(position) |
290 |
| - } |
291 |
| - }} |
292 |
| - scroll={false} |
293 |
| - onClose={closeAddFunds} |
294 |
| - > |
295 |
| - <div id="sequence-kit-add-funds-content"> |
296 |
| - {getAddFundsHeader()} |
297 |
| - {getAddFundsContent()} |
298 |
| - </div> |
299 |
| - </Modal> |
300 |
| - )} |
301 |
| - {openPaymentSelectionModal && ( |
302 |
| - <Modal |
303 |
| - contentProps={{ |
304 |
| - style: { |
305 |
| - maxWidth: '420px', |
306 |
| - ...getModalPositionCss(position), |
307 |
| - scrollbarColor: 'gray black', |
308 |
| - scrollbarWidth: 'thin' |
309 |
| - } |
310 |
| - }} |
311 |
| - onClose={() => setOpenPaymentSelectionModal(false)} |
312 |
| - > |
313 |
| - <div id="sequence-kit-payment-selection-content"> |
314 |
| - <PaymentSelection /> |
315 |
| - </div> |
316 |
| - </Modal> |
317 |
| - )} |
318 |
| - {openTransferFundsModal && ( |
319 |
| - <Modal |
320 |
| - contentProps={{ |
321 |
| - style: { |
322 |
| - height: 'auto', |
323 |
| - ...getModalPositionCss(position) |
324 |
| - } |
325 |
| - }} |
326 |
| - onClose={closeTransferFunds} |
327 |
| - > |
328 |
| - <div id="sequence-kit-transfer-funds-modal"> |
329 |
| - <NavigationHeader primaryText="Receive" /> |
330 |
| - <TransferToWallet /> |
331 |
| - </div> |
332 |
| - </Modal> |
333 |
| - )} |
334 |
| - {openTransactionStatusModal && ( |
335 |
| - <Modal |
336 |
| - contentProps={{ |
337 |
| - style: { |
338 |
| - height: 'auto', |
339 |
| - ...getModalPositionCss(position) |
340 |
| - } |
341 |
| - }} |
342 |
| - onClose={closeTransactionStatusModal} |
343 |
| - > |
344 |
| - <div id="sequence-kit-transaction-status-modal"> |
345 |
| - <TransactionStatus /> |
346 |
| - </div> |
347 |
| - </Modal> |
348 |
| - )} |
349 |
| - {isOpenSwapModal && ( |
350 |
| - <Modal |
351 |
| - contentProps={{ |
352 |
| - style: { |
353 |
| - maxWidth: '450px', |
354 |
| - height: 'auto', |
355 |
| - ...getModalPositionCss(position) |
356 |
| - } |
357 |
| - }} |
358 |
| - onClose={closeSwapModal} |
359 |
| - > |
360 |
| - <div id="sequence-kit-swap-modal"> |
361 |
| - <NavigationHeader primaryText={swapModalSettings?.title || 'Swap'} /> |
362 |
| - <Swap /> |
363 |
| - </div> |
364 |
| - </Modal> |
365 |
| - )} |
366 |
| - </AnimatePresence> |
367 |
| - </ShadowRoot> |
368 |
| - {children} |
369 |
| - </ForteController> |
370 |
| - </NavigationContextProvider> |
371 |
| - </TransferFundsContextProvider> |
372 |
| - </CheckoutModalContextProvider> |
373 |
| - </AddFundsContextProvider> |
374 |
| - </SelectPaymentContextProvider> |
375 |
| - </TransactionStatusModalContextProvider> |
376 |
| - </SwapModalContextProvider> |
377 |
| - </FortePaymentControllerProvider> |
| 260 | + <NavigationContextProvider value={{ history, setHistory, defaultLocation: getDefaultLocation() }}> |
| 261 | + <ForteController> |
| 262 | + <ShadowRoot theme={theme} customCSS={customCSS}> |
| 263 | + <AnimatePresence> |
| 264 | + {openCheckoutModal && ( |
| 265 | + <Modal |
| 266 | + contentProps={{ |
| 267 | + style: { |
| 268 | + maxWidth: '540px', |
| 269 | + height: 'auto', |
| 270 | + ...getModalPositionCss(position) |
| 271 | + } |
| 272 | + }} |
| 273 | + scroll={false} |
| 274 | + onClose={() => setOpenCheckoutModal(false)} |
| 275 | + > |
| 276 | + <div id="sequence-kit-checkout-content"> |
| 277 | + {getCheckoutHeader()} |
| 278 | + {getCheckoutContent()} |
| 279 | + </div> |
| 280 | + </Modal> |
| 281 | + )} |
| 282 | + {openAddFundsModal && ( |
| 283 | + <Modal |
| 284 | + contentProps={{ |
| 285 | + style: { |
| 286 | + maxWidth: '540px', |
| 287 | + height: 'auto', |
| 288 | + ...getModalPositionCss(position) |
| 289 | + } |
| 290 | + }} |
| 291 | + scroll={false} |
| 292 | + onClose={closeAddFunds} |
| 293 | + > |
| 294 | + <div id="sequence-kit-add-funds-content"> |
| 295 | + {getAddFundsHeader()} |
| 296 | + {getAddFundsContent()} |
| 297 | + </div> |
| 298 | + </Modal> |
| 299 | + )} |
| 300 | + {openPaymentSelectionModal && ( |
| 301 | + <Modal |
| 302 | + contentProps={{ |
| 303 | + style: { |
| 304 | + maxWidth: '420px', |
| 305 | + ...getModalPositionCss(position), |
| 306 | + scrollbarColor: 'gray black', |
| 307 | + scrollbarWidth: 'thin' |
| 308 | + } |
| 309 | + }} |
| 310 | + onClose={() => setOpenPaymentSelectionModal(false)} |
| 311 | + > |
| 312 | + <div id="sequence-kit-payment-selection-content"> |
| 313 | + <PaymentSelection /> |
| 314 | + </div> |
| 315 | + </Modal> |
| 316 | + )} |
| 317 | + {openTransferFundsModal && ( |
| 318 | + <Modal |
| 319 | + contentProps={{ |
| 320 | + style: { |
| 321 | + height: 'auto', |
| 322 | + ...getModalPositionCss(position) |
| 323 | + } |
| 324 | + }} |
| 325 | + onClose={closeTransferFunds} |
| 326 | + > |
| 327 | + <div id="sequence-kit-transfer-funds-modal"> |
| 328 | + <NavigationHeader primaryText="Receive" /> |
| 329 | + <TransferToWallet /> |
| 330 | + </div> |
| 331 | + </Modal> |
| 332 | + )} |
| 333 | + {openTransactionStatusModal && ( |
| 334 | + <Modal |
| 335 | + contentProps={{ |
| 336 | + style: { |
| 337 | + height: 'auto', |
| 338 | + ...getModalPositionCss(position) |
| 339 | + } |
| 340 | + }} |
| 341 | + onClose={closeTransactionStatusModal} |
| 342 | + > |
| 343 | + <div id="sequence-kit-transaction-status-modal"> |
| 344 | + <TransactionStatus /> |
| 345 | + </div> |
| 346 | + </Modal> |
| 347 | + )} |
| 348 | + {isOpenSwapModal && ( |
| 349 | + <Modal |
| 350 | + contentProps={{ |
| 351 | + style: { |
| 352 | + maxWidth: '450px', |
| 353 | + height: 'auto', |
| 354 | + ...getModalPositionCss(position) |
| 355 | + } |
| 356 | + }} |
| 357 | + onClose={closeSwapModal} |
| 358 | + > |
| 359 | + <div id="sequence-kit-swap-modal"> |
| 360 | + <NavigationHeader primaryText={swapModalSettings?.title || 'Swap'} /> |
| 361 | + <Swap /> |
| 362 | + </div> |
| 363 | + </Modal> |
| 364 | + )} |
| 365 | + </AnimatePresence> |
| 366 | + </ShadowRoot> |
| 367 | + {children} |
| 368 | + </ForteController> |
| 369 | + </NavigationContextProvider> |
| 370 | + </TransferFundsContextProvider> |
| 371 | + </CheckoutModalContextProvider> |
| 372 | + </AddFundsContextProvider> |
| 373 | + </SelectPaymentContextProvider> |
| 374 | + </TransactionStatusModalContextProvider> |
| 375 | + </SwapModalContextProvider> |
378 | 376 | </EnvironmentContextProvider>
|
379 | 377 | )
|
380 | 378 | }
|
0 commit comments