create-nymbal-app 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/index.d.ts +13 -2
  4. package/dist/index.js +45 -12
  5. package/dist/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/scaffold/templates/astro/README.md +49 -15
  8. package/scaffold/templates/astro/_dot.env.example +3 -1
  9. package/scaffold/templates/astro/astro.config.mjs +3 -0
  10. package/scaffold/templates/astro/package.json +25 -25
  11. package/scaffold/templates/astro/src/layouts/AccountLayout.astro +3 -6
  12. package/scaffold/templates/astro/src/layouts/BaseLayout.astro +5 -2
  13. package/scaffold/templates/astro/src/lib/api.ts +119 -13
  14. package/scaffold/templates/astro/src/lib/client.ts +9 -3
  15. package/scaffold/templates/astro/src/lib/page-policy.ts +24 -0
  16. package/scaffold/templates/astro/src/lib/reviews.ts +6 -0
  17. package/scaffold/templates/astro/src/lib/seo.ts +14 -1
  18. package/scaffold/templates/astro/src/lib/submit-once.ts +15 -2
  19. package/scaffold/templates/astro/src/middleware.ts +19 -10
  20. package/scaffold/templates/astro/src/pages/account/index.astro +1 -0
  21. package/scaffold/templates/astro/src/pages/account/orders/[orderNumber].astro +1 -1
  22. package/scaffold/templates/astro/src/pages/alerts/confirm.astro +3 -2
  23. package/scaffold/templates/astro/src/pages/alerts/unsubscribe.astro +3 -2
  24. package/scaffold/templates/astro/src/pages/cart.astro +18 -4
  25. package/scaffold/templates/astro/src/pages/checkout.astro +9 -2
  26. package/scaffold/templates/astro/src/pages/order/[orderNumber].astro +186 -60
  27. package/scaffold/templates/astro/src/pages/product/[slug].astro +10 -4
  28. package/scaffold/templates/astro/src/pages/products/index.astro +2 -1
  29. package/scaffold/templates/astro/src/scripts/order-access.ts +181 -0
  30. package/scaffold/templates/astro/src/scripts/pdp.ts +1 -0
  31. package/scaffold/templates/astro/src/scripts/plp.ts +1 -0
  32. package/scaffold/templates/astro/src/scripts/search.ts +1 -0
  33. package/scaffold/templates/astro/src/scripts/signed-in-redirect.ts +14 -1
  34. package/scaffold/templates/astro/src/styles/global.css +3 -0
  35. package/scaffold/templates/astro/src/styles/pages/pdp.css +7 -4
  36. package/scaffold/templates/nextjs/README.md +49 -15
  37. package/scaffold/templates/nextjs/_dot.env.example +3 -1
  38. package/scaffold/templates/nextjs/app/(catalog)/home/[key]/page.tsx +2 -2
  39. package/scaffold/templates/nextjs/app/(catalog)/product/[slug]/page.tsx +24 -20
  40. package/scaffold/templates/nextjs/app/(catalog)/products/page.tsx +8 -5
  41. package/scaffold/templates/nextjs/app/(catalog)/search/SearchView.tsx +1 -1
  42. package/scaffold/templates/nextjs/app/(shopper)/account/login/LoginView.tsx +4 -4
  43. package/scaffold/templates/nextjs/app/(shopper)/account/login/page.tsx +3 -1
  44. package/scaffold/templates/nextjs/app/(shopper)/alerts/actions.ts +6 -3
  45. package/scaffold/templates/nextjs/app/(shopper)/cart/page.tsx +21 -5
  46. package/scaffold/templates/nextjs/app/(shopper)/checkout/CheckoutView.tsx +6 -2
  47. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/OrderDetails.tsx +23 -0
  48. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/OrderEmailPrompt.tsx +112 -0
  49. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/OrderLinkForm.tsx +89 -0
  50. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/OrderNotFound.tsx +30 -0
  51. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/OrderView.tsx +140 -0
  52. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/OwnerRedirect.tsx +48 -0
  53. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/actions.ts +56 -0
  54. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/not-found.tsx +6 -0
  55. package/scaffold/templates/nextjs/app/(shopper)/order/[orderNumber]/page.tsx +9 -137
  56. package/scaffold/templates/nextjs/app/error.tsx +9 -3
  57. package/scaffold/templates/nextjs/app/globals.css +3 -0
  58. package/scaffold/templates/nextjs/components/client/AuthGuard.tsx +2 -2
  59. package/scaffold/templates/nextjs/components/client/NymbalSetup.tsx +1 -2
  60. package/scaffold/templates/nextjs/components/server/Header.tsx +5 -2
  61. package/scaffold/templates/nextjs/lib/api.ts +118 -12
  62. package/scaffold/templates/nextjs/lib/chrome.ts +9 -5
  63. package/scaffold/templates/nextjs/lib/client.ts +5 -7
  64. package/scaffold/templates/nextjs/lib/header.ts +15 -0
  65. package/scaffold/templates/nextjs/lib/page-policy.mjs +24 -0
  66. package/scaffold/templates/nextjs/lib/reviews.ts +6 -0
  67. package/scaffold/templates/nextjs/lib/seo.ts +19 -15
  68. package/scaffold/templates/nextjs/lib/signed-in-target.ts +11 -0
  69. package/scaffold/templates/nextjs/next.config.mjs +10 -1
  70. package/scaffold/templates/nextjs/package.json +26 -26
  71. package/scaffold/templates/astro/src/scripts/account-guard.ts +0 -22
@@ -0,0 +1,140 @@
1
+ import Link from 'next/link'
2
+ import type { ReactNode } from 'react'
3
+ import type { ShopperAddress, ShopperOrder } from '@nymbalhq/types'
4
+ import { OrderSummary, OrderTimeline } from '@/components/client/elements'
5
+ import { isPaid, orderHeading } from '@/lib/order-status'
6
+ import styles from '@/styles/pages/confirmation.module.css'
7
+
8
+ function AddressBlock({ title, address }: { title: string; address: ShopperAddress }) {
9
+ return (
10
+ <div className={styles.addressCard}>
11
+ <h4 className={styles.addressTitle}>{title}</h4>
12
+ <p className={styles.addressText}>
13
+ {address.firstName} {address.lastName}
14
+ <br />
15
+ {address.addressLine1}
16
+ {address.addressLine2 && <>, {address.addressLine2}</>}
17
+ <br />
18
+ {address.city}, {address.region} {address.postalCode}
19
+ <br />
20
+ {address.country}
21
+ </p>
22
+ </div>
23
+ )
24
+ }
25
+
26
+ /** The order summary element's attributes, as the server renders them and the browser keeps them. */
27
+ export function summaryAttributes(order: ShopperOrder): Record<string, string> {
28
+ return {
29
+ items: JSON.stringify(summaryItems(order)),
30
+ 'subtotal-minor': String(order.subtotalMinor),
31
+ 'discount-minor': String(order.discountTotalMinor ?? 0),
32
+ 'shipping-minor': String(order.shippingTotalMinor ?? 0),
33
+ 'tax-minor': String(order.taxTotalMinor ?? 0),
34
+ 'total-minor': String(order.totalMinor),
35
+ currency: order.currency,
36
+ }
37
+ }
38
+
39
+ function summaryItems(order: ShopperOrder) {
40
+ return order.lineItems.map((item) => ({
41
+ name: `${item.productName}${item.variantName ? ` - ${item.variantName}` : ''}`,
42
+ qty: item.qty,
43
+ unitPriceMinor: item.unitPriceMinor,
44
+ lineTotalMinor: item.lineTotalMinor,
45
+ }))
46
+ }
47
+
48
+ /**
49
+ * The order as its key opens it: the confirmation page's fields and where it ships. A key holder reads no billing
50
+ * address and no email, so the page shows neither. The server passes the elements' server HTML and the status poll;
51
+ * the email prompt renders it in the browser with neither.
52
+ */
53
+ export function OrderView({
54
+ order,
55
+ timelineHtml,
56
+ summaryHtml,
57
+ refresh,
58
+ }: {
59
+ order: ShopperOrder
60
+ timelineHtml?: string
61
+ summaryHtml?: string
62
+ refresh?: ReactNode
63
+ }) {
64
+ const paid = isPaid(order.status)
65
+ const items = summaryItems(order)
66
+ const timeline = order.timeline ?? []
67
+
68
+ return (
69
+ <div className={`container ${styles.page}`}>
70
+ {refresh}
71
+ <div className={styles.wrapper}>
72
+ <div className={styles.successHeader}>
73
+ {paid && (
74
+ <div className={styles.checkCircle}>
75
+ <svg
76
+ viewBox="0 0 24 24"
77
+ fill="none"
78
+ stroke="currentColor"
79
+ strokeWidth="2"
80
+ strokeLinecap="round"
81
+ strokeLinejoin="round"
82
+ aria-hidden="true"
83
+ >
84
+ <polyline points="20 6 9 17 4 12" />
85
+ </svg>
86
+ </div>
87
+ )}
88
+ <h1 className={styles.successTitle} data-testid="order-heading">
89
+ {orderHeading(order.status)}
90
+ </h1>
91
+ <p className={styles.successSubtitle}>
92
+ {paid ? 'Thank you for your order. ' : ''}Your order number is{' '}
93
+ <span className={styles.orderNumber} data-testid="order-number">
94
+ {order.orderNumber}
95
+ </span>
96
+ . Status:{' '}
97
+ <span data-testid="order-status" style={{ textTransform: 'capitalize' }}>
98
+ {order.status}
99
+ </span>
100
+ .{order.status === 'pending' && ' We will confirm it once the payment arrives.'}
101
+ </p>
102
+ </div>
103
+
104
+ <OrderTimeline
105
+ className={styles.summary}
106
+ entries={timeline}
107
+ {...(timelineHtml !== undefined && { serverHtml: timelineHtml })}
108
+ />
109
+
110
+ <OrderSummary
111
+ className={styles.summary}
112
+ items={items}
113
+ subtotalMinor={order.subtotalMinor}
114
+ discountMinor={order.discountTotalMinor ?? 0}
115
+ shippingMinor={order.shippingTotalMinor ?? 0}
116
+ taxMinor={order.taxTotalMinor ?? 0}
117
+ totalMinor={order.totalMinor}
118
+ currency={order.currency}
119
+ {...(summaryHtml !== undefined && { serverHtml: summaryHtml })}
120
+ />
121
+
122
+ <div className={styles.orderCard}>
123
+ <h3 className={styles.orderCardTitle}>Delivery Details</h3>
124
+ <div className={styles.addressGrid}>
125
+ <AddressBlock title="Shipping Address" address={order.shippingAddress} />
126
+ </div>
127
+ </div>
128
+
129
+ <div className={styles.actions}>
130
+ <Link href="/products" className={styles.continueButton}>
131
+ Continue Shopping
132
+ </Link>
133
+ <Link href="/account/orders" className={styles.orderLink}>
134
+ View All Orders
135
+ </Link>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ )
140
+ }
@@ -0,0 +1,48 @@
1
+ 'use client'
2
+
3
+ import { useEffect } from 'react'
4
+ import { useParams, useRouter } from 'next/navigation'
5
+ import { NymbalApiError } from '@nymbalhq/sdk'
6
+ import { getNymbalClient, restoreSession } from '@/lib/client'
7
+
8
+ /**
9
+ * Where a signed-in shopper who opened their own order here without a working key belongs: the order in their
10
+ * account. The session is restored first, which refreshes a lapsed token: the API reads a lapsed bearer as a guest's.
11
+ * Only the owner's read answering gives a path, so anyone else's order stays this page's not-found state and the page
12
+ * says nothing about whether it exists. Null with no session, so a guest's visit sends nothing.
13
+ */
14
+ async function ownersAccountPath(orderNumber: string): Promise<string | null> {
15
+ await restoreSession()
16
+ const client = getNymbalClient()
17
+ if (!client.auth.getState().isAuthenticated) return null
18
+ try {
19
+ await client.customer.orders.get(orderNumber)
20
+ } catch (err) {
21
+ if (err instanceof NymbalApiError && err.status === 404) return null
22
+ throw err
23
+ }
24
+ return `/account/orders/${encodeURIComponent(orderNumber)}`
25
+ }
26
+
27
+ /** Sends the order's signed-in owner on to it in their account; replacing the entry keeps Back from returning here. */
28
+ export function OwnerRedirect() {
29
+ const params = useParams<{ orderNumber?: string }>()
30
+ const orderNumber = decodeURIComponent(params.orderNumber ?? '')
31
+ const router = useRouter()
32
+
33
+ useEffect(() => {
34
+ if (!orderNumber) return
35
+ let active = true
36
+ ownersAccountPath(orderNumber).then(
37
+ (path) => {
38
+ if (active && path !== null) router.replace(path)
39
+ },
40
+ (err: unknown) => console.error('The signed-in order check failed', err),
41
+ )
42
+ return () => {
43
+ active = false
44
+ }
45
+ }, [orderNumber, router])
46
+
47
+ return null
48
+ }
@@ -0,0 +1,56 @@
1
+ 'use server'
2
+
3
+ import { headers } from 'next/headers'
4
+ import type { ShopperOrder } from '@nymbalhq/types'
5
+ import { openExpiredOrder, requestOrderLink, shopperHeaders } from '@/lib/api'
6
+ import { renderNymbal } from '@/lib/render'
7
+ import { summaryAttributes } from './OrderView'
8
+
9
+ /** What the order page shows once this server answered one of its forms. */
10
+ export type OrderPageState =
11
+ | { kind: 'opened'; order: ShopperOrder; timelineHtml: string; summaryHtml: string }
12
+ | { kind: 'not-found' }
13
+ | { kind: 'link-sent' }
14
+ | { kind: 'open-limited' }
15
+ | { kind: 'link-limited' }
16
+
17
+ function field(form: FormData, name: string): string {
18
+ const value = form.get(name)
19
+ return typeof value === 'string' ? value.trim() : ''
20
+ }
21
+
22
+ /**
23
+ * The order page's two forms sent without the page's script, which sends both from the browser: `intent=open` reads
24
+ * the expired key's order with the typed email, `intent=link` asks for a fresh link. The email stays in the body. An
25
+ * opened order carries the elements' server HTML, so its summary and timeline show without a script.
26
+ */
27
+ export async function orderPageAction(
28
+ _previous: OrderPageState | null,
29
+ form: FormData,
30
+ ): Promise<OrderPageState> {
31
+ const forwarded = shopperHeaders(await headers())
32
+ if (field(form, 'intent') === 'link') {
33
+ const answer = await requestOrderLink(
34
+ field(form, 'orderNumber'),
35
+ field(form, 'email'),
36
+ forwarded,
37
+ )
38
+ return { kind: answer === 'sent' ? 'link-sent' : 'link-limited' }
39
+ }
40
+ const read = await openExpiredOrder(
41
+ field(form, 'orderNumber'),
42
+ field(form, 'key'),
43
+ field(form, 'email'),
44
+ forwarded,
45
+ )
46
+ if (read === 'not-found') return { kind: 'not-found' }
47
+ if (read === 'limited') return { kind: 'open-limited' }
48
+ return {
49
+ kind: 'opened',
50
+ order: read,
51
+ timelineHtml: renderNymbal('nymbal-order-timeline', {
52
+ entries: JSON.stringify(read.timeline ?? []),
53
+ }).__html,
54
+ summaryHtml: renderNymbal('nymbal-order-summary', summaryAttributes(read)).__html,
55
+ }
56
+ }
@@ -0,0 +1,6 @@
1
+ import { OrderNotFound } from './OrderNotFound'
2
+
3
+ // An order the store does not know, or one read without what opens it: the shopper can ask for a fresh link.
4
+ export default function OrderPageNotFound() {
5
+ return <OrderNotFound />
6
+ }
@@ -1,63 +1,24 @@
1
1
  import type { Metadata } from 'next'
2
2
  import { notFound } from 'next/navigation'
3
- import Link from 'next/link'
4
3
  import { loadOrder } from '@/lib/api'
5
- import { OrderSummary, OrderTimeline } from '@/components/client/elements'
6
- import { renderNymbal } from '@/lib/render'
7
- import { OrderStatusRefresh } from '@/components/client/OrderStatusRefresh'
8
- import { isPaid, orderHeading } from '@/lib/order-status'
9
- import styles from '@/styles/pages/confirmation.module.css'
4
+ import { OrderDetails } from './OrderDetails'
5
+ import { OrderEmailPrompt } from './OrderEmailPrompt'
10
6
 
11
7
  interface OrderPageProps {
12
8
  params: Promise<{ orderNumber: string }>
13
9
  searchParams: Promise<{ key?: string | string[] }>
14
10
  }
15
11
 
16
- // The URL carries the order's key (`?key=`), so nothing this page links to or loads may be told the URL: the meta
17
- // tag here, and the header next.config.mjs sets on every /order/<n> response, the not-found render's too.
12
+ // The URL carries the order's key (`?key=`), so nothing this page links to or loads may be told more than its origin:
13
+ // the meta tag here, and the header next.config.mjs sets on every /order/<n> response, the not-found render's too.
18
14
  export async function generateMetadata({ params }: OrderPageProps): Promise<Metadata> {
19
15
  const { orderNumber } = await params
20
16
  return {
21
17
  title: `Order ${orderNumber}`,
22
- referrer: 'no-referrer',
18
+ referrer: 'strict-origin',
23
19
  }
24
20
  }
25
21
 
26
- function AddressBlock({
27
- title,
28
- address,
29
- }: {
30
- title: string
31
- address: {
32
- firstName?: string
33
- lastName?: string
34
- addressLine1: string
35
- addressLine2?: string
36
- city: string
37
- region: string
38
- postalCode: string
39
- country: string
40
- } | null
41
- }) {
42
- if (!address) return null
43
-
44
- return (
45
- <div className={styles.addressCard}>
46
- <h4 className={styles.addressTitle}>{title}</h4>
47
- <p className={styles.addressText}>
48
- {address.firstName} {address.lastName}
49
- <br />
50
- {address.addressLine1}
51
- {address.addressLine2 && <>, {address.addressLine2}</>}
52
- <br />
53
- {address.city}, {address.region} {address.postalCode}
54
- <br />
55
- {address.country}
56
- </p>
57
- </div>
58
- )
59
- }
60
-
61
22
  export default async function OrderPage({ params, searchParams }: OrderPageProps) {
62
23
  const { orderNumber } = await params
63
24
  const { key: keyParam } = await searchParams
@@ -65,98 +26,9 @@ export default async function OrderPage({ params, searchParams }: OrderPageProps
65
26
  // Rejects when the API fails, so a failed read is a 500 and never a 404 for an order the shopper has.
66
27
  const order = await loadOrder(orderNumber, key)
67
28
 
29
+ // Only the order's own key is told it has expired: the page asks for the order's email to open it.
30
+ if (order === 'expired')
31
+ return <OrderEmailPrompt orderNumber={orderNumber} orderKey={key ?? ''} />
68
32
  if (!order) notFound()
69
- const paid = isPaid(order.status)
70
- const items = order.lineItems.map((item) => ({
71
- name: `${item.productName}${item.variantName ? ` - ${item.variantName}` : ''}`,
72
- qty: item.qty,
73
- unitPriceMinor: item.unitPriceMinor,
74
- lineTotalMinor: item.lineTotalMinor,
75
- }))
76
- const summary = {
77
- items: JSON.stringify(items),
78
- 'subtotal-minor': String(order.subtotalMinor),
79
- 'discount-minor': String(order.discountTotalMinor ?? 0),
80
- 'shipping-minor': String(order.shippingTotalMinor ?? 0),
81
- 'tax-minor': String(order.taxTotalMinor ?? 0),
82
- 'total-minor': String(order.totalMinor),
83
- currency: order.currency,
84
- }
85
- const timeline = order.timeline ?? []
86
-
87
- return (
88
- <div className={`container ${styles.page}`}>
89
- <OrderStatusRefresh orderNumber={order.orderNumber} orderKey={key} status={order.status} />
90
- <div className={styles.wrapper}>
91
- <div className={styles.successHeader}>
92
- {paid && (
93
- <div className={styles.checkCircle}>
94
- <svg
95
- viewBox="0 0 24 24"
96
- fill="none"
97
- stroke="currentColor"
98
- strokeWidth="2"
99
- strokeLinecap="round"
100
- strokeLinejoin="round"
101
- aria-hidden="true"
102
- >
103
- <polyline points="20 6 9 17 4 12" />
104
- </svg>
105
- </div>
106
- )}
107
- <h1 className={styles.successTitle} data-testid="order-heading">
108
- {orderHeading(order.status)}
109
- </h1>
110
- <p className={styles.successSubtitle}>
111
- {paid ? 'Thank you for your order. ' : ''}Your order number is{' '}
112
- <span className={styles.orderNumber} data-testid="order-number">
113
- {order.orderNumber}
114
- </span>
115
- . Status:{' '}
116
- <span data-testid="order-status" style={{ textTransform: 'capitalize' }}>
117
- {order.status}
118
- </span>
119
- .{order.status === 'pending' && ' We will confirm it once the payment arrives.'}
120
- </p>
121
- </div>
122
-
123
- <OrderTimeline
124
- className={styles.summary}
125
- entries={timeline}
126
- serverHtml={
127
- renderNymbal('nymbal-order-timeline', { entries: JSON.stringify(timeline) }).__html
128
- }
129
- />
130
-
131
- <OrderSummary
132
- className={styles.summary}
133
- items={items}
134
- subtotalMinor={order.subtotalMinor}
135
- discountMinor={order.discountTotalMinor ?? 0}
136
- shippingMinor={order.shippingTotalMinor ?? 0}
137
- taxMinor={order.taxTotalMinor ?? 0}
138
- totalMinor={order.totalMinor}
139
- currency={order.currency}
140
- serverHtml={renderNymbal('nymbal-order-summary', summary).__html}
141
- />
142
-
143
- <div className={styles.orderCard}>
144
- <h3 className={styles.orderCardTitle}>Delivery Details</h3>
145
- <div className={styles.addressGrid}>
146
- <AddressBlock title="Shipping Address" address={order.shippingAddress} />
147
- <AddressBlock title="Billing Address" address={order.billingAddress} />
148
- </div>
149
- </div>
150
-
151
- <div className={styles.actions}>
152
- <Link href="/products" className={styles.continueButton}>
153
- Continue Shopping
154
- </Link>
155
- <Link href="/account/orders" className={styles.orderLink}>
156
- View All Orders
157
- </Link>
158
- </div>
159
- </div>
160
- </div>
161
- )
33
+ return <OrderDetails order={order} {...(key !== undefined && { orderKey: key })} />
162
34
  }
@@ -5,10 +5,11 @@ import styles from '@/styles/pages/error.module.css'
5
5
 
6
6
  interface ErrorProps {
7
7
  error: Error & { digest?: string }
8
- reset: () => void
8
+ /** Fetches the failed segment again and renders it; `reset` would render the failed payload again. */
9
+ retry: () => void
9
10
  }
10
11
 
11
- export default function ErrorPage({ error: _error, reset }: ErrorProps) {
12
+ export default function ErrorPage({ error: _error, retry }: ErrorProps) {
12
13
  return (
13
14
  <main id="main" className={styles.page}>
14
15
  <div className={styles.wrapper}>
@@ -35,7 +36,12 @@ export default function ErrorPage({ error: _error, reset }: ErrorProps) {
35
36
  <Link href="/" className={styles.homeLink}>
36
37
  Go Home
37
38
  </Link>
38
- <button type="button" className={styles.retryButton} onClick={reset}>
39
+ <button
40
+ type="button"
41
+ className={styles.retryButton}
42
+ onClick={() => retry()}
43
+ data-testid="error-retry"
44
+ >
39
45
  Try Again
40
46
  </button>
41
47
  </div>
@@ -18,6 +18,9 @@ html {
18
18
  -moz-text-size-adjust: 100%;
19
19
  text-size-adjust: 100%;
20
20
  scroll-behavior: smooth;
21
+ /* What is scrolled to the top edge (a fragment, scrollIntoView, keyboard focus) lands below the sticky site header:
22
+ at least its height at every width, with room for a phone header that also holds the mini-cart. */
23
+ scroll-padding-top: 5.5rem;
21
24
  }
22
25
 
23
26
  body {
@@ -11,8 +11,8 @@ export function AuthGuard({ children }: { children: ReactNode }) {
11
11
  const { isAuthenticated, loading } = useAuth()
12
12
  const router = useRouter()
13
13
  const pathname = usePathname()
14
- // A stored token is only known to be valid once its profile has loaded; redirecting before that would sign a
15
- // reloading shopper out.
14
+ // The shopper is only known to be signed out once the page load's session restore has settled; redirecting before
15
+ // that would sign a reloading shopper out.
16
16
  const [restored, setRestored] = useState(false)
17
17
 
18
18
  const isPublicAuthPath = PUBLIC_AUTH_PATHS.includes(pathname)
@@ -10,7 +10,7 @@ import { NymbalMiniCart } from '@nymbalhq/web-components/elements/nymbal-mini-ca
10
10
  import { NymbalSearchBar } from '@nymbalhq/web-components/elements/nymbal-search-bar'
11
11
  import { NymbalSiteFooter } from '@nymbalhq/web-components/elements/nymbal-site-footer'
12
12
  import { NymbalSiteHeader } from '@nymbalhq/web-components/elements/nymbal-site-header'
13
- import { getNymbalClient, restoreSession } from '@/lib/client'
13
+ import { getNymbalClient } from '@/lib/client'
14
14
 
15
15
  export function NymbalSetup({ children }: { children: ReactNode }) {
16
16
  const client = getNymbalClient()
@@ -29,7 +29,6 @@ export function NymbalSetup({ children }: { children: ReactNode }) {
29
29
  NymbalSearchBar.define()
30
30
  NymbalMiniCart.define()
31
31
  NymbalCartDrawer.define()
32
- void restoreSession()
33
32
  initialized.current = true
34
33
  }
35
34
  }, [client])
@@ -2,7 +2,7 @@ import { headers } from 'next/headers'
2
2
  import { SiteHeader } from '@/components/client/elements'
3
3
  import { fetchCart } from '@/lib/api'
4
4
  import { HEADER } from '@/lib/chrome'
5
- import { canSearch, siteHeader } from '@/lib/header'
5
+ import { canSearch, shopperCanSearch, siteHeader } from '@/lib/header'
6
6
  import { renderNymbal } from '@/lib/render'
7
7
 
8
8
  function HeaderElement({ header }: { header: ReturnType<typeof siteHeader> }) {
@@ -24,7 +24,10 @@ function HeaderElement({ header }: { header: ReturnType<typeof siteHeader> }) {
24
24
  */
25
25
  export async function Header({ shopper = false }: { shopper?: boolean }) {
26
26
  const cookie = shopper ? (await headers()).get('cookie') : null
27
- const [search, cart] = await Promise.all([canSearch(), shopper ? fetchCart(cookie) : null])
27
+ const [search, cart] = await Promise.all([
28
+ shopper ? shopperCanSearch() : canSearch(),
29
+ shopper ? fetchCart(cookie) : null,
30
+ ])
28
31
  return <HeaderElement header={siteHeader(search, cart?.itemCount)} />
29
32
  }
30
33