Appearance
Usage
The Authentified React Widget comes with 2 components: A provider, and a button. The provider wraps your order list, and provides the ability to check the resale status of items within it.
1. Add the Provider
Wrap your line items with the AuthentifiedProvider
.
tsx
import { AuthentifiedProvider } from "@authentified/react-widget"
import { OrderListComponent } from "./orderList"
export const OrdersPage = ({ orders }) => {
return (
<AuthentifiedProvider>
<OrderListComponent orders={orders} />
</AuthentifiedProvider>
)
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
2. Add the button
Now that the AuthentifiedProvider
is in place, you can add the button next to each line item in the customer's orders.
ts
import { AuthentifiedProvider, AuthentifiedButton } from "@authentified/react-widget"
export const OrderListComponent = ({ orders }) {
return (
<section>
{orders.map(order => (
<article key={order.id}>
<h2>{lineItem.product.name}</h2>
<h3>#{order.id}</h3>
<div>
{order.lineItems.map(lineItem => (
<AuthentifiedButton
variantId={lineItem.id}
productId={lineItem.product.id}
orderId={order.id}
shopId={process.env.SHOP_ID}
/>
))}
</div>
</article>
))}
</section>
)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
NOTE
If you are using the Storefront API to output orders, the OrderLineItem does not come with an id property, so you will need to use the variantId instead
ts
import { AuthentifiedProvider, AuthentifiedButton } from "@authentified/react-widget"
export const OrderListComponent = ({ orders }) {
return (
<section>
{orders.map(order => (
<article key={order.id}>
<h2>{lineItem.product.name}</h2>
<h3>#{order.id}</h3>
<div>
{order.lineItems.map(lineItem => (
<AuthentifiedButton
variantId={lineItem.variant.id}
productId={lineItem.product.id}
orderId={order.id}
shopId={process.env.SHOP_ID}
/>
))}
</div>
</article>
))}
</section>
)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Offline Orders
By default, orders are assumed to be from Shopify. If you wish to consign offline orders, you need to specify the type prop.
ts
import { AuthentifiedProvider, AuthentifiedButton } from "@authentified/react-widget"
export const OfflineOrderListComponent = ({ offlineOrders }) {
return (
<section>
{offlineOrders.map(order => (
<article key={order.id}>
<h2>{lineItem.product.name}</h2>
<h3>#{order.id}</h3>
<div>
{order.lineItems.map(lineItem => (
<AuthentifiedButton
variantId={lineItem.variant.id}
productId={lineItem.product.id}
orderId={order.id}
shopId={process.env.SHOP_ID}
type="offline"
/>
))}
</div>
</article>
))}
</section>
)
}
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25