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.
Add the Provider
Wrap your orders page with the Authentified Provider:
ts
import { AuthentifiedProvider } from "@authentified/react-widget"
import Orders from "./components/orders"
export default function OrderPage({ orders }) {
return <AuthentifiedProvider>
<Orders orders={orders}>
</AuthentifiedProvider>
}1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Add the button
Then you need to loop through the orders, then again through the items to output the button next to each item.
ts
import { AuthentifiedProvider, AuthentifiedButton } from "@authentified/react-widget"
const ResellButton = ({ lineItemId, productId, orderId, shopId }) => {
return (
<AuthentifiedButton className="btn btn-secondary"
lineItemId={lineItemId}
productId={productId}
orderId={orderId}
shopId={shopId}
/>
)
}
export default function OrdersComponent({ orders, customer }) {
// Find your store ID by going to https://admin.shopify.com/store/{your_store_name}/settings/general.json
const STORE_ID = 12345678910
return orders.map(order => (
<section key={order.id}>
<h3>#{order.id}</h3>
<div>
{order.lineItems.map(lineItem => (
<ResellButton lineItemId={lineItem.id} orderId={order.id} product={lineItem.product.id} shopId={STORE_ID} />
))}
</div>
</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
26
27
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
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"
const ResellButton = ({ variantId, productId, orderId, shopId }) => {
return (
<AuthentifiedButton className="btn btn-secondary"
variantId={variantId}
productId={productId}
orderId={orderId}
shopId={shopId}
/>
)
}
export default function OrdersComponent({ orders, customer }) {
// Find your store ID by going to https://admin.shopify.com/store/{your_store_name}/settings/general.json
const STORE_ID = 12345678910
return orders.map(order => (
<section key={order.id}>
<h3>#{order.id}</h3>
<div>
{order.lineItems.map(lineItem => (
<ResellButton variantId={lineItem.variant.id} orderId={order.id} product={lineItem.product.id} shopId={STORE_ID} />
))}
</div>
</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
26
27
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
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.
import { AuthentifiedProvider, AuthentifiedButton } from "@authentified/react-widget"
const OfflineResellButton = ({ variantId, productId, orderId, shopId }) => {
return (
<AuthentifiedButton className="btn btn-secondary"
variantId={variantId}
productId={productId}
orderId={orderId}
shopId={shopId}
type="offline"
/>
)
}1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Types
ts
export interface AuthentifiedProviderProps extends PropsWithChildren {
baseUrl?: string
environment?: "production" | "development"
}
export type AuthentifiedButtonOrderType = "offline" | "shopify"
export type AuthentifiedButtonScope = "lineItem" | "order"
export interface AuthentifiedButtonCommonProps extends HTMLAttributes<HTMLAnchorElement> {
orderId: number | string
shopId: number | string
customerId: number | string
scope?: AuthentifiedButtonScope
type?: AuthentifiedButtonOrderType
}
export type AuthentifiedButtonLineItemIdButtonProps = {
lineItemId: number | string
variantId?: never
}
export type AuthentifiedButtonVariantIdButtonProps = {
lineItemId?: never
variantId: number | string
}
export type AuthentifiedOrderButtonProps = AuthentifiedButtonCommonProps & {
scope: "order"
variantId?: never
productId?: never
lineItemId?: never
}
export type AuthentifiedLineItemButtonProps = AuthentifiedButtonCommonProps & {
scope: "lineItem"
productId: number | string
} & (AuthentifiedButtonLineItemIdButtonProps | AuthentifiedButtonVariantIdButtonProps)
export type AuthentifiedButtonProps = AuthentifiedLineItemButtonProps | AuthentifiedOrderButtonProps1
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
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