-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathuse-payment-methods.tsx
More file actions
43 lines (39 loc) · 1.26 KB
/
use-payment-methods.tsx
File metadata and controls
43 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import {usePaymentMethodsForOrder} from '@salesforce/commerce-sdk-react'
import Json from '../components/Json'
import {useParams} from 'react-router-dom'
function UsePaymentMethods() {
const {orderNo}: {orderNo: string} = useParams()
const {data, isLoading, error} = usePaymentMethodsForOrder({parameters: {orderNo: orderNo}})
if (isLoading) {
return (
<div>
<h1>usePaymentMethods page</h1>
<h2 style={{background: 'aqua'}}>Loading...</h2>
</div>
)
}
if (error) {
return <h1 style={{color: 'red'}}>Something is wrong</h1>
}
return (
<>
<h1>Payment Methods</h1>
<h3>Order #: {orderNo}</h3>
<h2>{data?.name}</h2>
<hr />
<div>
<div>Returning Data</div>
<Json data={{isLoading, error, data}} />
</div>
</>
)
}
UsePaymentMethods.getTemplateName = () => 'UsePaymentMethods'
export default UsePaymentMethods