@pradip1995/segment-login-template 0.5.27 → 0.5.28

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 (42) hide show
  1. package/package.json +13 -9
  2. package/src/account-addresses.tsx +307 -287
  3. package/src/account-guest-orders.tsx +98 -98
  4. package/src/account-orders.tsx +260 -260
  5. package/src/account-overview.tsx +133 -133
  6. package/src/account-payment-methods.tsx +328 -328
  7. package/src/account-profile-logic.ts +282 -282
  8. package/src/account-profile.tsx +111 -111
  9. package/src/account-theme.ts +91 -91
  10. package/src/account-utils.ts +20 -20
  11. package/src/address-actions.ts +74 -0
  12. package/src/auth-server.ts +442 -442
  13. package/src/card-expiry.test.ts +71 -0
  14. package/src/card-expiry.ts +29 -0
  15. package/src/commerce-auth-otp-modal.css +125 -125
  16. package/src/commerce-auth-otp-modal.tsx +121 -121
  17. package/src/default-address.test.ts +143 -0
  18. package/src/default-address.ts +51 -0
  19. package/src/forgot-password-form.tsx +109 -109
  20. package/src/google-auth-section.tsx +22 -22
  21. package/src/google-sign-in-section.tsx +67 -67
  22. package/src/guest-order-modal.tsx +215 -215
  23. package/src/index.ts +7 -7
  24. package/src/is-next-redirect.ts +60 -60
  25. package/src/login-form.tsx +469 -469
  26. package/src/manifest.ts +11 -11
  27. package/src/order-history-status.test.ts +224 -224
  28. package/src/order-history-status.ts +244 -244
  29. package/src/otp-component.ts +14 -14
  30. package/src/otp-input.tsx +46 -46
  31. package/src/otp-unified-form.tsx +333 -333
  32. package/src/otp-verification-modal.tsx +112 -112
  33. package/src/payment-methods-actions.ts +243 -243
  34. package/src/profile-email-field.tsx +116 -116
  35. package/src/profile-email.test.ts +182 -182
  36. package/src/profile-email.ts +54 -54
  37. package/src/profile-phone-field.tsx +119 -119
  38. package/src/register-form.tsx +339 -339
  39. package/src/reorder-checkout-address.ts +103 -101
  40. package/src/reset-password-form.tsx +103 -103
  41. package/src/reset-password-page.tsx +12 -12
  42. package/src/segment.tsx +272 -272
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/segment-login-template",
3
- "version": "0.5.27",
3
+ "version": "0.5.28",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,7 +24,16 @@
24
24
  "./profile-email-field": "./src/profile-email-field.tsx",
25
25
  "./google-auth-section": "./src/google-auth-section.tsx",
26
26
  "./google-sign-in-section": "./src/google-sign-in-section.tsx",
27
- "./otp-input": "./src/otp-input.tsx"
27
+ "./otp-input": "./src/otp-input.tsx",
28
+ "./profile-email": "./src/profile-email.ts",
29
+ "./address-actions": "./src/address-actions.ts",
30
+ "./default-address": "./src/default-address.ts",
31
+ "./card-expiry": "./src/card-expiry.ts"
32
+ },
33
+ "scripts": {
34
+ "typecheck": "tsc --noEmit",
35
+ "lint": "tsc --noEmit",
36
+ "test": "node --experimental-strip-types --test src/*.test.ts"
28
37
  },
29
38
  "peerDependencies": {
30
39
  "@pradip1995/commerce-auth": "^4.0.0",
@@ -37,7 +46,7 @@
37
46
  "dependencies": {
38
47
  "@pradip1995/commerce-auth": "^4.0.0",
39
48
  "@pradip1995/commerce-core": "^4.0.0",
40
- "@pradip1995/segment-primitives": "^0.4.15",
49
+ "@pradip1995/segment-primitives": "^0.4.20",
41
50
  "@pradip1995/segment-tokens": "^0.3.19"
42
51
  },
43
52
  "devDependencies": {
@@ -45,10 +54,5 @@
45
54
  "@types/react": "^19",
46
55
  "react": "19.0.3",
47
56
  "typescript": "^5.7.2"
48
- },
49
- "scripts": {
50
- "typecheck": "tsc --noEmit",
51
- "lint": "tsc --noEmit",
52
- "test": "node --experimental-strip-types --test src/*.test.ts"
53
57
  }
54
- }
58
+ }
@@ -1,287 +1,307 @@
1
- "use client"
2
-
3
- import { useActionState, useState } from "react"
4
- import type { HttpTypes } from "@medusajs/types"
5
- import {
6
- addCustomerAddress,
7
- deleteCustomerAddress,
8
- setDefaultAddress,
9
- updateCustomerAddress,
10
- } from "@pradip1995/commerce-core/data/customer"
11
- import { acct } from "./account-theme"
12
-
13
- export default function AccountAddresses({
14
- customer,
15
- countryCode,
16
- }: {
17
- customer: HttpTypes.StoreCustomer
18
- countryCode: string
19
- }) {
20
- const addresses = customer.addresses ?? []
21
- const [editingId, setEditingId] = useState<string | null>(null)
22
- const [showAdd, setShowAdd] = useState(false)
23
- const hasDefault = addresses.some((a) => a.is_default_shipping || a.is_default_billing)
24
-
25
- return (
26
- <div className="space-y-8">
27
- <div className="flex flex-wrap items-end justify-between gap-4">
28
- <div>
29
- <h2 className={acct.title}>Saved addresses</h2>
30
- <p className={`text-sm ${acct.muted}`}>Manage shipping and billing addresses.</p>
31
- </div>
32
- <button type="button" onClick={() => setShowAdd(true)} className={acct.btnPrimary}>
33
- Add address
34
- </button>
35
- </div>
36
-
37
- {addresses.length === 0 && !showAdd && (
38
- <div className={`${acct.cardMuted} p-8 text-center text-sm ${acct.muted}`}>
39
- No saved addresses yet.
40
- </div>
41
- )}
42
-
43
- <ul className="space-y-4">
44
- {addresses.map((address) => (
45
- <li key={address.id} className={`${acct.card} p-5`}>
46
- {editingId === address.id ? (
47
- <AddressForm
48
- countryCode={countryCode}
49
- address={address}
50
- addressId={address.id}
51
- defaultChecked={!!(address.is_default_shipping || address.is_default_billing)}
52
- onDone={() => setEditingId(null)}
53
- onCancel={() => setEditingId(null)}
54
- />
55
- ) : (
56
- <div className="flex flex-wrap justify-between gap-4">
57
- <div className="text-sm text-body space-y-1">
58
- <p className="font-semibold text-heading">
59
- {[address.first_name, address.last_name].filter(Boolean).join(" ")}
60
- </p>
61
- <p>{address.address_1}</p>
62
- {address.address_2 && <p>{address.address_2}</p>}
63
- <p>
64
- {[address.city, address.province, address.postal_code].filter(Boolean).join(", ")}
65
- </p>
66
- <p className="uppercase text-xs text-muted">{address.country_code}</p>
67
- {address.phone && <p>{address.phone}</p>}
68
- {(address.is_default_shipping || address.is_default_billing) && (
69
- <p className="text-xs text-brand-accent font-medium pt-1">
70
- {address.is_default_shipping && address.is_default_billing
71
- ? "Default shipping & billing"
72
- : address.is_default_shipping
73
- ? "Default shipping"
74
- : "Default billing"}
75
- </p>
76
- )}
77
- </div>
78
- <div className="flex flex-col sm:flex-row gap-2 shrink-0 items-end sm:items-center">
79
- {!address.is_default_shipping && (
80
- <MakeDefaultButton addressId={address.id!} />
81
- )}
82
- <button
83
- type="button"
84
- onClick={() => setEditingId(address.id!)}
85
- className={`${acct.btnOutline} !py-2 !px-3`}
86
- >
87
- Edit
88
- </button>
89
- <DeleteAddressButton addressId={address.id!} />
90
- </div>
91
- </div>
92
- )}
93
- </li>
94
- ))}
95
- </ul>
96
-
97
- {showAdd && (
98
- <div className={`${acct.card} p-5`}>
99
- <h3 className="text-sm font-semibold text-heading mb-4">New address</h3>
100
- <AddressForm
101
- countryCode={countryCode}
102
- defaultChecked={addresses.length === 0 || !hasDefault}
103
- onDone={() => setShowAdd(false)}
104
- onCancel={() => setShowAdd(false)}
105
- />
106
- </div>
107
- )}
108
- </div>
109
- )
110
- }
111
-
112
- function AddressForm({
113
- countryCode,
114
- address,
115
- addressId,
116
- defaultChecked = false,
117
- onDone,
118
- onCancel,
119
- }: {
120
- countryCode: string
121
- address?: HttpTypes.StoreCustomerAddress
122
- addressId?: string
123
- defaultChecked?: boolean
124
- onDone: () => void
125
- onCancel: () => void
126
- }) {
127
- const action = addressId ? updateCustomerAddress : addCustomerAddress
128
- const [state, formAction, pending] = useActionState(
129
- async (prev: Record<string, unknown>, formData: FormData) => {
130
- const makeDefault = formData.get("is_default") === "on"
131
- const result = await action(
132
- addressId
133
- ? { ...prev, addressId }
134
- : {
135
- ...prev,
136
- isDefaultShipping: makeDefault,
137
- isDefaultBilling: makeDefault,
138
- },
139
- formData
140
- )
141
- if (result?.success) {
142
- if (addressId && makeDefault && !address?.is_default_shipping) {
143
- const defaultResult = await setDefaultAddress(addressId)
144
- if (!defaultResult?.success) {
145
- return {
146
- success: false,
147
- error: defaultResult?.error || "Failed to set default address",
148
- }
149
- }
150
- }
151
- onDone()
152
- window.location.reload()
153
- }
154
- return result
155
- },
156
- { success: false, error: null as string | null }
157
- )
158
-
159
- return (
160
- <form action={formAction} className="grid grid-cols-1 sm:grid-cols-2 gap-4">
161
- <Field label="First name" name="first_name" defaultValue={address?.first_name || ""} />
162
- <Field label="Last name" name="last_name" defaultValue={address?.last_name || ""} />
163
- <Field label="Address line 1" name="address_1" className="sm:col-span-2" defaultValue={address?.address_1 || ""} />
164
- <Field label="Address line 2" name="address_2" className="sm:col-span-2" defaultValue={address?.address_2 || ""} />
165
- <Field label="City" name="city" defaultValue={address?.city || ""} />
166
- <Field label="State / Province" name="province" defaultValue={address?.province || ""} />
167
- <Field label="Postal code" name="postal_code" defaultValue={address?.postal_code || ""} />
168
- <Field
169
- label="Country code"
170
- name="country_code"
171
- defaultValue={address?.country_code || countryCode}
172
- />
173
- <Field label="Phone" name="phone" type="tel" defaultValue={address?.phone || ""} />
174
- <label className="sm:col-span-2 flex items-center gap-2 text-sm text-body cursor-pointer">
175
- <input
176
- type="checkbox"
177
- name="is_default"
178
- defaultChecked={defaultChecked}
179
- className="size-4 accent-[var(--color-brand-accent,#7c3aed)]"
180
- />
181
- <span>Set as default shipping address</span>
182
- </label>
183
- {state?.error && (
184
- <p className="sm:col-span-2 text-sm text-red-600">{String(state.error)}</p>
185
- )}
186
- <div className="sm:col-span-2 flex gap-3">
187
- <button type="submit" disabled={pending} className={acct.btnPrimary}>
188
- {pending ? "Saving…" : "Save address"}
189
- </button>
190
- <button type="button" onClick={onCancel} className={acct.btnOutline}>
191
- Cancel
192
- </button>
193
- </div>
194
- </form>
195
- )
196
- }
197
-
198
- function MakeDefaultButton({ addressId }: { addressId: string }) {
199
- const [pending, setPending] = useState(false)
200
- const [error, setError] = useState<string | null>(null)
201
-
202
- async function handleDefault() {
203
- setPending(true)
204
- setError(null)
205
- try {
206
- const result = await setDefaultAddress(addressId)
207
- if (!result?.success) {
208
- setError(result?.error || "Failed to set default address")
209
- setPending(false)
210
- return
211
- }
212
- window.location.reload()
213
- } catch (err) {
214
- setError(err instanceof Error ? err.message : "Failed to set default address")
215
- setPending(false)
216
- }
217
- }
218
-
219
- return (
220
- <div className="flex flex-col items-end gap-1">
221
- <button
222
- type="button"
223
- onClick={handleDefault}
224
- disabled={pending}
225
- className="text-xs text-brand-accent hover:underline disabled:opacity-60"
226
- >
227
- {pending ? "Setting…" : "Make default"}
228
- </button>
229
- {error && <p className="text-xs text-red-600 max-w-[12rem] text-right">{error}</p>}
230
- </div>
231
- )
232
- }
233
-
234
- function DeleteAddressButton({ addressId }: { addressId: string }) {
235
- const [pending, setPending] = useState(false)
236
-
237
- async function handleDelete() {
238
- if (!confirm("Delete this address?")) return
239
- setPending(true)
240
- try {
241
- await deleteCustomerAddress(addressId)
242
- window.location.reload()
243
- } finally {
244
- setPending(false)
245
- }
246
- }
247
-
248
- return (
249
- <button
250
- type="button"
251
- onClick={handleDelete}
252
- disabled={pending}
253
- className="text-xs text-red-600 hover:underline disabled:opacity-60"
254
- >
255
- {pending ? "Deleting…" : "Delete"}
256
- </button>
257
- )
258
- }
259
-
260
- function Field({
261
- label,
262
- name,
263
- type = "text",
264
- defaultValue,
265
- className = "",
266
- }: {
267
- label: string
268
- name: string
269
- type?: string
270
- defaultValue?: string
271
- className?: string
272
- }) {
273
- return (
274
- <label className={`block ${className}`}>
275
- <span className="text-xs font-semibold uppercase tracking-wider text-muted mb-1.5 block">
276
- {label}
277
- </span>
278
- <input
279
- name={name}
280
- type={type}
281
- defaultValue={defaultValue}
282
- required={name !== "address_2"}
283
- className="w-full border border-cart-border rounded-none px-3 py-2.5 text-sm bg-surface text-heading focus:outline-none focus:border-brand-accent"
284
- />
285
- </label>
286
- )
287
- }
1
+ "use client"
2
+
3
+ import { useActionState, useState } from "react"
4
+ import type { HttpTypes } from "@medusajs/types"
5
+ import {
6
+ addCustomerAddress,
7
+ deleteCustomerAddress,
8
+ updateCustomerAddress,
9
+ } from "@pradip1995/commerce-core/data/customer"
10
+ import {
11
+ ensureExclusiveDefaultAddress,
12
+ setExclusiveDefaultAddress,
13
+ } from "./address-actions"
14
+ import {
15
+ isExclusiveDefaultAddress,
16
+ resolveDefaultAddressId,
17
+ } from "./default-address"
18
+ import { acct } from "./account-theme"
19
+
20
+ export default function AccountAddresses({
21
+ customer,
22
+ countryCode,
23
+ }: {
24
+ customer: HttpTypes.StoreCustomer
25
+ countryCode: string
26
+ }) {
27
+ const addresses = customer.addresses ?? []
28
+ const [editingId, setEditingId] = useState<string | null>(null)
29
+ const [showAdd, setShowAdd] = useState(false)
30
+ const defaultAddressId = resolveDefaultAddressId(addresses)
31
+ const hasDefault = Boolean(defaultAddressId)
32
+
33
+ return (
34
+ <div className="space-y-8">
35
+ <div className="flex flex-wrap items-end justify-between gap-4">
36
+ <div>
37
+ <h2 className={acct.title}>Saved addresses</h2>
38
+ <p className={`text-sm ${acct.muted}`}>Manage shipping and billing addresses.</p>
39
+ </div>
40
+ <button type="button" onClick={() => setShowAdd(true)} className={acct.btnPrimary}>
41
+ Add address
42
+ </button>
43
+ </div>
44
+
45
+ {addresses.length === 0 && !showAdd && (
46
+ <div className={`${acct.cardMuted} p-8 text-center text-sm ${acct.muted}`}>
47
+ No saved addresses yet.
48
+ </div>
49
+ )}
50
+
51
+ <ul className="space-y-4">
52
+ {addresses.map((address) => {
53
+ const isDefault = isExclusiveDefaultAddress(address, defaultAddressId)
54
+ return (
55
+ <li key={address.id} className={`${acct.card} p-5`}>
56
+ {editingId === address.id ? (
57
+ <AddressForm
58
+ countryCode={countryCode}
59
+ address={address}
60
+ addressId={address.id}
61
+ defaultChecked={isDefault}
62
+ onDone={() => setEditingId(null)}
63
+ onCancel={() => setEditingId(null)}
64
+ />
65
+ ) : (
66
+ <div className="flex flex-wrap justify-between gap-4">
67
+ <div className="text-sm text-body space-y-1">
68
+ <p className="font-semibold text-heading">
69
+ {[address.first_name, address.last_name].filter(Boolean).join(" ")}
70
+ </p>
71
+ <p>{address.address_1}</p>
72
+ {address.address_2 && <p>{address.address_2}</p>}
73
+ <p>
74
+ {[address.city, address.province, address.postal_code]
75
+ .filter(Boolean)
76
+ .join(", ")}
77
+ </p>
78
+ <p className="uppercase text-xs text-muted">{address.country_code}</p>
79
+ {address.phone && <p>{address.phone}</p>}
80
+ {isDefault && (
81
+ <p className="text-xs text-brand-accent font-medium pt-1">Default</p>
82
+ )}
83
+ </div>
84
+ <div className="flex flex-col sm:flex-row gap-2 shrink-0 items-end sm:items-center">
85
+ {!isDefault && <MakeDefaultButton addressId={address.id!} />}
86
+ <button
87
+ type="button"
88
+ onClick={() => setEditingId(address.id!)}
89
+ className={`${acct.btnOutline} !py-2 !px-3`}
90
+ >
91
+ Edit
92
+ </button>
93
+ <DeleteAddressButton addressId={address.id!} />
94
+ </div>
95
+ </div>
96
+ )}
97
+ </li>
98
+ )
99
+ })}
100
+ </ul>
101
+
102
+ {showAdd && (
103
+ <div className={`${acct.card} p-5`}>
104
+ <h3 className="text-sm font-semibold text-heading mb-4">New address</h3>
105
+ <AddressForm
106
+ countryCode={countryCode}
107
+ defaultChecked={addresses.length === 0 || !hasDefault}
108
+ onDone={() => setShowAdd(false)}
109
+ onCancel={() => setShowAdd(false)}
110
+ />
111
+ </div>
112
+ )}
113
+ </div>
114
+ )
115
+ }
116
+
117
+ function AddressForm({
118
+ countryCode,
119
+ address,
120
+ addressId,
121
+ defaultChecked = false,
122
+ onDone,
123
+ onCancel,
124
+ }: {
125
+ countryCode: string
126
+ address?: HttpTypes.StoreCustomerAddress
127
+ addressId?: string
128
+ defaultChecked?: boolean
129
+ onDone: () => void
130
+ onCancel: () => void
131
+ }) {
132
+ const action = addressId ? updateCustomerAddress : addCustomerAddress
133
+ const [state, formAction, pending] = useActionState(
134
+ async (prev: Record<string, unknown>, formData: FormData) => {
135
+ const makeDefault = formData.get("is_default") === "on"
136
+ const result = await action(
137
+ addressId
138
+ ? { ...prev, addressId }
139
+ : {
140
+ ...prev,
141
+ isDefaultShipping: makeDefault,
142
+ isDefaultBilling: makeDefault,
143
+ },
144
+ formData
145
+ )
146
+ if (result?.success) {
147
+ if (makeDefault) {
148
+ const defaultResult = await ensureExclusiveDefaultAddress({
149
+ addressId,
150
+ address_1: String(formData.get("address_1") || ""),
151
+ postal_code: String(formData.get("postal_code") || ""),
152
+ phone: String(formData.get("phone") || ""),
153
+ })
154
+ if (!defaultResult?.success) {
155
+ return {
156
+ success: false,
157
+ error: defaultResult?.error || "Failed to set default address",
158
+ }
159
+ }
160
+ }
161
+ onDone()
162
+ window.location.reload()
163
+ }
164
+ return result
165
+ },
166
+ { success: false, error: null as string | null }
167
+ )
168
+
169
+ return (
170
+ <form action={formAction} className="grid grid-cols-1 sm:grid-cols-2 gap-4">
171
+ <Field label="First name" name="first_name" defaultValue={address?.first_name || ""} />
172
+ <Field label="Last name" name="last_name" defaultValue={address?.last_name || ""} />
173
+ <Field
174
+ label="Address line 1"
175
+ name="address_1"
176
+ className="sm:col-span-2"
177
+ defaultValue={address?.address_1 || ""}
178
+ />
179
+ <Field
180
+ label="Address line 2"
181
+ name="address_2"
182
+ className="sm:col-span-2"
183
+ defaultValue={address?.address_2 || ""}
184
+ />
185
+ <Field label="City" name="city" defaultValue={address?.city || ""} />
186
+ <Field label="State / Province" name="province" defaultValue={address?.province || ""} />
187
+ <Field label="Postal code" name="postal_code" defaultValue={address?.postal_code || ""} />
188
+ <Field
189
+ label="Country code"
190
+ name="country_code"
191
+ defaultValue={address?.country_code || countryCode}
192
+ />
193
+ <Field label="Phone" name="phone" type="tel" defaultValue={address?.phone || ""} />
194
+ <label className="sm:col-span-2 flex items-center gap-2 text-sm text-body cursor-pointer">
195
+ <input
196
+ type="checkbox"
197
+ name="is_default"
198
+ defaultChecked={defaultChecked}
199
+ className="size-4 accent-[var(--color-brand-accent,#7c3aed)]"
200
+ />
201
+ <span>Set as default shipping address</span>
202
+ </label>
203
+ {state?.error && (
204
+ <p className="sm:col-span-2 text-sm text-red-600">{String(state.error)}</p>
205
+ )}
206
+ <div className="sm:col-span-2 flex gap-3">
207
+ <button type="submit" disabled={pending} className={acct.btnPrimary}>
208
+ {pending ? "Saving…" : "Save address"}
209
+ </button>
210
+ <button type="button" onClick={onCancel} className={acct.btnOutline}>
211
+ Cancel
212
+ </button>
213
+ </div>
214
+ </form>
215
+ )
216
+ }
217
+
218
+ function MakeDefaultButton({ addressId }: { addressId: string }) {
219
+ const [pending, setPending] = useState(false)
220
+ const [error, setError] = useState<string | null>(null)
221
+
222
+ async function handleDefault() {
223
+ setPending(true)
224
+ setError(null)
225
+ try {
226
+ const result = await setExclusiveDefaultAddress(addressId)
227
+ if (!result?.success) {
228
+ setError(result?.error || "Failed to set default address")
229
+ setPending(false)
230
+ return
231
+ }
232
+ window.location.reload()
233
+ } catch (err) {
234
+ setError(err instanceof Error ? err.message : "Failed to set default address")
235
+ setPending(false)
236
+ }
237
+ }
238
+
239
+ return (
240
+ <div className="flex flex-col items-end gap-1">
241
+ <button
242
+ type="button"
243
+ onClick={handleDefault}
244
+ disabled={pending}
245
+ className="text-xs text-brand-accent hover:underline disabled:opacity-60"
246
+ >
247
+ {pending ? "Setting…" : "Make default"}
248
+ </button>
249
+ {error && <p className="text-xs text-red-600 max-w-[12rem] text-right">{error}</p>}
250
+ </div>
251
+ )
252
+ }
253
+
254
+ function DeleteAddressButton({ addressId }: { addressId: string }) {
255
+ const [pending, setPending] = useState(false)
256
+
257
+ async function handleDelete() {
258
+ if (!confirm("Delete this address?")) return
259
+ setPending(true)
260
+ try {
261
+ await deleteCustomerAddress(addressId)
262
+ window.location.reload()
263
+ } finally {
264
+ setPending(false)
265
+ }
266
+ }
267
+
268
+ return (
269
+ <button
270
+ type="button"
271
+ onClick={handleDelete}
272
+ disabled={pending}
273
+ className="text-xs text-red-600 hover:underline disabled:opacity-60"
274
+ >
275
+ {pending ? "Deleting…" : "Delete"}
276
+ </button>
277
+ )
278
+ }
279
+
280
+ function Field({
281
+ label,
282
+ name,
283
+ type = "text",
284
+ defaultValue,
285
+ className = "",
286
+ }: {
287
+ label: string
288
+ name: string
289
+ type?: string
290
+ defaultValue?: string
291
+ className?: string
292
+ }) {
293
+ return (
294
+ <label className={`block ${className}`}>
295
+ <span className="text-xs font-semibold uppercase tracking-wider text-muted mb-1.5 block">
296
+ {label}
297
+ </span>
298
+ <input
299
+ name={name}
300
+ type={type}
301
+ defaultValue={defaultValue}
302
+ required={name !== "address_2"}
303
+ className="w-full border border-cart-border rounded-none px-3 py-2.5 text-sm bg-surface text-heading focus:outline-none focus:border-brand-accent"
304
+ />
305
+ </label>
306
+ )
307
+ }