@digilogiclabs/create-saas-app 2.10.0 → 2.11.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 (60) hide show
  1. package/README.md +153 -113
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cli/commands/create.d.ts.map +1 -1
  4. package/dist/cli/commands/create.js +2 -6
  5. package/dist/cli/commands/create.js.map +1 -1
  6. package/dist/templates/web/ai-platform/template/src/app/api/auth/route.ts +57 -0
  7. package/dist/templates/web/ai-platform/template/src/app/login/page.tsx +112 -0
  8. package/dist/templates/web/ai-platform/template/src/app/models/page.tsx +186 -0
  9. package/dist/templates/web/ai-platform/template/src/app/playground/page.tsx +251 -0
  10. package/dist/templates/web/ai-platform/template/src/app/settings/page.tsx +190 -0
  11. package/dist/templates/web/ai-platform/template/src/app/signup/page.tsx +133 -0
  12. package/dist/templates/web/ai-platform/template/src/lib/auth-session.ts +52 -0
  13. package/dist/templates/web/iot-dashboard/template/src/app/alerts/page.tsx +157 -0
  14. package/dist/templates/web/iot-dashboard/template/src/app/api/auth/route.ts +57 -0
  15. package/dist/templates/web/iot-dashboard/template/src/app/devices/[id]/page.tsx +204 -0
  16. package/dist/templates/web/iot-dashboard/template/src/app/devices/new/page.tsx +139 -0
  17. package/dist/templates/web/iot-dashboard/template/src/app/devices/page.tsx +171 -0
  18. package/dist/templates/web/iot-dashboard/template/src/app/login/page.tsx +112 -0
  19. package/dist/templates/web/iot-dashboard/template/src/app/settings/page.tsx +186 -0
  20. package/dist/templates/web/iot-dashboard/template/src/app/signup/page.tsx +133 -0
  21. package/dist/templates/web/iot-dashboard/template/src/lib/auth-session.ts +52 -0
  22. package/dist/templates/web/marketplace/template/src/app/api/auth/route.ts +57 -0
  23. package/dist/templates/web/marketplace/template/src/app/login/page.tsx +112 -0
  24. package/dist/templates/web/marketplace/template/src/app/orders/page.tsx +160 -0
  25. package/dist/templates/web/marketplace/template/src/app/products/[id]/page.tsx +218 -0
  26. package/dist/templates/web/marketplace/template/src/app/settings/page.tsx +150 -0
  27. package/dist/templates/web/marketplace/template/src/app/signup/page.tsx +133 -0
  28. package/dist/templates/web/marketplace/template/src/lib/auth-session.ts +52 -0
  29. package/dist/templates/web/micro-saas/template/src/app/api/auth/route.ts +57 -0
  30. package/dist/templates/web/micro-saas/template/src/app/login/page.tsx +14 -3
  31. package/dist/templates/web/micro-saas/template/src/app/signup/page.tsx +15 -4
  32. package/dist/templates/web/micro-saas/template/src/lib/auth-session.ts +52 -0
  33. package/package.json +1 -1
  34. package/src/templates/web/ai-platform/template/src/app/api/auth/route.ts +57 -0
  35. package/src/templates/web/ai-platform/template/src/app/login/page.tsx +112 -0
  36. package/src/templates/web/ai-platform/template/src/app/models/page.tsx +186 -0
  37. package/src/templates/web/ai-platform/template/src/app/playground/page.tsx +251 -0
  38. package/src/templates/web/ai-platform/template/src/app/settings/page.tsx +190 -0
  39. package/src/templates/web/ai-platform/template/src/app/signup/page.tsx +133 -0
  40. package/src/templates/web/ai-platform/template/src/lib/auth-session.ts +52 -0
  41. package/src/templates/web/iot-dashboard/template/src/app/alerts/page.tsx +157 -0
  42. package/src/templates/web/iot-dashboard/template/src/app/api/auth/route.ts +57 -0
  43. package/src/templates/web/iot-dashboard/template/src/app/devices/[id]/page.tsx +204 -0
  44. package/src/templates/web/iot-dashboard/template/src/app/devices/new/page.tsx +139 -0
  45. package/src/templates/web/iot-dashboard/template/src/app/devices/page.tsx +171 -0
  46. package/src/templates/web/iot-dashboard/template/src/app/login/page.tsx +112 -0
  47. package/src/templates/web/iot-dashboard/template/src/app/settings/page.tsx +186 -0
  48. package/src/templates/web/iot-dashboard/template/src/app/signup/page.tsx +133 -0
  49. package/src/templates/web/iot-dashboard/template/src/lib/auth-session.ts +52 -0
  50. package/src/templates/web/marketplace/template/src/app/api/auth/route.ts +57 -0
  51. package/src/templates/web/marketplace/template/src/app/login/page.tsx +112 -0
  52. package/src/templates/web/marketplace/template/src/app/orders/page.tsx +160 -0
  53. package/src/templates/web/marketplace/template/src/app/products/[id]/page.tsx +218 -0
  54. package/src/templates/web/marketplace/template/src/app/settings/page.tsx +150 -0
  55. package/src/templates/web/marketplace/template/src/app/signup/page.tsx +133 -0
  56. package/src/templates/web/marketplace/template/src/lib/auth-session.ts +52 -0
  57. package/src/templates/web/micro-saas/template/src/app/api/auth/route.ts +57 -0
  58. package/src/templates/web/micro-saas/template/src/app/login/page.tsx +14 -3
  59. package/src/templates/web/micro-saas/template/src/app/signup/page.tsx +15 -4
  60. package/src/templates/web/micro-saas/template/src/lib/auth-session.ts +52 -0
@@ -0,0 +1,251 @@
1
+ 'use client'
2
+
3
+ import { useState } from 'react'
4
+ import { Button, Card } from '@digilogiclabs/saas-factory-ui'
5
+ import { Play, Loader2, Clock, Hash, Bot } from 'lucide-react'
6
+ import { useAuth } from '@digilogiclabs/app-sdk'
7
+ import Link from 'next/link'
8
+
9
+ const MODELS = [
10
+ { id: 'gpt-4o', name: 'GPT-4o' },
11
+ { id: 'gpt-4o-mini', name: 'GPT-4o Mini' },
12
+ { id: 'claude-3-5-sonnet', name: 'Claude 3.5 Sonnet' },
13
+ { id: 'claude-3-haiku', name: 'Claude 3 Haiku' },
14
+ { id: 'gemini-1-5-pro', name: 'Gemini 1.5 Pro' },
15
+ { id: 'gemini-flash', name: 'Gemini Flash' },
16
+ ]
17
+
18
+ const DEMO_RESPONSES: Record<string, string> = {
19
+ 'gpt-4o': 'This is a simulated response from GPT-4o. In production, this would connect to the OpenAI API and return a real completion based on your prompt and parameters.',
20
+ 'gpt-4o-mini': 'This is a simulated response from GPT-4o Mini. This model is optimized for speed and cost-efficiency while maintaining good quality output.',
21
+ 'claude-3-5-sonnet': 'This is a simulated response from Claude 3.5 Sonnet. Known for nuanced analysis and careful reasoning, this model excels at complex tasks.',
22
+ 'claude-3-haiku': 'This is a simulated response from Claude 3 Haiku. Designed for fast, concise responses ideal for automation and quick queries.',
23
+ 'gemini-1-5-pro': 'This is a simulated response from Gemini 1.5 Pro. With its large context window, this model handles long documents and complex multi-turn conversations well.',
24
+ 'gemini-flash': 'This is a simulated response from Gemini Flash. Optimized for ultra-fast inference, this model provides quick responses at minimal cost.',
25
+ }
26
+
27
+ export default function PlaygroundPage() {
28
+ const { user, loading: authLoading } = useAuth()
29
+ const [model, setModel] = useState(MODELS[0].id)
30
+ const [systemPrompt, setSystemPrompt] = useState('You are a helpful AI assistant.')
31
+ const [userMessage, setUserMessage] = useState('')
32
+ const [temperature, setTemperature] = useState(0.7)
33
+ const [maxTokens, setMaxTokens] = useState(1024)
34
+ const [response, setResponse] = useState('')
35
+ const [isRunning, setIsRunning] = useState(false)
36
+ const [tokenCount, setTokenCount] = useState<number | null>(null)
37
+ const [responseTime, setResponseTime] = useState<number | null>(null)
38
+
39
+ const handleRun = async () => {
40
+ if (!userMessage.trim() || isRunning) return
41
+
42
+ setIsRunning(true)
43
+ setResponse('')
44
+ setTokenCount(null)
45
+ setResponseTime(null)
46
+
47
+ const start = Date.now()
48
+
49
+ await new Promise(resolve => setTimeout(resolve, 500 + Math.random() * 500))
50
+
51
+ const demoResponse = DEMO_RESPONSES[model] || 'Response from the selected model.'
52
+ const fullResponse = `${demoResponse}\n\nParameters used:\n- Model: ${model}\n- Temperature: ${temperature}\n- Max Tokens: ${maxTokens}\n- System Prompt: "${systemPrompt}"\n- User Message: "${userMessage}"`
53
+
54
+ setResponse(fullResponse)
55
+ setTokenCount(Math.floor(fullResponse.split(/\s+/).length * 1.3))
56
+ setResponseTime(Date.now() - start)
57
+ setIsRunning(false)
58
+ }
59
+
60
+ if (authLoading) {
61
+ return (
62
+ <div className="min-h-screen bg-background flex items-center justify-center">
63
+ <Loader2 className="w-8 h-8 text-primary animate-spin" />
64
+ </div>
65
+ )
66
+ }
67
+
68
+ if (!user) {
69
+ return (
70
+ <div className="min-h-screen bg-background flex items-center justify-center">
71
+ <Card className="p-8 bg-secondary border-border text-center max-w-md">
72
+ <Bot className="w-16 h-16 text-primary mx-auto mb-4" />
73
+ <h2 className="text-2xl font-bold text-foreground mb-2">Sign in to use Playground</h2>
74
+ <p className="text-muted-foreground mb-6">
75
+ Create an account to test AI models in the playground.
76
+ </p>
77
+ <div className="flex gap-2 justify-center">
78
+ <Link href="/login">
79
+ <Button variant="outline">Sign In</Button>
80
+ </Link>
81
+ <Link href="/signup">
82
+ <Button>Sign Up</Button>
83
+ </Link>
84
+ </div>
85
+ </Card>
86
+ </div>
87
+ )
88
+ }
89
+
90
+ return (
91
+ <div className="min-h-screen bg-background">
92
+ <div className="max-w-7xl mx-auto px-4 py-8">
93
+ {/* Header */}
94
+ <div className="mb-8">
95
+ <h1 className="text-3xl font-bold text-foreground">API Playground</h1>
96
+ <p className="text-muted-foreground mt-1">
97
+ Test different models and parameters before integrating into your app.
98
+ </p>
99
+ </div>
100
+
101
+ {/* Split Layout */}
102
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
103
+ {/* Left Panel - Request */}
104
+ <Card className="p-6 bg-secondary border-border">
105
+ <h2 className="text-lg font-semibold text-foreground mb-4">Request</h2>
106
+
107
+ {/* Model Selection */}
108
+ <div className="mb-4">
109
+ <label className="block text-sm font-medium text-muted-foreground mb-1.5">
110
+ Model
111
+ </label>
112
+ <select
113
+ value={model}
114
+ onChange={(e) => setModel(e.target.value)}
115
+ className="w-full bg-muted border border-border rounded-lg px-3 py-2 text-foreground text-sm focus:ring-2 focus:ring-ring"
116
+ >
117
+ {MODELS.map((m) => (
118
+ <option key={m.id} value={m.id} className="bg-card">
119
+ {m.name}
120
+ </option>
121
+ ))}
122
+ </select>
123
+ </div>
124
+
125
+ {/* System Prompt */}
126
+ <div className="mb-4">
127
+ <label className="block text-sm font-medium text-muted-foreground mb-1.5">
128
+ System Prompt
129
+ </label>
130
+ <textarea
131
+ value={systemPrompt}
132
+ onChange={(e) => setSystemPrompt(e.target.value)}
133
+ rows={3}
134
+ className="w-full bg-muted border border-border rounded-lg px-3 py-2 text-foreground text-sm placeholder-muted-foreground focus:ring-2 focus:ring-ring resize-none"
135
+ placeholder="You are a helpful assistant..."
136
+ />
137
+ </div>
138
+
139
+ {/* User Message */}
140
+ <div className="mb-4">
141
+ <label className="block text-sm font-medium text-muted-foreground mb-1.5">
142
+ User Message
143
+ </label>
144
+ <textarea
145
+ value={userMessage}
146
+ onChange={(e) => setUserMessage(e.target.value)}
147
+ rows={4}
148
+ className="w-full bg-muted border border-border rounded-lg px-3 py-2 text-foreground text-sm placeholder-muted-foreground focus:ring-2 focus:ring-ring resize-none"
149
+ placeholder="Enter your message..."
150
+ />
151
+ </div>
152
+
153
+ {/* Temperature */}
154
+ <div className="mb-4">
155
+ <div className="flex items-center justify-between mb-1.5">
156
+ <label className="text-sm font-medium text-muted-foreground">Temperature</label>
157
+ <span className="text-sm text-foreground font-mono">{temperature.toFixed(1)}</span>
158
+ </div>
159
+ <input
160
+ type="range"
161
+ min="0"
162
+ max="1"
163
+ step="0.1"
164
+ value={temperature}
165
+ onChange={(e) => setTemperature(parseFloat(e.target.value))}
166
+ className="w-full accent-primary"
167
+ />
168
+ <div className="flex justify-between text-xs text-muted-foreground mt-1">
169
+ <span>Precise</span>
170
+ <span>Creative</span>
171
+ </div>
172
+ </div>
173
+
174
+ {/* Max Tokens */}
175
+ <div className="mb-6">
176
+ <label className="block text-sm font-medium text-muted-foreground mb-1.5">
177
+ Max Tokens
178
+ </label>
179
+ <input
180
+ type="number"
181
+ value={maxTokens}
182
+ onChange={(e) => setMaxTokens(parseInt(e.target.value) || 0)}
183
+ min={1}
184
+ max={4096}
185
+ className="w-full bg-muted border border-border rounded-lg px-3 py-2 text-foreground text-sm focus:ring-2 focus:ring-ring"
186
+ />
187
+ </div>
188
+
189
+ {/* Run Button */}
190
+ <Button
191
+ className="w-full"
192
+ onClick={handleRun}
193
+ disabled={!userMessage.trim() || isRunning}
194
+ >
195
+ {isRunning ? (
196
+ <>
197
+ <Loader2 className="w-4 h-4 mr-2 animate-spin" />
198
+ Running...
199
+ </>
200
+ ) : (
201
+ <>
202
+ <Play className="w-4 h-4 mr-2" />
203
+ Run
204
+ </>
205
+ )}
206
+ </Button>
207
+ </Card>
208
+
209
+ {/* Right Panel - Response */}
210
+ <Card className="p-6 bg-secondary border-border flex flex-col">
211
+ <h2 className="text-lg font-semibold text-foreground mb-4">Response</h2>
212
+
213
+ {/* Response Area */}
214
+ <div className="bg-muted rounded-lg p-4 flex-1 min-h-[300px] font-mono text-sm text-foreground whitespace-pre-wrap overflow-auto">
215
+ {isRunning ? (
216
+ <div className="flex items-center gap-2 text-muted-foreground">
217
+ <Loader2 className="w-4 h-4 animate-spin" />
218
+ Generating response...
219
+ </div>
220
+ ) : response ? (
221
+ response
222
+ ) : (
223
+ <span className="text-muted-foreground">
224
+ Response will appear here after you click Run.
225
+ </span>
226
+ )}
227
+ </div>
228
+
229
+ {/* Metadata */}
230
+ {(tokenCount !== null || responseTime !== null) && (
231
+ <div className="flex gap-4 mt-4 pt-4 border-t border-border">
232
+ {tokenCount !== null && (
233
+ <div className="flex items-center gap-1.5 text-sm text-muted-foreground">
234
+ <Hash className="w-4 h-4" />
235
+ <span>{tokenCount} tokens</span>
236
+ </div>
237
+ )}
238
+ {responseTime !== null && (
239
+ <div className="flex items-center gap-1.5 text-sm text-muted-foreground">
240
+ <Clock className="w-4 h-4" />
241
+ <span>{responseTime}ms</span>
242
+ </div>
243
+ )}
244
+ </div>
245
+ )}
246
+ </Card>
247
+ </div>
248
+ </div>
249
+ </div>
250
+ )
251
+ }
@@ -0,0 +1,190 @@
1
+ 'use client'
2
+
3
+ import { useState } from 'react'
4
+ import { Button, Card } from '@digilogiclabs/saas-factory-ui'
5
+ import { User, Key, CreditCard, Copy, Eye, EyeOff, Trash2, Plus, Zap } from 'lucide-react'
6
+
7
+ const MOCK_KEYS = [
8
+ { id: '1', name: 'Production', key: 'sk-proj-abc...xyz', created: '2026-01-15', lastUsed: '2 hours ago' },
9
+ { id: '2', name: 'Development', key: 'sk-proj-def...uvw', created: '2026-02-20', lastUsed: '3 days ago' },
10
+ ]
11
+
12
+ export default function SettingsPage() {
13
+ const [activeTab, setActiveTab] = useState<'profile' | 'keys' | 'billing'>('profile')
14
+ const [name, setName] = useState('Test User')
15
+ const [revealedKeys, setRevealedKeys] = useState<Set<string>>(new Set())
16
+
17
+ const toggleReveal = (id: string) => {
18
+ setRevealedKeys(prev => {
19
+ const next = new Set(prev)
20
+ if (next.has(id)) next.delete(id)
21
+ else next.add(id)
22
+ return next
23
+ })
24
+ }
25
+
26
+ const tabs = [
27
+ { id: 'profile' as const, label: 'Profile', icon: User },
28
+ { id: 'keys' as const, label: 'API Keys', icon: Key },
29
+ { id: 'billing' as const, label: 'Billing', icon: CreditCard },
30
+ ]
31
+
32
+ return (
33
+ <div className="min-h-screen bg-background">
34
+ <div className="max-w-4xl mx-auto px-4 sm:px-6 py-8">
35
+ <h1 className="text-3xl font-bold text-foreground mb-8">Settings</h1>
36
+
37
+ {/* Tabs */}
38
+ <div className="flex gap-1 mb-8 border-b border-border" role="tablist">
39
+ {tabs.map(({ id, label, icon: Icon }) => (
40
+ <button
41
+ key={id}
42
+ role="tab"
43
+ aria-selected={activeTab === id}
44
+ onClick={() => setActiveTab(id)}
45
+ className={`flex items-center gap-2 px-4 py-2.5 text-sm font-medium border-b-2 transition-colors -mb-px ${
46
+ activeTab === id
47
+ ? 'border-primary text-foreground'
48
+ : 'border-transparent text-muted-foreground hover:text-foreground'
49
+ }`}
50
+ >
51
+ <Icon className="w-4 h-4" />
52
+ {label}
53
+ </button>
54
+ ))}
55
+ </div>
56
+
57
+ {/* Profile Tab */}
58
+ {activeTab === 'profile' && (
59
+ <Card className="p-6 bg-secondary border-border">
60
+ <h2 className="text-lg font-semibold text-foreground mb-6">Profile Information</h2>
61
+ <div className="space-y-4 max-w-md">
62
+ <div>
63
+ <label htmlFor="name" className="block text-sm font-medium mb-1.5">Name</label>
64
+ <input
65
+ id="name"
66
+ type="text"
67
+ value={name}
68
+ onChange={(e) => setName(e.target.value)}
69
+ className="w-full px-3 py-2.5 rounded-lg border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"
70
+ />
71
+ </div>
72
+ <div>
73
+ <label htmlFor="email" className="block text-sm font-medium mb-1.5">Email</label>
74
+ <input
75
+ id="email"
76
+ type="email"
77
+ value="user@example.com"
78
+ readOnly
79
+ className="w-full px-3 py-2.5 rounded-lg border border-input bg-muted text-muted-foreground cursor-not-allowed"
80
+ />
81
+ <p className="text-xs text-muted-foreground mt-1">Contact support to change your email.</p>
82
+ </div>
83
+ <Button className="mt-4">Save Changes</Button>
84
+ </div>
85
+ </Card>
86
+ )}
87
+
88
+ {/* API Keys Tab */}
89
+ {activeTab === 'keys' && (
90
+ <div className="space-y-6">
91
+ <div className="flex items-center justify-between">
92
+ <p className="text-sm text-muted-foreground">
93
+ API keys allow programmatic access to the platform. Keep them secret.
94
+ </p>
95
+ <Button size="sm">
96
+ <Plus className="w-4 h-4 mr-1" />
97
+ Create Key
98
+ </Button>
99
+ </div>
100
+
101
+ <div className="space-y-3">
102
+ {MOCK_KEYS.map((apiKey) => (
103
+ <Card key={apiKey.id} className="p-4 bg-secondary border-border">
104
+ <div className="flex items-center justify-between">
105
+ <div className="flex-1">
106
+ <div className="flex items-center gap-3 mb-1">
107
+ <span className="font-medium text-foreground">{apiKey.name}</span>
108
+ <span className="text-xs text-muted-foreground">Created {apiKey.created}</span>
109
+ </div>
110
+ <div className="flex items-center gap-2">
111
+ <code className="text-sm bg-muted px-2 py-0.5 rounded font-mono text-muted-foreground">
112
+ {revealedKeys.has(apiKey.id) ? 'sk-proj-abcdef1234567890xyz' : apiKey.key}
113
+ </code>
114
+ <button
115
+ onClick={() => toggleReveal(apiKey.id)}
116
+ className="text-muted-foreground hover:text-foreground"
117
+ aria-label={revealedKeys.has(apiKey.id) ? 'Hide key' : 'Show key'}
118
+ >
119
+ {revealedKeys.has(apiKey.id) ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
120
+ </button>
121
+ <button className="text-muted-foreground hover:text-foreground" aria-label="Copy key">
122
+ <Copy className="w-4 h-4" />
123
+ </button>
124
+ </div>
125
+ <p className="text-xs text-muted-foreground mt-1">Last used {apiKey.lastUsed}</p>
126
+ </div>
127
+ <Button variant="ghost" size="sm" className="text-destructive hover:text-destructive/80" aria-label="Delete key">
128
+ <Trash2 className="w-4 h-4" />
129
+ </Button>
130
+ </div>
131
+ </Card>
132
+ ))}
133
+ </div>
134
+ </div>
135
+ )}
136
+
137
+ {/* Billing Tab */}
138
+ {activeTab === 'billing' && (
139
+ <div className="space-y-6">
140
+ <Card className="p-6 bg-secondary border-border">
141
+ <div className="flex items-center justify-between mb-4">
142
+ <div>
143
+ <h2 className="text-lg font-semibold text-foreground">Free Tier</h2>
144
+ <p className="text-sm text-muted-foreground">Your current plan</p>
145
+ </div>
146
+ <span className="text-xs px-2.5 py-1 rounded-full bg-primary/10 text-primary font-medium">Active</span>
147
+ </div>
148
+
149
+ <div className="mb-4">
150
+ <div className="flex items-center justify-between text-sm mb-1">
151
+ <span className="text-muted-foreground">Token usage this month</span>
152
+ <span className="text-foreground font-medium">45,678 / 100,000</span>
153
+ </div>
154
+ <div className="w-full h-2 rounded-full bg-muted overflow-hidden">
155
+ <div className="h-full rounded-full bg-primary" style={{ width: '46%' }} />
156
+ </div>
157
+ </div>
158
+
159
+ <div className="grid grid-cols-3 gap-4 pt-4 border-t border-border">
160
+ <div>
161
+ <p className="text-xs text-muted-foreground">API Calls</p>
162
+ <p className="text-lg font-bold text-foreground">1,234</p>
163
+ </div>
164
+ <div>
165
+ <p className="text-xs text-muted-foreground">Models Used</p>
166
+ <p className="text-lg font-bold text-foreground">3</p>
167
+ </div>
168
+ <div>
169
+ <p className="text-xs text-muted-foreground">Avg Response</p>
170
+ <p className="text-lg font-bold text-foreground">1.2s</p>
171
+ </div>
172
+ </div>
173
+ </Card>
174
+
175
+ <Card className="p-6 bg-gradient-to-r from-brand-from/10 via-brand-via/10 to-brand-to/10 border-primary/20">
176
+ <div className="flex items-center gap-3 mb-3">
177
+ <Zap className="w-5 h-5 text-primary" />
178
+ <h3 className="font-semibold text-foreground">Upgrade to Pro</h3>
179
+ </div>
180
+ <p className="text-sm text-muted-foreground mb-4">
181
+ Get 1M tokens/month, all models, priority support, and custom fine-tuning.
182
+ </p>
183
+ <Button>Upgrade — $29/month</Button>
184
+ </Card>
185
+ </div>
186
+ )}
187
+ </div>
188
+ </div>
189
+ )
190
+ }
@@ -0,0 +1,133 @@
1
+ 'use client'
2
+
3
+ import { useState } from 'react'
4
+ import { Button, Card, CardContent } from '@digilogiclabs/saas-factory-ui'
5
+ import { Bot } from 'lucide-react'
6
+ import { useRouter } from 'next/navigation'
7
+ import Link from 'next/link'
8
+
9
+ export default function SignupPage() {
10
+ const [email, setEmail] = useState('')
11
+ const [password, setPassword] = useState('')
12
+ const [confirmPassword, setConfirmPassword] = useState('')
13
+ const [error, setError] = useState('')
14
+ const [loading, setLoading] = useState(false)
15
+ const router = useRouter()
16
+
17
+ const handleSubmit = async (e: React.FormEvent) => {
18
+ e.preventDefault()
19
+ setError('')
20
+ if (password !== confirmPassword) {
21
+ setError('Passwords do not match')
22
+ return
23
+ }
24
+ setLoading(true)
25
+ try {
26
+ const res = await fetch('/api/auth', {
27
+ method: 'POST',
28
+ headers: { 'Content-Type': 'application/json' },
29
+ body: JSON.stringify({ email, password, action: 'signup' }),
30
+ })
31
+ if (!res.ok) {
32
+ const data = await res.json()
33
+ throw new Error(data.error || 'Failed to create account')
34
+ }
35
+ router.push('/dashboard')
36
+ router.refresh()
37
+ } catch (err) {
38
+ setError(err instanceof Error ? err.message : 'Failed to create account')
39
+ } finally {
40
+ setLoading(false)
41
+ }
42
+ }
43
+
44
+ return (
45
+ <div className="min-h-screen flex items-center justify-center bg-background px-4">
46
+ <div className="w-full max-w-md">
47
+ {/* Logo */}
48
+ <Link href="/" className="flex items-center justify-center gap-2 mb-8 hover:opacity-80 transition-opacity">
49
+ <div className="w-10 h-10 rounded-xl bg-gradient-to-br from-brand-from via-brand-via to-brand-to flex items-center justify-center">
50
+ <Bot className="w-5 h-5 text-white" />
51
+ </div>
52
+ <span className="font-bold text-xl">AI Platform</span>
53
+ </Link>
54
+
55
+ <Card className="border border-border">
56
+ <CardContent className="p-8">
57
+ <div className="text-center mb-8">
58
+ <h1 className="text-2xl font-bold">Create your account</h1>
59
+ <p className="text-muted-foreground mt-2">Get started with AI models</p>
60
+ </div>
61
+
62
+ {error && (
63
+ <div className="bg-destructive/10 text-destructive p-3 rounded-lg mb-6 text-sm" role="alert">
64
+ {error}
65
+ </div>
66
+ )}
67
+
68
+ <form onSubmit={handleSubmit} className="space-y-4">
69
+ <div>
70
+ <label htmlFor="email" className="block text-sm font-medium mb-1.5">
71
+ Email
72
+ </label>
73
+ <input
74
+ id="email"
75
+ type="email"
76
+ value={email}
77
+ onChange={(e) => setEmail(e.target.value)}
78
+ className="w-full px-3 py-2.5 rounded-lg border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-shadow"
79
+ placeholder="you@example.com"
80
+ required
81
+ />
82
+ </div>
83
+
84
+ <div>
85
+ <label htmlFor="password" className="block text-sm font-medium mb-1.5">
86
+ Password
87
+ </label>
88
+ <input
89
+ id="password"
90
+ type="password"
91
+ value={password}
92
+ onChange={(e) => setPassword(e.target.value)}
93
+ className="w-full px-3 py-2.5 rounded-lg border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-shadow"
94
+ placeholder="Minimum 8 characters"
95
+ required
96
+ minLength={8}
97
+ />
98
+ </div>
99
+
100
+ <div>
101
+ <label htmlFor="confirmPassword" className="block text-sm font-medium mb-1.5">
102
+ Confirm Password
103
+ </label>
104
+ <input
105
+ id="confirmPassword"
106
+ type="password"
107
+ value={confirmPassword}
108
+ onChange={(e) => setConfirmPassword(e.target.value)}
109
+ className="w-full px-3 py-2.5 rounded-lg border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-shadow"
110
+ placeholder="Re-enter your password"
111
+ required
112
+ />
113
+ </div>
114
+
115
+ <Button type="submit" className="w-full h-11 text-base cursor-pointer hover:brightness-110 active:scale-[0.98] transition-all duration-200" disabled={loading}>
116
+ {loading ? 'Creating account...' : 'Create Account'}
117
+ </Button>
118
+ </form>
119
+
120
+ <div className="mt-6 text-center">
121
+ <p className="text-muted-foreground text-sm">
122
+ Already have an account?{' '}
123
+ <Link href="/login" className="text-primary hover:underline font-medium">
124
+ Sign in
125
+ </Link>
126
+ </p>
127
+ </div>
128
+ </CardContent>
129
+ </Card>
130
+ </div>
131
+ </div>
132
+ )
133
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Auth session adapter — demo implementation.
3
+ *
4
+ * Replace this file with a real provider when configuring your app:
5
+ * - Keycloak: import { auth } from '@/auth' (Auth.js)
6
+ * - Supabase: import { createClient } from '@/lib/supabase/server'
7
+ * - Firebase: import { getServerSession } from 'next-auth'
8
+ *
9
+ * The getSession() and getUser() exports are consumed by auth-server.ts
10
+ * and must return the same shape regardless of provider.
11
+ */
12
+ import 'server-only'
13
+ import { cookies } from 'next/headers'
14
+
15
+ type SessionUser = {
16
+ id?: string
17
+ email?: string | null
18
+ name?: string | null
19
+ roles?: string[]
20
+ }
21
+
22
+ type Session = {
23
+ user?: SessionUser
24
+ }
25
+
26
+ /**
27
+ * Get the current session from cookies.
28
+ * Demo: reads a JSON cookie set at login. Replace with your auth provider.
29
+ */
30
+ export async function getSession(): Promise<Session | null> {
31
+ const cookieStore = await cookies()
32
+ const sessionCookie = cookieStore.get('session')
33
+
34
+ if (!sessionCookie?.value) {
35
+ return null
36
+ }
37
+
38
+ try {
39
+ const session = JSON.parse(sessionCookie.value) as Session
40
+ return session
41
+ } catch {
42
+ return null
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Get the current authenticated user, or null.
48
+ */
49
+ export async function getUser(): Promise<SessionUser | null> {
50
+ const session = await getSession()
51
+ return session?.user ?? null
52
+ }