@thorprovider/create-thor-app 4.0.0 → 4.0.1
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.
- package/README.md +6 -55
- package/dist/index.js +154 -626
- package/package.json +1 -1
- package/templates/default/.agents/AGENTS.md +27 -0
- package/templates/default/.env.example +8 -30
- package/templates/default/.eslintrc.json +20 -27
- package/templates/default/README.md +52 -123
- package/templates/default/ai-validator.json +47 -29
- package/templates/default/app/api/revalidate/route.ts +27 -36
- package/templates/default/app/backend-unavailable/page.tsx +3 -7
- package/templates/default/app/error.tsx +1 -2
- package/templates/default/app/global-error.tsx +3 -3
- package/templates/default/app/globals.css +1 -71
- package/templates/default/app/layout.tsx +16 -38
- package/templates/default/app/not-found.tsx +1 -1
- package/templates/default/app/page.tsx +10 -119
- package/templates/default/components/providers/app-providers.tsx +19 -68
- package/templates/default/components/providers/cart-provider.tsx +143 -0
- package/templates/default/components/providers/commerce-provider.tsx +33 -0
- package/templates/default/components/providers/region-provider.tsx +105 -0
- package/templates/default/docs/README.md +46 -37
- package/templates/default/docs/commerce-api.md +58 -125
- package/templates/default/docs/patterns.md +128 -67
- package/templates/default/docs/project-structure.md +58 -50
- package/templates/default/docs/rules.md +43 -42
- package/templates/default/docs/types.md +105 -1024
- package/templates/default/lib/commerce.ts +33 -132
- package/templates/default/lib/env.ts +24 -94
- package/templates/default/lib/utils.ts +18 -0
- package/templates/default/next-env.d.ts +1 -1
- package/templates/default/next.config.ts +7 -0
- package/templates/default/package.json +2 -8
- package/templates/default/registry.json +6 -0
- package/templates/default/styles/tokens.css +81 -0
- package/templates/default/components/providers/navigation-provider.tsx +0 -37
- package/templates/default/config/site.config.ts +0 -156
- package/templates/default/docs/components.md +0 -282
- package/templates/default/docs/dependencies.md +0 -61
- package/templates/default/lib/auth-context.tsx +0 -213
- package/templates/default/lib/cart-provider.tsx +0 -53
- package/templates/default/lib/commerce-provider.tsx +0 -48
- package/templates/default/lib/region-detection.ts +0 -73
- package/templates/default/lib/region-provider.tsx +0 -53
- package/templates/default/lib/regions-config.ts +0 -48
- package/templates/default/lib/storefront-config.ts +0 -54
- package/templates/default/next.config.mjs +0 -51
- package/templates/default/proxy.ts +0 -155
- package/templates/default/scripts/generate-regions-config.ts +0 -498
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Site Configuration Template for @thorprovider/core
|
|
3
|
-
*
|
|
4
|
-
* Generic placeholder values. V0 and starters replace these with brand-specific content.
|
|
5
|
-
* The TYPE SHAPE is what matters — values are meant to be overridden.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { SiteConfig } from '@thorprovider/types';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Site configuration — replace values for your brand.
|
|
12
|
-
*
|
|
13
|
-
* ✅ V0 CAN modify: all values below
|
|
14
|
-
* ❌ V0 MUST NOT modify: the `satisfies SiteConfig` type constraint
|
|
15
|
-
*/
|
|
16
|
-
export const siteConfig = {
|
|
17
|
-
// Brand Information
|
|
18
|
-
name: 'My Store',
|
|
19
|
-
title: 'My Store | Powered by Thor Commerce',
|
|
20
|
-
description: 'An e-commerce store built with Thor Commerce.',
|
|
21
|
-
tagline: 'Your tagline here',
|
|
22
|
-
|
|
23
|
-
// Logos & Presets
|
|
24
|
-
logo: '/logo.svg',
|
|
25
|
-
logoDark: '/logo-dark.svg',
|
|
26
|
-
preset: 'electro',
|
|
27
|
-
|
|
28
|
-
// Site Metadata
|
|
29
|
-
url: 'https://example.com',
|
|
30
|
-
author: {
|
|
31
|
-
name: 'Store Owner',
|
|
32
|
-
email: 'hello@example.com',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
// Social Media
|
|
36
|
-
social: {
|
|
37
|
-
twitter: '@mystore',
|
|
38
|
-
instagram: '@mystore',
|
|
39
|
-
facebook: 'mystore',
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
// Navigation
|
|
43
|
-
navigation: [
|
|
44
|
-
{ name: 'Home', href: '/' },
|
|
45
|
-
{ name: 'Products', href: '/products' },
|
|
46
|
-
],
|
|
47
|
-
|
|
48
|
-
// Header Navigation Configuration
|
|
49
|
-
header: {
|
|
50
|
-
logo: {
|
|
51
|
-
src: '/logo.svg',
|
|
52
|
-
alt: 'My Store',
|
|
53
|
-
width: 150,
|
|
54
|
-
height: 40,
|
|
55
|
-
href: '/',
|
|
56
|
-
},
|
|
57
|
-
leftLinks: [],
|
|
58
|
-
rightLinks: [
|
|
59
|
-
{
|
|
60
|
-
type: 'preset' as const,
|
|
61
|
-
preset: 'account' as const,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
type: 'preset' as const,
|
|
65
|
-
preset: 'cart' as const,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
search: {
|
|
69
|
-
enabled: true,
|
|
70
|
-
width: 400,
|
|
71
|
-
placeholder: 'Search products...',
|
|
72
|
-
minChars: 1,
|
|
73
|
-
},
|
|
74
|
-
account: {
|
|
75
|
-
enabled: true,
|
|
76
|
-
label: 'Account',
|
|
77
|
-
icon: { type: 'lucide' as const, name: 'User' },
|
|
78
|
-
items: [
|
|
79
|
-
{
|
|
80
|
-
label: 'Profile',
|
|
81
|
-
href: '/profile',
|
|
82
|
-
icon: { type: 'lucide' as const, name: 'User' },
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
label: 'My Orders',
|
|
86
|
-
href: '/orders',
|
|
87
|
-
icon: { type: 'lucide' as const, name: 'Package' },
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
divider: true,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
label: 'Logout',
|
|
94
|
-
icon: { type: 'lucide' as const, name: 'LogOut' },
|
|
95
|
-
destructive: true,
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
cart: {
|
|
100
|
-
label: 'Cart',
|
|
101
|
-
variant: 'mini' as const,
|
|
102
|
-
composition: 'compact' as const,
|
|
103
|
-
showBadge: true,
|
|
104
|
-
},
|
|
105
|
-
maxWidth: 1280,
|
|
106
|
-
enableOverflow: true,
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
// Footer Links
|
|
110
|
-
footerLinks: {
|
|
111
|
-
shop: [
|
|
112
|
-
{ name: 'All Products', href: '/products' },
|
|
113
|
-
],
|
|
114
|
-
support: [
|
|
115
|
-
{ name: 'Help Center', href: '/help' },
|
|
116
|
-
{ name: 'Contact', href: '/contact' },
|
|
117
|
-
],
|
|
118
|
-
company: [],
|
|
119
|
-
legal: [
|
|
120
|
-
{ name: 'Privacy', href: '/legal/privacy' },
|
|
121
|
-
{ name: 'Terms', href: '/legal/terms' },
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
// Copyright
|
|
126
|
-
copyright: {
|
|
127
|
-
year: new Date().getFullYear(),
|
|
128
|
-
text: 'All rights reserved.',
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
// Module Configurations
|
|
132
|
-
modules: {
|
|
133
|
-
cart: {
|
|
134
|
-
mini: {
|
|
135
|
-
variant: 'mini' as const,
|
|
136
|
-
composition: 'compact' as const,
|
|
137
|
-
},
|
|
138
|
-
page: {
|
|
139
|
-
variant: 'page' as const,
|
|
140
|
-
composition: 'full' as const,
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
checkout: {
|
|
144
|
-
default: {
|
|
145
|
-
variant: 'complete' as const,
|
|
146
|
-
composition: 'accordion' as const,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
profile: {
|
|
150
|
-
default: {
|
|
151
|
-
variant: 'complete' as const,
|
|
152
|
-
composition: 'tabs' as const,
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
} satisfies SiteConfig;
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Available @thorprovider/components"
|
|
3
|
-
purpose: "Complete catalog of UI components available from @thorprovider/components with props and usage examples"
|
|
4
|
-
lastReviewed: "2026-04-25"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Available @thorprovider/components
|
|
8
|
-
|
|
9
|
-
All components import from `@thorprovider/components`. They are pure React (no Next.js), use semantic CSS tokens, and accept data + callbacks via props.
|
|
10
|
-
|
|
11
|
-
```tsx
|
|
12
|
-
import { Button, ProductCard, CartItem } from '@thorprovider/components';
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Ecommerce Components
|
|
18
|
-
|
|
19
|
-
These are purpose-built for commerce UIs. Use them instead of building from scratch.
|
|
20
|
-
|
|
21
|
-
| Component | Key Props | Callbacks |
|
|
22
|
-
|-----------|-----------|-----------|
|
|
23
|
-
| `ProductCard` | `title`, `price`, `originalPrice`, `image`, `href` | `onAddToCart` |
|
|
24
|
-
| `ProductImage` | `src`, `alt`, `fallbackSrc`, `aspectRatio` | `onError` |
|
|
25
|
-
| `ProductFilter` | `groups`, `selectedFilters` | `onFilterChange`, `onClearAll` |
|
|
26
|
-
| `ProductQuickView` | `open`, `product` | `onClose`, `onAddToCart` |
|
|
27
|
-
| `VariantSelector` | `label`, `options`, `value` | `onChange` |
|
|
28
|
-
| `PriceDisplay` | `price`, `originalPrice`, `currency` | — |
|
|
29
|
-
| `QuantitySelector` | `value`, `min`, `max` | `onChange` |
|
|
30
|
-
| `WishlistToggle` | `isWishlisted`, `size` | `onToggle` |
|
|
31
|
-
| `CartItem` | `id`, `title`, `quantity`, `price`, `image` | `onQuantityChange`, `onRemove` |
|
|
32
|
-
| `CartSummary` | `subtotal`, `total`, `shipping`, `tax` | `onCheckout` |
|
|
33
|
-
| `CartDrawer` | `open`, `items` | `onOpenChange`, `onQuantityChange`, `onRemove`, `onCheckout` |
|
|
34
|
-
| `CheckoutStepIndicator` | `steps`, `currentStep`, `completedSteps` | `onStepClick` |
|
|
35
|
-
| `SearchInput` | `value`, `placeholder`, `inputSize` | `onChange`, `onClear` |
|
|
36
|
-
| `Rating` | `value`, `max`, `showValue` | — (read-only) |
|
|
37
|
-
| `ReviewStars` | `value`, `max`, `readOnly` | `onChange` |
|
|
38
|
-
| `StatisticsCard` | `title`, `value`, `trend`, `icon` | — |
|
|
39
|
-
| `Breadcrumb` | `items`, `separator`, `maxItems` | — |
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Base Components (shadcn/ui)
|
|
44
|
-
|
|
45
|
-
Standard UI primitives. All follow shadcn patterns.
|
|
46
|
-
|
|
47
|
-
| Component | Usage |
|
|
48
|
-
|-----------|-------|
|
|
49
|
-
| `Button` | `<Button variant="default\|destructive\|outline\|secondary\|ghost\|link" size="default\|sm\|lg\|icon">` |
|
|
50
|
-
| `Input` | `<Input type="text\|email\|password" placeholder="..." />` |
|
|
51
|
-
| `Textarea` | `<Textarea rows={4} />` |
|
|
52
|
-
| `Select` | `<Select options={[{value, label}]} value={v} onChange={fn} />` |
|
|
53
|
-
| `Checkbox` | `<Checkbox checked={bool} onCheckedChange={fn} />` |
|
|
54
|
-
| `Radio` | `<Radio value={v} checked={bool} onChange={fn} />` |
|
|
55
|
-
| `RadioGroup` | Radix-based group: `<RadioGroup value={v} onValueChange={fn}>` |
|
|
56
|
-
| `Switch` | `<Switch checked={bool} onCheckedChange={fn} />` |
|
|
57
|
-
| `Toggle` | `<Toggle pressed={bool} onPressedChange={fn} />` |
|
|
58
|
-
| `Label` | `<Label htmlFor="id">Text</Label>` |
|
|
59
|
-
| `FormField` | Wrapper: label + input + error message |
|
|
60
|
-
| `FormError` | `<FormError message="Validation error" />` |
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## Layout & Typography
|
|
65
|
-
|
|
66
|
-
| Component | Usage |
|
|
67
|
-
|-----------|-------|
|
|
68
|
-
| `Card` | Container with `CardHeader`, `CardContent`, `CardFooter` subcomponents |
|
|
69
|
-
| `Heading` | `<Heading as="h1">Title</Heading>` (renders h1-h6 via `as` prop) |
|
|
70
|
-
| `Text` | `<Text size="sm\|base\|lg" weight="normal\|medium\|bold">Body text</Text>` |
|
|
71
|
-
| `Link` | `<Link href="/path">Text</Link>` — renders `<a>` (not next/link) |
|
|
72
|
-
| `Badge` | `<Badge variant="default\|secondary\|destructive\|outline">Label</Badge>` |
|
|
73
|
-
| `Separator` | `<Separator orientation="horizontal\|vertical" />` |
|
|
74
|
-
| `AspectRatio` | `<AspectRatio ratio={16/9}><img /></AspectRatio>` |
|
|
75
|
-
| `ScrollArea` | Scrollable container with custom scrollbar |
|
|
76
|
-
| `Skeleton` | Loading placeholder: `<Skeleton className="h-4 w-[200px]" />` |
|
|
77
|
-
| `Progress` | `<Progress value={60} max={100} />` |
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Overlay & Navigation
|
|
82
|
-
|
|
83
|
-
| Component | Usage |
|
|
84
|
-
|-----------|-------|
|
|
85
|
-
| `Dialog` | Modal: `Dialog` + `DialogTrigger` + `DialogContent` + `DialogHeader` + `DialogTitle` + `DialogFooter` |
|
|
86
|
-
| `AlertDialog` | Confirmation: `AlertDialog` + `AlertDialogTrigger` + `AlertDialogAction` + `AlertDialogCancel` |
|
|
87
|
-
| `Sheet` | Slide-out drawer: `Sheet` + `SheetTrigger` + `SheetContent` + `SheetHeader` |
|
|
88
|
-
| `Popover` | Floating panel: `Popover` + `PopoverTrigger` + `PopoverContent` |
|
|
89
|
-
| `DropdownMenu` | Context menu: `DropdownMenu` + `DropdownMenuTrigger` + `DropdownMenuContent` + `DropdownMenuItem` |
|
|
90
|
-
| `NavigationMenu` | Mega menu: `NavigationMenu` + `NavigationMenuList` + `NavigationMenuItem` + `NavigationMenuTrigger` |
|
|
91
|
-
| `Tooltip` | `<Tooltip><TooltipTrigger>Hover me</TooltipTrigger><TooltipContent>Info</TooltipContent></Tooltip>` |
|
|
92
|
-
| `HoverCard` | Preview on hover: `HoverCard` + `HoverCardTrigger` + `HoverCardContent` |
|
|
93
|
-
| `Tabs` | `<Tabs defaultValue="tab1"><TabsList><TabsTrigger value="tab1">Tab 1</TabsTrigger></TabsList><TabsContent value="tab1">...</TabsContent></Tabs>` |
|
|
94
|
-
| `Accordion` | Expandable: `Accordion` + `AccordionItem` + `AccordionTrigger` + `AccordionContent` |
|
|
95
|
-
| `Pagination` | `<Pagination currentPage={1} totalPages={10} onPageChange={fn} />` |
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## Feedback
|
|
100
|
-
|
|
101
|
-
| Component | Usage |
|
|
102
|
-
|-----------|-------|
|
|
103
|
-
| `Alert` | `<Alert variant="default\|success\|warning\|destructive">Message</Alert>` |
|
|
104
|
-
| `LoadingSpinner` | `<LoadingSpinner size="sm\|md\|lg" />` |
|
|
105
|
-
| `EmptyState` | `<EmptyState icon={Icon} title="No items" description="..." action={<Button>CTA</Button>} />` |
|
|
106
|
-
| `Avatar` | `<Avatar><AvatarImage src={url} /><AvatarFallback>JD</AvatarFallback></Avatar>` |
|
|
107
|
-
| `PriceInput` | `<PriceInput value={amount} currency="USD" onChange={fn} />` |
|
|
108
|
-
| `TagInput` | `<TagInput tags={["tag1"]} onTagsChange={fn} />` |
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Data Fetching Pattern
|
|
113
|
-
|
|
114
|
-
Components receive data via props from server components. Example:
|
|
115
|
-
|
|
116
|
-
```tsx
|
|
117
|
-
// app/page.tsx (server component)
|
|
118
|
-
import { commerce } from '@/lib/commerce';
|
|
119
|
-
import { backendCircuitBreaker } from '@thorprovider/adapters';
|
|
120
|
-
import { ProductCard } from '@thorprovider/components';
|
|
121
|
-
|
|
122
|
-
export default async function HomePage() {
|
|
123
|
-
const products = await backendCircuitBreaker.execute(
|
|
124
|
-
() => commerce.getProducts({ first: 8 }),
|
|
125
|
-
[],
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
130
|
-
{products.map((p) => (
|
|
131
|
-
<ProductCard
|
|
132
|
-
key={p.id}
|
|
133
|
-
title={p.title}
|
|
134
|
-
price={parseFloat(p.priceRange?.minVariantPrice?.amount ?? '0')}
|
|
135
|
-
image={p.featuredImage?.url ?? ''}
|
|
136
|
-
href={`/products/${p.handle}`}
|
|
137
|
-
/>
|
|
138
|
-
))}
|
|
139
|
-
</div>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Client Component Pattern (hooks + interactivity)
|
|
145
|
-
|
|
146
|
-
```tsx
|
|
147
|
-
'use client';
|
|
148
|
-
// components/add-to-cart-button.tsx
|
|
149
|
-
import { useState } from 'react';
|
|
150
|
-
import { useCart } from '@/lib/cart-provider';
|
|
151
|
-
import { Button } from '@thorprovider/components';
|
|
152
|
-
|
|
153
|
-
export function AddToCartButton({ variantId }: { variantId: string }) {
|
|
154
|
-
const { addItem, isLoading } = useCart();
|
|
155
|
-
const [added, setAdded] = useState(false);
|
|
156
|
-
|
|
157
|
-
async function handleAdd() {
|
|
158
|
-
await addItem(variantId, 1);
|
|
159
|
-
setAdded(true);
|
|
160
|
-
setTimeout(() => setAdded(false), 2000);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<Button onClick={handleAdd} disabled={isLoading}>
|
|
165
|
-
{added ? 'Added!' : 'Add to Cart'}
|
|
166
|
-
</Button>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Product Variant Selection Flow
|
|
172
|
-
|
|
173
|
-
```tsx
|
|
174
|
-
'use client';
|
|
175
|
-
// Selecting a variant → adding to cart
|
|
176
|
-
import { useState } from 'react';
|
|
177
|
-
import { VariantSelector, QuantitySelector, PriceDisplay } from '@thorprovider/components';
|
|
178
|
-
import { useCart } from '@/lib/cart-provider';
|
|
179
|
-
import type { Product, ProductVariant } from '@thorprovider/types';
|
|
180
|
-
|
|
181
|
-
export function ProductOptions({ product }: { product: Product }) {
|
|
182
|
-
const { addItem } = useCart();
|
|
183
|
-
const [selected, setSelected] = useState<Record<string, string>>({});
|
|
184
|
-
const [quantity, setQuantity] = useState(1);
|
|
185
|
-
|
|
186
|
-
// Find variant matching selected options
|
|
187
|
-
const variant = product.variants.find((v) =>
|
|
188
|
-
v.selectedOptions.every((opt) => selected[opt.name] === opt.value)
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
return (
|
|
192
|
-
<div className="space-y-4">
|
|
193
|
-
{product.options.map((opt) => (
|
|
194
|
-
<VariantSelector
|
|
195
|
-
key={opt.id}
|
|
196
|
-
label={opt.name}
|
|
197
|
-
options={opt.values.map((v) => ({ label: v, value: v }))}
|
|
198
|
-
value={selected[opt.name] ?? ''}
|
|
199
|
-
onChange={(val) => setSelected((prev) => ({ ...prev, [opt.name]: val }))}
|
|
200
|
-
/>
|
|
201
|
-
))}
|
|
202
|
-
{variant && (
|
|
203
|
-
<>
|
|
204
|
-
<PriceDisplay
|
|
205
|
-
price={parseFloat(variant.price.amount)}
|
|
206
|
-
originalPrice={variant.compareAtPrice ? parseFloat(variant.compareAtPrice.amount) : undefined}
|
|
207
|
-
currency={variant.price.currencyCode}
|
|
208
|
-
/>
|
|
209
|
-
<QuantitySelector value={quantity} onChange={setQuantity} min={1} max={10} />
|
|
210
|
-
<button onClick={() => addItem(variant.id, quantity)}>Add to Cart</button>
|
|
211
|
-
</>
|
|
212
|
-
)}
|
|
213
|
-
</div>
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## Available Hooks (from @thorprovider/providers via lib/)
|
|
219
|
-
|
|
220
|
-
### useCart() — `import { useCart } from '@/lib/cart-provider'`
|
|
221
|
-
|
|
222
|
-
| Field | Type | Description |
|
|
223
|
-
|-------|------|-------------|
|
|
224
|
-
| `cart` | `Cart \| null` | Current cart object |
|
|
225
|
-
| `items` | `CartItem[]` | Cart line items array |
|
|
226
|
-
| `totalQuantity` | `number` | Total items in cart |
|
|
227
|
-
| `isLoading` | `boolean` | True during mutations |
|
|
228
|
-
| `error` | `Error \| null` | Last error |
|
|
229
|
-
| `addItem(variantId, qty?)` | `Promise<void>` | Add variant to cart |
|
|
230
|
-
| `updateQuantity(lineItemId, qty)` | `Promise<void>` | Update line item quantity |
|
|
231
|
-
| `removeItem(lineItemId)` | `Promise<void>` | Remove line item |
|
|
232
|
-
| `clearCart()` | `void` | Clear entire cart |
|
|
233
|
-
|
|
234
|
-
### useAuth() — `import { useAuth } from '@/lib/auth-context'`
|
|
235
|
-
|
|
236
|
-
| Field | Type | Description |
|
|
237
|
-
|-------|------|-------------|
|
|
238
|
-
| `customer` | `Customer \| null` | Current customer |
|
|
239
|
-
| `isAuthenticated` | `boolean` | True if logged in |
|
|
240
|
-
| `loading` | `boolean` | True during mutations |
|
|
241
|
-
| `login(credentials)` | `Promise<void>` | `{ email, password }` |
|
|
242
|
-
| `register(data)` | `Promise<void>` | `{ firstName, lastName, email, password }` |
|
|
243
|
-
| `logout()` | `Promise<void>` | Sign out |
|
|
244
|
-
| `requestPasswordReset(email)` | `Promise<void>` | Send reset email |
|
|
245
|
-
| `resetPassword(token, password)` | `Promise<void>` | Reset with token |
|
|
246
|
-
| `updateCustomer(data)` | `Promise<void>` | Update profile fields |
|
|
247
|
-
|
|
248
|
-
### useRegion() — `import { useRegion } from '@/lib/region-provider'`
|
|
249
|
-
|
|
250
|
-
| Field | Type | Description |
|
|
251
|
-
|-------|------|-------------|
|
|
252
|
-
| `region` | `Region` | Current region (currency, countries) |
|
|
253
|
-
| `regions` | `Region[]` | All available regions |
|
|
254
|
-
| `setRegion(regionId)` | `void` | Switch region |
|
|
255
|
-
|
|
256
|
-
### useCommerce() — `import { useCommerce } from '@/lib/commerce-provider'`
|
|
257
|
-
|
|
258
|
-
| Field | Type | Description |
|
|
259
|
-
|-------|------|-------------|
|
|
260
|
-
| `provider` | `CommerceProvider` | Commerce instance for client-side calls |
|
|
261
|
-
|
|
262
|
-
### useNavigation() — `import { useNavigation } from '@thorprovider/providers'`
|
|
263
|
-
|
|
264
|
-
| Field | Type | Description |
|
|
265
|
-
|-------|------|-------------|
|
|
266
|
-
| `Link` | `Component` | Framework-aware link (renders next/link in Next.js) |
|
|
267
|
-
| `navigate(href)` | `void` | Programmatic navigation |
|
|
268
|
-
|
|
269
|
-
## Price Formatting
|
|
270
|
-
|
|
271
|
-
`Money.amount` is always a **string** (e.g., `"45.00"`). Convert to number for display components:
|
|
272
|
-
|
|
273
|
-
```tsx
|
|
274
|
-
const price = parseFloat(product.priceRange.minVariantPrice.amount);
|
|
275
|
-
const currency = product.priceRange.minVariantPrice.currencyCode; // "USD"
|
|
276
|
-
|
|
277
|
-
// Use PriceDisplay component
|
|
278
|
-
<PriceDisplay price={price} currency={currency} />
|
|
279
|
-
|
|
280
|
-
// Or format manually
|
|
281
|
-
new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(price);
|
|
282
|
-
```
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Dependencies — @thorprovider/* Packages"
|
|
3
|
-
purpose: "Quick reference for all @thorprovider/* packages, their imports, and when to use each one"
|
|
4
|
-
lastReviewed: "2026-04-25"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Dependencies — @thorprovider/* Packages
|
|
8
|
-
|
|
9
|
-
## Quick Reference
|
|
10
|
-
|
|
11
|
-
| Package | Import | Use when |
|
|
12
|
-
|---------|--------|----------|
|
|
13
|
-
| `@thorprovider/types` | `import type { Product } from '@thorprovider/types'` | TypeScript types for domain objects |
|
|
14
|
-
| `@thorprovider/components` | `import { Button } from '@thorprovider/components'` | UI primitives — always check here first |
|
|
15
|
-
| `@thorprovider/providers` | `import { useCart } from '@thorprovider/providers'` | React hooks for commerce state |
|
|
16
|
-
| `@thorprovider/adapters` | `import { backendCircuitBreaker } from '@thorprovider/adapters'` | Resilient backend calls in pages/routes |
|
|
17
|
-
|
|
18
|
-
## @thorprovider/components — Complete Inventory (55 components)
|
|
19
|
-
|
|
20
|
-
**⚠️ Check this list BEFORE creating any UI component. If it's here, import it — don't recreate it.**
|
|
21
|
-
|
|
22
|
-
**TIER 1 — Base (20):** `Button`, `Input`, `Label`, `Badge`, `Checkbox`, `Radio`, `Card`, `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter`, `Heading`, `Text`, `Link`, `Select`, `Textarea`, `FormField`, `Dialog` (+ `DialogHeader`, `DialogTitle`, `DialogDescription`, `DialogFooter`, `DialogClose`), `Alert`, `Skeleton`
|
|
23
|
-
|
|
24
|
-
**TIER 2 — Composite (10):** `SearchInput`, `PriceInput`, `ProductImage`, `Rating`, `TagInput`, `Pagination`, `StatisticsCard`, `Breadcrumb`, `Tooltip`, `Tabs` (+ `TabsList`, `TabsTrigger`, `TabsContent`)
|
|
25
|
-
|
|
26
|
-
**TIER 3 — Ecommerce (10):** `ProductCard`, `CartItem`, `CartSummary`, `ProductFilter`, `PriceDisplay`, `FormError`, `LoadingSpinner`, `EmptyState`, `ReviewStars`, `QuantitySelector`
|
|
27
|
-
|
|
28
|
-
**TIER 4 — Advanced (20):** `Avatar`, `DropdownMenu`, `Popover`, `AlertDialog`, `Sheet`, `ScrollArea`, `Separator`, `NavigationMenu`, `Progress`, `Switch`, `Toggle`, `HoverCard`, `Accordion`, `AspectRatio`, `RadioGroup`, `CartDrawer`, `ProductQuickView`, `VariantSelector`, `CheckoutStepIndicator`, `WishlistToggle`
|
|
29
|
-
|
|
30
|
-
**Utility:** `cn` (class merging helper)
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
Need a component?
|
|
34
|
-
├─ Found above? → import { X } from '@thorprovider/components'
|
|
35
|
-
└─ Not found? → create in components/[feature].tsx
|
|
36
|
-
(compose using @thorprovider/components primitives inside)
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## @thorprovider/providers — Available Hooks
|
|
40
|
-
|
|
41
|
-
The app exposes hooks via local wrappers in `lib/`. **Always import from `@/lib/*`** (not from `@thorprovider/providers` directly) — the wrappers inject the correct commerce/region/auth dependencies:
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
import { useCart } from '@/lib/cart-provider'; // cart, items, addItem(), removeItem(), updateQuantity()
|
|
45
|
-
import { useAuth } from '@/lib/auth-context'; // customer, isAuthenticated, login(), logout()
|
|
46
|
-
import { useRegion } from '@/lib/region-provider'; // region, regions, setRegion()
|
|
47
|
-
import { useCommerce } from '@/lib/commerce-provider'; // provider (commerce instance)
|
|
48
|
-
import { useNavigation } from '@thorprovider/providers'; // Link, navigate() (framework-agnostic)
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Commerce API + Types
|
|
52
|
-
|
|
53
|
-
For method signatures → see `commerce-api.md`
|
|
54
|
-
For type definitions → see `types.md`
|
|
55
|
-
|
|
56
|
-
Quick start:
|
|
57
|
-
```ts
|
|
58
|
-
import { commerce } from '@/lib/commerce';
|
|
59
|
-
import { backendCircuitBreaker } from '@thorprovider/adapters';
|
|
60
|
-
import type { Product, Cart, Order, Customer } from '@thorprovider/types';
|
|
61
|
-
```
|