-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathuse-shopper-get-order.tsx
More file actions
44 lines (40 loc) · 1.34 KB
/
use-shopper-get-order.tsx
File metadata and controls
44 lines (40 loc) · 1.34 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
44
/*
* 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 {useOrder} from '@salesforce/commerce-sdk-react'
import {Link, useParams} from 'react-router-dom'
import Json from '../components/Json'
function UseShopperGetOrder() {
const {orderNo}: {orderNo: string} = useParams()
const {data, isLoading, error} = useOrder({parameters: {orderNo}})
if (isLoading) {
return (
<div>
<h1>useOrder page</h1>
<h2 style={{background: 'aqua'}}>Loading...</h2>
</div>
)
}
if (error) {
return <h1 style={{color: 'red'}}>Something is wrong</h1>
}
return (
<>
<h1>Order Information</h1>
<h3>Order #: {orderNo}</h3>
<div>Click on the link to go to the payment methods page</div>
<Link to={`/orders/${orderNo}/payment-methods`}>Payment Methods</Link>
<hr />
<div>
<div>Returning Data</div>
<Json data={{isLoading, error, data}} />
</div>
</>
)
}
UseShopperGetOrder.getTemplateName = () => 'UseShopperGetOrder'
export default UseShopperGetOrder