@l4yercak3/cli 1.2.16 → 1.2.18
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/docs/INTEGRATION_PATHS_ARCHITECTURE.md +1543 -0
- package/package.json +1 -1
- package/src/commands/spread.js +101 -6
- package/src/detectors/database-detector.js +245 -0
- package/src/detectors/index.js +17 -4
- package/src/generators/api-only/client.js +683 -0
- package/src/generators/api-only/index.js +96 -0
- package/src/generators/api-only/types.js +618 -0
- package/src/generators/api-only/webhooks.js +377 -0
- package/src/generators/index.js +88 -2
- package/src/generators/mcp-guide-generator.js +256 -0
- package/src/generators/quickstart/components/index.js +1699 -0
- package/src/generators/quickstart/database/convex.js +1257 -0
- package/src/generators/quickstart/database/index.js +34 -0
- package/src/generators/quickstart/database/supabase.js +1132 -0
- package/src/generators/quickstart/hooks/index.js +1047 -0
- package/src/generators/quickstart/index.js +151 -0
- package/src/generators/quickstart/pages/index.js +1466 -0
- package/src/mcp/registry/domains/benefits.js +798 -0
- package/src/mcp/registry/index.js +2 -0
- package/tests/database-detector.test.js +221 -0
- package/tests/generators-index.test.js +215 -3
|
@@ -0,0 +1,1466 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page Generator
|
|
3
|
+
* Generates Next.js App Router pages for L4YERCAK3 features
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { ensureDir, writeFileWithBackup, checkFileOverwrite } = require('../../../utils/file-utils');
|
|
9
|
+
|
|
10
|
+
class PageGenerator {
|
|
11
|
+
/**
|
|
12
|
+
* Generate Next.js pages based on selected features
|
|
13
|
+
* @param {Object} options - Generation options
|
|
14
|
+
* @returns {Promise<Object>} - Generated file paths
|
|
15
|
+
*/
|
|
16
|
+
async generate(options) {
|
|
17
|
+
const { projectPath, features = [], isTypeScript, frameworkType } = options;
|
|
18
|
+
|
|
19
|
+
// Only generate pages for Next.js
|
|
20
|
+
if (frameworkType !== 'nextjs') {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const results = {};
|
|
25
|
+
|
|
26
|
+
// Determine app directory
|
|
27
|
+
let appDir;
|
|
28
|
+
if (fs.existsSync(path.join(projectPath, 'src', 'app'))) {
|
|
29
|
+
appDir = path.join(projectPath, 'src', 'app');
|
|
30
|
+
} else if (fs.existsSync(path.join(projectPath, 'app'))) {
|
|
31
|
+
appDir = path.join(projectPath, 'app');
|
|
32
|
+
} else {
|
|
33
|
+
// Create app directory structure
|
|
34
|
+
appDir = path.join(projectPath, 'src', 'app');
|
|
35
|
+
ensureDir(appDir);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ext = isTypeScript ? 'tsx' : 'jsx';
|
|
39
|
+
|
|
40
|
+
// Generate CRM pages
|
|
41
|
+
if (features.includes('crm')) {
|
|
42
|
+
results.contactsPage = await this.generateContactsPage(appDir, ext, isTypeScript);
|
|
43
|
+
results.contactDetailPage = await this.generateContactDetailPage(appDir, ext, isTypeScript);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Generate Events pages
|
|
47
|
+
if (features.includes('events')) {
|
|
48
|
+
results.eventsPage = await this.generateEventsPage(appDir, ext, isTypeScript);
|
|
49
|
+
results.eventDetailPage = await this.generateEventDetailPage(appDir, ext, isTypeScript);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Generate Products pages
|
|
53
|
+
if (features.includes('products') || features.includes('checkout')) {
|
|
54
|
+
results.productsPage = await this.generateProductsPage(appDir, ext, isTypeScript);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Generate dashboard page (if any features selected)
|
|
58
|
+
if (features.length > 0) {
|
|
59
|
+
results.dashboardPage = await this.generateDashboardPage(appDir, ext, isTypeScript, features);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Generate providers wrapper
|
|
63
|
+
results.providers = await this.generateProviders(appDir, ext, isTypeScript);
|
|
64
|
+
|
|
65
|
+
return results;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async generateContactsPage(appDir, ext, isTypeScript) {
|
|
69
|
+
const pageDir = path.join(appDir, 'contacts');
|
|
70
|
+
ensureDir(pageDir);
|
|
71
|
+
|
|
72
|
+
const outputPath = path.join(pageDir, `page.${ext}`);
|
|
73
|
+
|
|
74
|
+
const action = await checkFileOverwrite(outputPath);
|
|
75
|
+
if (action === 'skip') {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const content = isTypeScript
|
|
80
|
+
? this.getContactsPageTS()
|
|
81
|
+
: this.getContactsPageJS();
|
|
82
|
+
|
|
83
|
+
return writeFileWithBackup(outputPath, content, action);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getContactsPageTS() {
|
|
87
|
+
return `/**
|
|
88
|
+
* Contacts Page
|
|
89
|
+
* Lists all contacts with search and filtering
|
|
90
|
+
* Auto-generated by @l4yercak3/cli
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
'use client';
|
|
94
|
+
|
|
95
|
+
import { useState } from 'react';
|
|
96
|
+
import { useRouter } from 'next/navigation';
|
|
97
|
+
import { ContactList, ContactForm } from '@/components/l4yercak3';
|
|
98
|
+
import type { Contact } from '@/lib/l4yercak3/types';
|
|
99
|
+
|
|
100
|
+
export default function ContactsPage() {
|
|
101
|
+
const router = useRouter();
|
|
102
|
+
const [showForm, setShowForm] = useState(false);
|
|
103
|
+
|
|
104
|
+
const handleSelectContact = (contact: Contact) => {
|
|
105
|
+
router.push(\`/contacts/\${contact.id}\`);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const handleCreateSuccess = (contact: Contact) => {
|
|
109
|
+
setShowForm(false);
|
|
110
|
+
router.push(\`/contacts/\${contact.id}\`);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div className="container mx-auto px-4 py-8">
|
|
115
|
+
<div className="flex justify-between items-center mb-6">
|
|
116
|
+
<h1 className="text-2xl font-bold">Contacts</h1>
|
|
117
|
+
<button
|
|
118
|
+
onClick={() => setShowForm(!showForm)}
|
|
119
|
+
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
|
120
|
+
>
|
|
121
|
+
{showForm ? 'Cancel' : 'Add Contact'}
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
{showForm && (
|
|
126
|
+
<div className="mb-6 p-4 bg-white border rounded-lg shadow-sm">
|
|
127
|
+
<h2 className="text-lg font-semibold mb-4">New Contact</h2>
|
|
128
|
+
<ContactForm
|
|
129
|
+
onSuccess={handleCreateSuccess}
|
|
130
|
+
onCancel={() => setShowForm(false)}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
<ContactList onSelect={handleSelectContact} />
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
getContactsPageJS() {
|
|
143
|
+
return `/**
|
|
144
|
+
* Contacts Page
|
|
145
|
+
* Lists all contacts with search and filtering
|
|
146
|
+
* Auto-generated by @l4yercak3/cli
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
'use client';
|
|
150
|
+
|
|
151
|
+
import { useState } from 'react';
|
|
152
|
+
import { useRouter } from 'next/navigation';
|
|
153
|
+
import { ContactList, ContactForm } from '@/components/l4yercak3';
|
|
154
|
+
|
|
155
|
+
export default function ContactsPage() {
|
|
156
|
+
const router = useRouter();
|
|
157
|
+
const [showForm, setShowForm] = useState(false);
|
|
158
|
+
|
|
159
|
+
const handleSelectContact = (contact) => {
|
|
160
|
+
router.push(\`/contacts/\${contact.id}\`);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const handleCreateSuccess = (contact) => {
|
|
164
|
+
setShowForm(false);
|
|
165
|
+
router.push(\`/contacts/\${contact.id}\`);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div className="container mx-auto px-4 py-8">
|
|
170
|
+
<div className="flex justify-between items-center mb-6">
|
|
171
|
+
<h1 className="text-2xl font-bold">Contacts</h1>
|
|
172
|
+
<button
|
|
173
|
+
onClick={() => setShowForm(!showForm)}
|
|
174
|
+
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
|
175
|
+
>
|
|
176
|
+
{showForm ? 'Cancel' : 'Add Contact'}
|
|
177
|
+
</button>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
{showForm && (
|
|
181
|
+
<div className="mb-6 p-4 bg-white border rounded-lg shadow-sm">
|
|
182
|
+
<h2 className="text-lg font-semibold mb-4">New Contact</h2>
|
|
183
|
+
<ContactForm
|
|
184
|
+
onSuccess={handleCreateSuccess}
|
|
185
|
+
onCancel={() => setShowForm(false)}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
)}
|
|
189
|
+
|
|
190
|
+
<ContactList onSelect={handleSelectContact} />
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async generateContactDetailPage(appDir, ext, isTypeScript) {
|
|
198
|
+
const pageDir = path.join(appDir, 'contacts', '[id]');
|
|
199
|
+
ensureDir(pageDir);
|
|
200
|
+
|
|
201
|
+
const outputPath = path.join(pageDir, `page.${ext}`);
|
|
202
|
+
|
|
203
|
+
const action = await checkFileOverwrite(outputPath);
|
|
204
|
+
if (action === 'skip') {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const content = isTypeScript
|
|
209
|
+
? this.getContactDetailPageTS()
|
|
210
|
+
: this.getContactDetailPageJS();
|
|
211
|
+
|
|
212
|
+
return writeFileWithBackup(outputPath, content, action);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
getContactDetailPageTS() {
|
|
216
|
+
return `/**
|
|
217
|
+
* Contact Detail Page
|
|
218
|
+
* Shows details and allows editing of a single contact
|
|
219
|
+
* Auto-generated by @l4yercak3/cli
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
'use client';
|
|
223
|
+
|
|
224
|
+
import { useState } from 'react';
|
|
225
|
+
import { useParams, useRouter } from 'next/navigation';
|
|
226
|
+
import { useContact, useDeleteContact } from '@/lib/l4yercak3/hooks/use-contacts';
|
|
227
|
+
import { ContactForm } from '@/components/l4yercak3';
|
|
228
|
+
|
|
229
|
+
export default function ContactDetailPage() {
|
|
230
|
+
const params = useParams();
|
|
231
|
+
const router = useRouter();
|
|
232
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
233
|
+
|
|
234
|
+
const contactId = params.id as string;
|
|
235
|
+
const { data: contact, isLoading, error } = useContact(contactId);
|
|
236
|
+
const deleteContact = useDeleteContact();
|
|
237
|
+
|
|
238
|
+
if (isLoading) {
|
|
239
|
+
return (
|
|
240
|
+
<div className="flex items-center justify-center min-h-screen">
|
|
241
|
+
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (error || !contact) {
|
|
247
|
+
return (
|
|
248
|
+
<div className="container mx-auto px-4 py-8">
|
|
249
|
+
<div className="p-4 bg-red-50 text-red-600 rounded-lg">
|
|
250
|
+
{error?.message || 'Contact not found'}
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const handleDelete = async () => {
|
|
257
|
+
if (confirm('Are you sure you want to delete this contact?')) {
|
|
258
|
+
await deleteContact.mutateAsync(contactId);
|
|
259
|
+
router.push('/contacts');
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const handleUpdateSuccess = () => {
|
|
264
|
+
setIsEditing(false);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<div className="container mx-auto px-4 py-8">
|
|
269
|
+
<button
|
|
270
|
+
onClick={() => router.push('/contacts')}
|
|
271
|
+
className="mb-4 text-blue-600 hover:underline"
|
|
272
|
+
>
|
|
273
|
+
← Back to Contacts
|
|
274
|
+
</button>
|
|
275
|
+
|
|
276
|
+
<div className="bg-white border rounded-lg shadow-sm p-6">
|
|
277
|
+
<div className="flex justify-between items-start mb-6">
|
|
278
|
+
<div className="flex items-center gap-4">
|
|
279
|
+
<div className="w-16 h-16 bg-blue-100 text-blue-600 rounded-full flex items-center justify-center text-2xl font-semibold">
|
|
280
|
+
{contact.firstName?.[0]}{contact.lastName?.[0]}
|
|
281
|
+
</div>
|
|
282
|
+
<div>
|
|
283
|
+
<h1 className="text-2xl font-bold">
|
|
284
|
+
{contact.firstName} {contact.lastName}
|
|
285
|
+
</h1>
|
|
286
|
+
{contact.email && (
|
|
287
|
+
<p className="text-gray-500">{contact.email}</p>
|
|
288
|
+
)}
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<div className="flex gap-2">
|
|
293
|
+
<button
|
|
294
|
+
onClick={() => setIsEditing(!isEditing)}
|
|
295
|
+
className="px-4 py-2 border rounded-lg hover:bg-gray-50 transition-colors"
|
|
296
|
+
>
|
|
297
|
+
{isEditing ? 'Cancel' : 'Edit'}
|
|
298
|
+
</button>
|
|
299
|
+
<button
|
|
300
|
+
onClick={handleDelete}
|
|
301
|
+
disabled={deleteContact.isPending}
|
|
302
|
+
className="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50"
|
|
303
|
+
>
|
|
304
|
+
{deleteContact.isPending ? 'Deleting...' : 'Delete'}
|
|
305
|
+
</button>
|
|
306
|
+
</div>
|
|
307
|
+
</div>
|
|
308
|
+
|
|
309
|
+
{isEditing ? (
|
|
310
|
+
<ContactForm
|
|
311
|
+
contact={contact}
|
|
312
|
+
onSuccess={handleUpdateSuccess}
|
|
313
|
+
onCancel={() => setIsEditing(false)}
|
|
314
|
+
/>
|
|
315
|
+
) : (
|
|
316
|
+
<div className="space-y-4">
|
|
317
|
+
{contact.phone && (
|
|
318
|
+
<div>
|
|
319
|
+
<label className="text-sm text-gray-500">Phone</label>
|
|
320
|
+
<p className="font-medium">{contact.phone}</p>
|
|
321
|
+
</div>
|
|
322
|
+
)}
|
|
323
|
+
|
|
324
|
+
{contact.tags && contact.tags.length > 0 && (
|
|
325
|
+
<div>
|
|
326
|
+
<label className="text-sm text-gray-500">Tags</label>
|
|
327
|
+
<div className="flex flex-wrap gap-2 mt-1">
|
|
328
|
+
{contact.tags.map((tag) => (
|
|
329
|
+
<span
|
|
330
|
+
key={tag}
|
|
331
|
+
className="px-3 py-1 bg-gray-100 text-gray-600 rounded-full text-sm"
|
|
332
|
+
>
|
|
333
|
+
{tag}
|
|
334
|
+
</span>
|
|
335
|
+
))}
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
)}
|
|
339
|
+
|
|
340
|
+
{contact.notes && (
|
|
341
|
+
<div>
|
|
342
|
+
<label className="text-sm text-gray-500">Notes</label>
|
|
343
|
+
<p className="whitespace-pre-wrap">{contact.notes}</p>
|
|
344
|
+
</div>
|
|
345
|
+
)}
|
|
346
|
+
</div>
|
|
347
|
+
)}
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
`;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
getContactDetailPageJS() {
|
|
356
|
+
return `/**
|
|
357
|
+
* Contact Detail Page
|
|
358
|
+
* Shows details and allows editing of a single contact
|
|
359
|
+
* Auto-generated by @l4yercak3/cli
|
|
360
|
+
*/
|
|
361
|
+
|
|
362
|
+
'use client';
|
|
363
|
+
|
|
364
|
+
import { useState } from 'react';
|
|
365
|
+
import { useParams, useRouter } from 'next/navigation';
|
|
366
|
+
import { useContact, useDeleteContact } from '@/lib/l4yercak3/hooks/use-contacts';
|
|
367
|
+
import { ContactForm } from '@/components/l4yercak3';
|
|
368
|
+
|
|
369
|
+
export default function ContactDetailPage() {
|
|
370
|
+
const params = useParams();
|
|
371
|
+
const router = useRouter();
|
|
372
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
373
|
+
|
|
374
|
+
const contactId = params.id;
|
|
375
|
+
const { data: contact, isLoading, error } = useContact(contactId);
|
|
376
|
+
const deleteContact = useDeleteContact();
|
|
377
|
+
|
|
378
|
+
if (isLoading) {
|
|
379
|
+
return (
|
|
380
|
+
<div className="flex items-center justify-center min-h-screen">
|
|
381
|
+
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
|
|
382
|
+
</div>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (error || !contact) {
|
|
387
|
+
return (
|
|
388
|
+
<div className="container mx-auto px-4 py-8">
|
|
389
|
+
<div className="p-4 bg-red-50 text-red-600 rounded-lg">
|
|
390
|
+
{error?.message || 'Contact not found'}
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const handleDelete = async () => {
|
|
397
|
+
if (confirm('Are you sure you want to delete this contact?')) {
|
|
398
|
+
await deleteContact.mutateAsync(contactId);
|
|
399
|
+
router.push('/contacts');
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
const handleUpdateSuccess = () => {
|
|
404
|
+
setIsEditing(false);
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
return (
|
|
408
|
+
<div className="container mx-auto px-4 py-8">
|
|
409
|
+
<button
|
|
410
|
+
onClick={() => router.push('/contacts')}
|
|
411
|
+
className="mb-4 text-blue-600 hover:underline"
|
|
412
|
+
>
|
|
413
|
+
← Back to Contacts
|
|
414
|
+
</button>
|
|
415
|
+
|
|
416
|
+
<div className="bg-white border rounded-lg shadow-sm p-6">
|
|
417
|
+
<div className="flex justify-between items-start mb-6">
|
|
418
|
+
<div className="flex items-center gap-4">
|
|
419
|
+
<div className="w-16 h-16 bg-blue-100 text-blue-600 rounded-full flex items-center justify-center text-2xl font-semibold">
|
|
420
|
+
{contact.firstName?.[0]}{contact.lastName?.[0]}
|
|
421
|
+
</div>
|
|
422
|
+
<div>
|
|
423
|
+
<h1 className="text-2xl font-bold">
|
|
424
|
+
{contact.firstName} {contact.lastName}
|
|
425
|
+
</h1>
|
|
426
|
+
{contact.email && (
|
|
427
|
+
<p className="text-gray-500">{contact.email}</p>
|
|
428
|
+
)}
|
|
429
|
+
</div>
|
|
430
|
+
</div>
|
|
431
|
+
|
|
432
|
+
<div className="flex gap-2">
|
|
433
|
+
<button
|
|
434
|
+
onClick={() => setIsEditing(!isEditing)}
|
|
435
|
+
className="px-4 py-2 border rounded-lg hover:bg-gray-50 transition-colors"
|
|
436
|
+
>
|
|
437
|
+
{isEditing ? 'Cancel' : 'Edit'}
|
|
438
|
+
</button>
|
|
439
|
+
<button
|
|
440
|
+
onClick={handleDelete}
|
|
441
|
+
disabled={deleteContact.isPending}
|
|
442
|
+
className="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50"
|
|
443
|
+
>
|
|
444
|
+
{deleteContact.isPending ? 'Deleting...' : 'Delete'}
|
|
445
|
+
</button>
|
|
446
|
+
</div>
|
|
447
|
+
</div>
|
|
448
|
+
|
|
449
|
+
{isEditing ? (
|
|
450
|
+
<ContactForm
|
|
451
|
+
contact={contact}
|
|
452
|
+
onSuccess={handleUpdateSuccess}
|
|
453
|
+
onCancel={() => setIsEditing(false)}
|
|
454
|
+
/>
|
|
455
|
+
) : (
|
|
456
|
+
<div className="space-y-4">
|
|
457
|
+
{contact.phone && (
|
|
458
|
+
<div>
|
|
459
|
+
<label className="text-sm text-gray-500">Phone</label>
|
|
460
|
+
<p className="font-medium">{contact.phone}</p>
|
|
461
|
+
</div>
|
|
462
|
+
)}
|
|
463
|
+
|
|
464
|
+
{contact.tags && contact.tags.length > 0 && (
|
|
465
|
+
<div>
|
|
466
|
+
<label className="text-sm text-gray-500">Tags</label>
|
|
467
|
+
<div className="flex flex-wrap gap-2 mt-1">
|
|
468
|
+
{contact.tags.map((tag) => (
|
|
469
|
+
<span
|
|
470
|
+
key={tag}
|
|
471
|
+
className="px-3 py-1 bg-gray-100 text-gray-600 rounded-full text-sm"
|
|
472
|
+
>
|
|
473
|
+
{tag}
|
|
474
|
+
</span>
|
|
475
|
+
))}
|
|
476
|
+
</div>
|
|
477
|
+
</div>
|
|
478
|
+
)}
|
|
479
|
+
|
|
480
|
+
{contact.notes && (
|
|
481
|
+
<div>
|
|
482
|
+
<label className="text-sm text-gray-500">Notes</label>
|
|
483
|
+
<p className="whitespace-pre-wrap">{contact.notes}</p>
|
|
484
|
+
</div>
|
|
485
|
+
)}
|
|
486
|
+
</div>
|
|
487
|
+
)}
|
|
488
|
+
</div>
|
|
489
|
+
</div>
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
`;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
async generateEventsPage(appDir, ext, isTypeScript) {
|
|
496
|
+
const pageDir = path.join(appDir, 'events');
|
|
497
|
+
ensureDir(pageDir);
|
|
498
|
+
|
|
499
|
+
const outputPath = path.join(pageDir, `page.${ext}`);
|
|
500
|
+
|
|
501
|
+
const action = await checkFileOverwrite(outputPath);
|
|
502
|
+
if (action === 'skip') {
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const content = isTypeScript
|
|
507
|
+
? this.getEventsPageTS()
|
|
508
|
+
: this.getEventsPageJS();
|
|
509
|
+
|
|
510
|
+
return writeFileWithBackup(outputPath, content, action);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
getEventsPageTS() {
|
|
514
|
+
return `/**
|
|
515
|
+
* Events Page
|
|
516
|
+
* Lists all events with filtering
|
|
517
|
+
* Auto-generated by @l4yercak3/cli
|
|
518
|
+
*/
|
|
519
|
+
|
|
520
|
+
'use client';
|
|
521
|
+
|
|
522
|
+
import { useRouter } from 'next/navigation';
|
|
523
|
+
import { EventList } from '@/components/l4yercak3';
|
|
524
|
+
import type { Event } from '@/lib/l4yercak3/types';
|
|
525
|
+
|
|
526
|
+
export default function EventsPage() {
|
|
527
|
+
const router = useRouter();
|
|
528
|
+
|
|
529
|
+
const handleSelectEvent = (event: Event) => {
|
|
530
|
+
router.push(\`/events/\${event.id}\`);
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
return (
|
|
534
|
+
<div className="container mx-auto px-4 py-8">
|
|
535
|
+
<h1 className="text-2xl font-bold mb-6">Events</h1>
|
|
536
|
+
<EventList onSelect={handleSelectEvent} />
|
|
537
|
+
</div>
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
`;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
getEventsPageJS() {
|
|
544
|
+
return `/**
|
|
545
|
+
* Events Page
|
|
546
|
+
* Lists all events with filtering
|
|
547
|
+
* Auto-generated by @l4yercak3/cli
|
|
548
|
+
*/
|
|
549
|
+
|
|
550
|
+
'use client';
|
|
551
|
+
|
|
552
|
+
import { useRouter } from 'next/navigation';
|
|
553
|
+
import { EventList } from '@/components/l4yercak3';
|
|
554
|
+
|
|
555
|
+
export default function EventsPage() {
|
|
556
|
+
const router = useRouter();
|
|
557
|
+
|
|
558
|
+
const handleSelectEvent = (event) => {
|
|
559
|
+
router.push(\`/events/\${event.id}\`);
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
return (
|
|
563
|
+
<div className="container mx-auto px-4 py-8">
|
|
564
|
+
<h1 className="text-2xl font-bold mb-6">Events</h1>
|
|
565
|
+
<EventList onSelect={handleSelectEvent} />
|
|
566
|
+
</div>
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
`;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
async generateEventDetailPage(appDir, ext, isTypeScript) {
|
|
573
|
+
const pageDir = path.join(appDir, 'events', '[id]');
|
|
574
|
+
ensureDir(pageDir);
|
|
575
|
+
|
|
576
|
+
const outputPath = path.join(pageDir, `page.${ext}`);
|
|
577
|
+
|
|
578
|
+
const action = await checkFileOverwrite(outputPath);
|
|
579
|
+
if (action === 'skip') {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
const content = isTypeScript
|
|
584
|
+
? this.getEventDetailPageTS()
|
|
585
|
+
: this.getEventDetailPageJS();
|
|
586
|
+
|
|
587
|
+
return writeFileWithBackup(outputPath, content, action);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
getEventDetailPageTS() {
|
|
591
|
+
return `/**
|
|
592
|
+
* Event Detail Page
|
|
593
|
+
* Shows event details and registration
|
|
594
|
+
* Auto-generated by @l4yercak3/cli
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
'use client';
|
|
598
|
+
|
|
599
|
+
import { useParams, useRouter } from 'next/navigation';
|
|
600
|
+
import { useEvent, useEventAttendees } from '@/lib/l4yercak3/hooks/use-events';
|
|
601
|
+
|
|
602
|
+
export default function EventDetailPage() {
|
|
603
|
+
const params = useParams();
|
|
604
|
+
const router = useRouter();
|
|
605
|
+
|
|
606
|
+
const eventId = params.id as string;
|
|
607
|
+
const { data: event, isLoading, error } = useEvent(eventId);
|
|
608
|
+
const { data: attendees } = useEventAttendees(eventId);
|
|
609
|
+
|
|
610
|
+
if (isLoading) {
|
|
611
|
+
return (
|
|
612
|
+
<div className="flex items-center justify-center min-h-screen">
|
|
613
|
+
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
|
|
614
|
+
</div>
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (error || !event) {
|
|
619
|
+
return (
|
|
620
|
+
<div className="container mx-auto px-4 py-8">
|
|
621
|
+
<div className="p-4 bg-red-50 text-red-600 rounded-lg">
|
|
622
|
+
{error?.message || 'Event not found'}
|
|
623
|
+
</div>
|
|
624
|
+
</div>
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
const startDate = event.startDate ? new Date(event.startDate) : null;
|
|
629
|
+
const endDate = event.endDate ? new Date(event.endDate) : null;
|
|
630
|
+
|
|
631
|
+
const formatDate = (date: Date) => {
|
|
632
|
+
return date.toLocaleDateString('en-US', {
|
|
633
|
+
weekday: 'long',
|
|
634
|
+
year: 'numeric',
|
|
635
|
+
month: 'long',
|
|
636
|
+
day: 'numeric',
|
|
637
|
+
hour: 'numeric',
|
|
638
|
+
minute: '2-digit',
|
|
639
|
+
});
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
return (
|
|
643
|
+
<div className="container mx-auto px-4 py-8">
|
|
644
|
+
<button
|
|
645
|
+
onClick={() => router.push('/events')}
|
|
646
|
+
className="mb-4 text-blue-600 hover:underline"
|
|
647
|
+
>
|
|
648
|
+
← Back to Events
|
|
649
|
+
</button>
|
|
650
|
+
|
|
651
|
+
<div className="bg-white border rounded-lg shadow-sm overflow-hidden">
|
|
652
|
+
{/* Header */}
|
|
653
|
+
<div className="p-6 border-b">
|
|
654
|
+
<div className="flex justify-between items-start">
|
|
655
|
+
<div>
|
|
656
|
+
<h1 className="text-2xl font-bold">{event.name}</h1>
|
|
657
|
+
{startDate && (
|
|
658
|
+
<p className="text-gray-500 mt-1">{formatDate(startDate)}</p>
|
|
659
|
+
)}
|
|
660
|
+
</div>
|
|
661
|
+
<span
|
|
662
|
+
className={\`px-3 py-1 rounded-full text-sm \${
|
|
663
|
+
event.status === 'published'
|
|
664
|
+
? 'bg-green-100 text-green-700'
|
|
665
|
+
: event.status === 'draft'
|
|
666
|
+
? 'bg-gray-100 text-gray-600'
|
|
667
|
+
: 'bg-red-100 text-red-700'
|
|
668
|
+
}\`}
|
|
669
|
+
>
|
|
670
|
+
{event.status}
|
|
671
|
+
</span>
|
|
672
|
+
</div>
|
|
673
|
+
</div>
|
|
674
|
+
|
|
675
|
+
{/* Content */}
|
|
676
|
+
<div className="p-6 space-y-6">
|
|
677
|
+
{event.description && (
|
|
678
|
+
<div>
|
|
679
|
+
<h2 className="text-lg font-semibold mb-2">About</h2>
|
|
680
|
+
<p className="text-gray-600 whitespace-pre-wrap">{event.description}</p>
|
|
681
|
+
</div>
|
|
682
|
+
)}
|
|
683
|
+
|
|
684
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
685
|
+
{/* Date & Time */}
|
|
686
|
+
<div>
|
|
687
|
+
<h2 className="text-lg font-semibold mb-2">Date & Time</h2>
|
|
688
|
+
<div className="space-y-1 text-gray-600">
|
|
689
|
+
{startDate && <p>Starts: {formatDate(startDate)}</p>}
|
|
690
|
+
{endDate && <p>Ends: {formatDate(endDate)}</p>}
|
|
691
|
+
</div>
|
|
692
|
+
</div>
|
|
693
|
+
|
|
694
|
+
{/* Location */}
|
|
695
|
+
{event.location && (
|
|
696
|
+
<div>
|
|
697
|
+
<h2 className="text-lg font-semibold mb-2">Location</h2>
|
|
698
|
+
<p className="text-gray-600">{event.location}</p>
|
|
699
|
+
</div>
|
|
700
|
+
)}
|
|
701
|
+
</div>
|
|
702
|
+
|
|
703
|
+
{/* Attendees */}
|
|
704
|
+
{attendees && attendees.length > 0 && (
|
|
705
|
+
<div>
|
|
706
|
+
<h2 className="text-lg font-semibold mb-2">
|
|
707
|
+
Attendees ({attendees.length})
|
|
708
|
+
</h2>
|
|
709
|
+
<div className="flex -space-x-2">
|
|
710
|
+
{attendees.slice(0, 10).map((attendee, i) => (
|
|
711
|
+
<div
|
|
712
|
+
key={attendee.id || i}
|
|
713
|
+
className="w-8 h-8 bg-blue-100 text-blue-600 rounded-full border-2 border-white flex items-center justify-center text-xs font-medium"
|
|
714
|
+
>
|
|
715
|
+
{attendee.contact?.firstName?.[0] || '?'}
|
|
716
|
+
</div>
|
|
717
|
+
))}
|
|
718
|
+
{attendees.length > 10 && (
|
|
719
|
+
<div className="w-8 h-8 bg-gray-100 text-gray-600 rounded-full border-2 border-white flex items-center justify-center text-xs">
|
|
720
|
+
+{attendees.length - 10}
|
|
721
|
+
</div>
|
|
722
|
+
)}
|
|
723
|
+
</div>
|
|
724
|
+
</div>
|
|
725
|
+
)}
|
|
726
|
+
</div>
|
|
727
|
+
|
|
728
|
+
{/* Actions */}
|
|
729
|
+
<div className="p-6 border-t bg-gray-50">
|
|
730
|
+
<button
|
|
731
|
+
className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
|
732
|
+
>
|
|
733
|
+
Register for Event
|
|
734
|
+
</button>
|
|
735
|
+
</div>
|
|
736
|
+
</div>
|
|
737
|
+
</div>
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
`;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
getEventDetailPageJS() {
|
|
744
|
+
return `/**
|
|
745
|
+
* Event Detail Page
|
|
746
|
+
* Shows event details and registration
|
|
747
|
+
* Auto-generated by @l4yercak3/cli
|
|
748
|
+
*/
|
|
749
|
+
|
|
750
|
+
'use client';
|
|
751
|
+
|
|
752
|
+
import { useParams, useRouter } from 'next/navigation';
|
|
753
|
+
import { useEvent, useEventAttendees } from '@/lib/l4yercak3/hooks/use-events';
|
|
754
|
+
|
|
755
|
+
export default function EventDetailPage() {
|
|
756
|
+
const params = useParams();
|
|
757
|
+
const router = useRouter();
|
|
758
|
+
|
|
759
|
+
const eventId = params.id;
|
|
760
|
+
const { data: event, isLoading, error } = useEvent(eventId);
|
|
761
|
+
const { data: attendees } = useEventAttendees(eventId);
|
|
762
|
+
|
|
763
|
+
if (isLoading) {
|
|
764
|
+
return (
|
|
765
|
+
<div className="flex items-center justify-center min-h-screen">
|
|
766
|
+
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
|
|
767
|
+
</div>
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
if (error || !event) {
|
|
772
|
+
return (
|
|
773
|
+
<div className="container mx-auto px-4 py-8">
|
|
774
|
+
<div className="p-4 bg-red-50 text-red-600 rounded-lg">
|
|
775
|
+
{error?.message || 'Event not found'}
|
|
776
|
+
</div>
|
|
777
|
+
</div>
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
const startDate = event.startDate ? new Date(event.startDate) : null;
|
|
782
|
+
const endDate = event.endDate ? new Date(event.endDate) : null;
|
|
783
|
+
|
|
784
|
+
const formatDate = (date) => {
|
|
785
|
+
return date.toLocaleDateString('en-US', {
|
|
786
|
+
weekday: 'long',
|
|
787
|
+
year: 'numeric',
|
|
788
|
+
month: 'long',
|
|
789
|
+
day: 'numeric',
|
|
790
|
+
hour: 'numeric',
|
|
791
|
+
minute: '2-digit',
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
return (
|
|
796
|
+
<div className="container mx-auto px-4 py-8">
|
|
797
|
+
<button
|
|
798
|
+
onClick={() => router.push('/events')}
|
|
799
|
+
className="mb-4 text-blue-600 hover:underline"
|
|
800
|
+
>
|
|
801
|
+
← Back to Events
|
|
802
|
+
</button>
|
|
803
|
+
|
|
804
|
+
<div className="bg-white border rounded-lg shadow-sm overflow-hidden">
|
|
805
|
+
{/* Header */}
|
|
806
|
+
<div className="p-6 border-b">
|
|
807
|
+
<div className="flex justify-between items-start">
|
|
808
|
+
<div>
|
|
809
|
+
<h1 className="text-2xl font-bold">{event.name}</h1>
|
|
810
|
+
{startDate && (
|
|
811
|
+
<p className="text-gray-500 mt-1">{formatDate(startDate)}</p>
|
|
812
|
+
)}
|
|
813
|
+
</div>
|
|
814
|
+
<span
|
|
815
|
+
className={\`px-3 py-1 rounded-full text-sm \${
|
|
816
|
+
event.status === 'published'
|
|
817
|
+
? 'bg-green-100 text-green-700'
|
|
818
|
+
: event.status === 'draft'
|
|
819
|
+
? 'bg-gray-100 text-gray-600'
|
|
820
|
+
: 'bg-red-100 text-red-700'
|
|
821
|
+
}\`}
|
|
822
|
+
>
|
|
823
|
+
{event.status}
|
|
824
|
+
</span>
|
|
825
|
+
</div>
|
|
826
|
+
</div>
|
|
827
|
+
|
|
828
|
+
{/* Content */}
|
|
829
|
+
<div className="p-6 space-y-6">
|
|
830
|
+
{event.description && (
|
|
831
|
+
<div>
|
|
832
|
+
<h2 className="text-lg font-semibold mb-2">About</h2>
|
|
833
|
+
<p className="text-gray-600 whitespace-pre-wrap">{event.description}</p>
|
|
834
|
+
</div>
|
|
835
|
+
)}
|
|
836
|
+
|
|
837
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
838
|
+
{/* Date & Time */}
|
|
839
|
+
<div>
|
|
840
|
+
<h2 className="text-lg font-semibold mb-2">Date & Time</h2>
|
|
841
|
+
<div className="space-y-1 text-gray-600">
|
|
842
|
+
{startDate && <p>Starts: {formatDate(startDate)}</p>}
|
|
843
|
+
{endDate && <p>Ends: {formatDate(endDate)}</p>}
|
|
844
|
+
</div>
|
|
845
|
+
</div>
|
|
846
|
+
|
|
847
|
+
{/* Location */}
|
|
848
|
+
{event.location && (
|
|
849
|
+
<div>
|
|
850
|
+
<h2 className="text-lg font-semibold mb-2">Location</h2>
|
|
851
|
+
<p className="text-gray-600">{event.location}</p>
|
|
852
|
+
</div>
|
|
853
|
+
)}
|
|
854
|
+
</div>
|
|
855
|
+
|
|
856
|
+
{/* Attendees */}
|
|
857
|
+
{attendees && attendees.length > 0 && (
|
|
858
|
+
<div>
|
|
859
|
+
<h2 className="text-lg font-semibold mb-2">
|
|
860
|
+
Attendees ({attendees.length})
|
|
861
|
+
</h2>
|
|
862
|
+
<div className="flex -space-x-2">
|
|
863
|
+
{attendees.slice(0, 10).map((attendee, i) => (
|
|
864
|
+
<div
|
|
865
|
+
key={attendee.id || i}
|
|
866
|
+
className="w-8 h-8 bg-blue-100 text-blue-600 rounded-full border-2 border-white flex items-center justify-center text-xs font-medium"
|
|
867
|
+
>
|
|
868
|
+
{attendee.contact?.firstName?.[0] || '?'}
|
|
869
|
+
</div>
|
|
870
|
+
))}
|
|
871
|
+
{attendees.length > 10 && (
|
|
872
|
+
<div className="w-8 h-8 bg-gray-100 text-gray-600 rounded-full border-2 border-white flex items-center justify-center text-xs">
|
|
873
|
+
+{attendees.length - 10}
|
|
874
|
+
</div>
|
|
875
|
+
)}
|
|
876
|
+
</div>
|
|
877
|
+
</div>
|
|
878
|
+
)}
|
|
879
|
+
</div>
|
|
880
|
+
|
|
881
|
+
{/* Actions */}
|
|
882
|
+
<div className="p-6 border-t bg-gray-50">
|
|
883
|
+
<button
|
|
884
|
+
className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
|
885
|
+
>
|
|
886
|
+
Register for Event
|
|
887
|
+
</button>
|
|
888
|
+
</div>
|
|
889
|
+
</div>
|
|
890
|
+
</div>
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
`;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
async generateProductsPage(appDir, ext, isTypeScript) {
|
|
897
|
+
const pageDir = path.join(appDir, 'products');
|
|
898
|
+
ensureDir(pageDir);
|
|
899
|
+
|
|
900
|
+
const outputPath = path.join(pageDir, `page.${ext}`);
|
|
901
|
+
|
|
902
|
+
const action = await checkFileOverwrite(outputPath);
|
|
903
|
+
if (action === 'skip') {
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
const content = isTypeScript
|
|
908
|
+
? this.getProductsPageTS()
|
|
909
|
+
: this.getProductsPageJS();
|
|
910
|
+
|
|
911
|
+
return writeFileWithBackup(outputPath, content, action);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
getProductsPageTS() {
|
|
915
|
+
return `/**
|
|
916
|
+
* Products Page
|
|
917
|
+
* Displays a grid of products with cart functionality
|
|
918
|
+
* Auto-generated by @l4yercak3/cli
|
|
919
|
+
*/
|
|
920
|
+
|
|
921
|
+
'use client';
|
|
922
|
+
|
|
923
|
+
import { useState } from 'react';
|
|
924
|
+
import { ProductGrid } from '@/components/l4yercak3';
|
|
925
|
+
import { useCreateCheckoutSession } from '@/lib/l4yercak3/hooks/use-products';
|
|
926
|
+
import type { Product } from '@/lib/l4yercak3/types';
|
|
927
|
+
|
|
928
|
+
interface CartItem {
|
|
929
|
+
product: Product;
|
|
930
|
+
quantity: number;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
export default function ProductsPage() {
|
|
934
|
+
const [cart, setCart] = useState<CartItem[]>([]);
|
|
935
|
+
const createCheckout = useCreateCheckoutSession();
|
|
936
|
+
|
|
937
|
+
const handleAddToCart = (product: Product) => {
|
|
938
|
+
setCart((prev) => {
|
|
939
|
+
const existing = prev.find((item) => item.product.id === product.id);
|
|
940
|
+
if (existing) {
|
|
941
|
+
return prev.map((item) =>
|
|
942
|
+
item.product.id === product.id
|
|
943
|
+
? { ...item, quantity: item.quantity + 1 }
|
|
944
|
+
: item
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
return [...prev, { product, quantity: 1 }];
|
|
948
|
+
});
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
const handleRemoveFromCart = (productId: string) => {
|
|
952
|
+
setCart((prev) => prev.filter((item) => item.product.id !== productId));
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
const handleCheckout = async () => {
|
|
956
|
+
const lineItems = cart.map((item) => ({
|
|
957
|
+
productId: item.product.id,
|
|
958
|
+
quantity: item.quantity,
|
|
959
|
+
}));
|
|
960
|
+
|
|
961
|
+
const session = await createCheckout.mutateAsync({
|
|
962
|
+
lineItems,
|
|
963
|
+
successUrl: \`\${window.location.origin}/checkout/success\`,
|
|
964
|
+
cancelUrl: \`\${window.location.origin}/products\`,
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
if (session.url) {
|
|
968
|
+
window.location.href = session.url;
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
const cartTotal = cart.reduce(
|
|
973
|
+
(total, item) => total + item.product.price * item.quantity,
|
|
974
|
+
0
|
|
975
|
+
);
|
|
976
|
+
|
|
977
|
+
const formatPrice = (price: number) => {
|
|
978
|
+
return new Intl.NumberFormat('en-US', {
|
|
979
|
+
style: 'currency',
|
|
980
|
+
currency: 'USD',
|
|
981
|
+
}).format(price / 100);
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
return (
|
|
985
|
+
<div className="container mx-auto px-4 py-8">
|
|
986
|
+
<div className="flex justify-between items-center mb-6">
|
|
987
|
+
<h1 className="text-2xl font-bold">Products</h1>
|
|
988
|
+
|
|
989
|
+
{/* Cart Summary */}
|
|
990
|
+
{cart.length > 0 && (
|
|
991
|
+
<div className="flex items-center gap-4">
|
|
992
|
+
<span className="text-gray-600">
|
|
993
|
+
{cart.reduce((sum, item) => sum + item.quantity, 0)} items
|
|
994
|
+
</span>
|
|
995
|
+
<span className="font-bold">{formatPrice(cartTotal)}</span>
|
|
996
|
+
<button
|
|
997
|
+
onClick={handleCheckout}
|
|
998
|
+
disabled={createCheckout.isPending}
|
|
999
|
+
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50"
|
|
1000
|
+
>
|
|
1001
|
+
{createCheckout.isPending ? 'Processing...' : 'Checkout'}
|
|
1002
|
+
</button>
|
|
1003
|
+
</div>
|
|
1004
|
+
)}
|
|
1005
|
+
</div>
|
|
1006
|
+
|
|
1007
|
+
{/* Cart Items */}
|
|
1008
|
+
{cart.length > 0 && (
|
|
1009
|
+
<div className="mb-6 p-4 bg-white border rounded-lg">
|
|
1010
|
+
<h2 className="font-semibold mb-3">Cart</h2>
|
|
1011
|
+
<div className="space-y-2">
|
|
1012
|
+
{cart.map((item) => (
|
|
1013
|
+
<div key={item.product.id} className="flex justify-between items-center">
|
|
1014
|
+
<span>
|
|
1015
|
+
{item.product.name} x {item.quantity}
|
|
1016
|
+
</span>
|
|
1017
|
+
<div className="flex items-center gap-3">
|
|
1018
|
+
<span>{formatPrice(item.product.price * item.quantity)}</span>
|
|
1019
|
+
<button
|
|
1020
|
+
onClick={() => handleRemoveFromCart(item.product.id)}
|
|
1021
|
+
className="text-red-600 hover:underline text-sm"
|
|
1022
|
+
>
|
|
1023
|
+
Remove
|
|
1024
|
+
</button>
|
|
1025
|
+
</div>
|
|
1026
|
+
</div>
|
|
1027
|
+
))}
|
|
1028
|
+
</div>
|
|
1029
|
+
</div>
|
|
1030
|
+
)}
|
|
1031
|
+
|
|
1032
|
+
<ProductGrid onAddToCart={handleAddToCart} />
|
|
1033
|
+
</div>
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
`;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
getProductsPageJS() {
|
|
1040
|
+
return `/**
|
|
1041
|
+
* Products Page
|
|
1042
|
+
* Displays a grid of products with cart functionality
|
|
1043
|
+
* Auto-generated by @l4yercak3/cli
|
|
1044
|
+
*/
|
|
1045
|
+
|
|
1046
|
+
'use client';
|
|
1047
|
+
|
|
1048
|
+
import { useState } from 'react';
|
|
1049
|
+
import { ProductGrid } from '@/components/l4yercak3';
|
|
1050
|
+
import { useCreateCheckoutSession } from '@/lib/l4yercak3/hooks/use-products';
|
|
1051
|
+
|
|
1052
|
+
export default function ProductsPage() {
|
|
1053
|
+
const [cart, setCart] = useState([]);
|
|
1054
|
+
const createCheckout = useCreateCheckoutSession();
|
|
1055
|
+
|
|
1056
|
+
const handleAddToCart = (product) => {
|
|
1057
|
+
setCart((prev) => {
|
|
1058
|
+
const existing = prev.find((item) => item.product.id === product.id);
|
|
1059
|
+
if (existing) {
|
|
1060
|
+
return prev.map((item) =>
|
|
1061
|
+
item.product.id === product.id
|
|
1062
|
+
? { ...item, quantity: item.quantity + 1 }
|
|
1063
|
+
: item
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
return [...prev, { product, quantity: 1 }];
|
|
1067
|
+
});
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
const handleRemoveFromCart = (productId) => {
|
|
1071
|
+
setCart((prev) => prev.filter((item) => item.product.id !== productId));
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
const handleCheckout = async () => {
|
|
1075
|
+
const lineItems = cart.map((item) => ({
|
|
1076
|
+
productId: item.product.id,
|
|
1077
|
+
quantity: item.quantity,
|
|
1078
|
+
}));
|
|
1079
|
+
|
|
1080
|
+
const session = await createCheckout.mutateAsync({
|
|
1081
|
+
lineItems,
|
|
1082
|
+
successUrl: \`\${window.location.origin}/checkout/success\`,
|
|
1083
|
+
cancelUrl: \`\${window.location.origin}/products\`,
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1086
|
+
if (session.url) {
|
|
1087
|
+
window.location.href = session.url;
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1091
|
+
const cartTotal = cart.reduce(
|
|
1092
|
+
(total, item) => total + item.product.price * item.quantity,
|
|
1093
|
+
0
|
|
1094
|
+
);
|
|
1095
|
+
|
|
1096
|
+
const formatPrice = (price) => {
|
|
1097
|
+
return new Intl.NumberFormat('en-US', {
|
|
1098
|
+
style: 'currency',
|
|
1099
|
+
currency: 'USD',
|
|
1100
|
+
}).format(price / 100);
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
return (
|
|
1104
|
+
<div className="container mx-auto px-4 py-8">
|
|
1105
|
+
<div className="flex justify-between items-center mb-6">
|
|
1106
|
+
<h1 className="text-2xl font-bold">Products</h1>
|
|
1107
|
+
|
|
1108
|
+
{/* Cart Summary */}
|
|
1109
|
+
{cart.length > 0 && (
|
|
1110
|
+
<div className="flex items-center gap-4">
|
|
1111
|
+
<span className="text-gray-600">
|
|
1112
|
+
{cart.reduce((sum, item) => sum + item.quantity, 0)} items
|
|
1113
|
+
</span>
|
|
1114
|
+
<span className="font-bold">{formatPrice(cartTotal)}</span>
|
|
1115
|
+
<button
|
|
1116
|
+
onClick={handleCheckout}
|
|
1117
|
+
disabled={createCheckout.isPending}
|
|
1118
|
+
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50"
|
|
1119
|
+
>
|
|
1120
|
+
{createCheckout.isPending ? 'Processing...' : 'Checkout'}
|
|
1121
|
+
</button>
|
|
1122
|
+
</div>
|
|
1123
|
+
)}
|
|
1124
|
+
</div>
|
|
1125
|
+
|
|
1126
|
+
{/* Cart Items */}
|
|
1127
|
+
{cart.length > 0 && (
|
|
1128
|
+
<div className="mb-6 p-4 bg-white border rounded-lg">
|
|
1129
|
+
<h2 className="font-semibold mb-3">Cart</h2>
|
|
1130
|
+
<div className="space-y-2">
|
|
1131
|
+
{cart.map((item) => (
|
|
1132
|
+
<div key={item.product.id} className="flex justify-between items-center">
|
|
1133
|
+
<span>
|
|
1134
|
+
{item.product.name} x {item.quantity}
|
|
1135
|
+
</span>
|
|
1136
|
+
<div className="flex items-center gap-3">
|
|
1137
|
+
<span>{formatPrice(item.product.price * item.quantity)}</span>
|
|
1138
|
+
<button
|
|
1139
|
+
onClick={() => handleRemoveFromCart(item.product.id)}
|
|
1140
|
+
className="text-red-600 hover:underline text-sm"
|
|
1141
|
+
>
|
|
1142
|
+
Remove
|
|
1143
|
+
</button>
|
|
1144
|
+
</div>
|
|
1145
|
+
</div>
|
|
1146
|
+
))}
|
|
1147
|
+
</div>
|
|
1148
|
+
</div>
|
|
1149
|
+
)}
|
|
1150
|
+
|
|
1151
|
+
<ProductGrid onAddToCart={handleAddToCart} />
|
|
1152
|
+
</div>
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
`;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
async generateDashboardPage(appDir, ext, isTypeScript, features) {
|
|
1159
|
+
const pageDir = path.join(appDir, 'dashboard');
|
|
1160
|
+
ensureDir(pageDir);
|
|
1161
|
+
|
|
1162
|
+
const outputPath = path.join(pageDir, `page.${ext}`);
|
|
1163
|
+
|
|
1164
|
+
const action = await checkFileOverwrite(outputPath);
|
|
1165
|
+
if (action === 'skip') {
|
|
1166
|
+
return null;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
const content = isTypeScript
|
|
1170
|
+
? this.getDashboardPageTS(features)
|
|
1171
|
+
: this.getDashboardPageJS(features);
|
|
1172
|
+
|
|
1173
|
+
return writeFileWithBackup(outputPath, content, action);
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
getDashboardPageTS(features) {
|
|
1177
|
+
const imports = [];
|
|
1178
|
+
const cards = [];
|
|
1179
|
+
|
|
1180
|
+
if (features.includes('crm')) {
|
|
1181
|
+
imports.push("import { useContacts } from '@/lib/l4yercak3/hooks/use-contacts';");
|
|
1182
|
+
cards.push(`
|
|
1183
|
+
{/* Contacts Card */}
|
|
1184
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1185
|
+
<h2 className="text-lg font-semibold mb-2">Contacts</h2>
|
|
1186
|
+
<div className="text-3xl font-bold text-blue-600">
|
|
1187
|
+
{contactsLoading ? '...' : contacts?.length || 0}
|
|
1188
|
+
</div>
|
|
1189
|
+
<p className="text-gray-500 text-sm mt-1">Total contacts</p>
|
|
1190
|
+
<a href="/contacts" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
|
|
1191
|
+
View all →
|
|
1192
|
+
</a>
|
|
1193
|
+
</div>`);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
if (features.includes('events')) {
|
|
1197
|
+
imports.push("import { useEvents } from '@/lib/l4yercak3/hooks/use-events';");
|
|
1198
|
+
cards.push(`
|
|
1199
|
+
{/* Events Card */}
|
|
1200
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1201
|
+
<h2 className="text-lg font-semibold mb-2">Upcoming Events</h2>
|
|
1202
|
+
<div className="text-3xl font-bold text-green-600">
|
|
1203
|
+
{eventsLoading ? '...' : events?.length || 0}
|
|
1204
|
+
</div>
|
|
1205
|
+
<p className="text-gray-500 text-sm mt-1">Events scheduled</p>
|
|
1206
|
+
<a href="/events" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
|
|
1207
|
+
View all →
|
|
1208
|
+
</a>
|
|
1209
|
+
</div>`);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
if (features.includes('products') || features.includes('checkout')) {
|
|
1213
|
+
imports.push("import { useProducts, useOrders } from '@/lib/l4yercak3/hooks/use-products';");
|
|
1214
|
+
cards.push(`
|
|
1215
|
+
{/* Products Card */}
|
|
1216
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1217
|
+
<h2 className="text-lg font-semibold mb-2">Products</h2>
|
|
1218
|
+
<div className="text-3xl font-bold text-purple-600">
|
|
1219
|
+
{productsLoading ? '...' : products?.length || 0}
|
|
1220
|
+
</div>
|
|
1221
|
+
<p className="text-gray-500 text-sm mt-1">Active products</p>
|
|
1222
|
+
<a href="/products" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
|
|
1223
|
+
View all →
|
|
1224
|
+
</a>
|
|
1225
|
+
</div>`);
|
|
1226
|
+
cards.push(`
|
|
1227
|
+
{/* Orders Card */}
|
|
1228
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1229
|
+
<h2 className="text-lg font-semibold mb-2">Recent Orders</h2>
|
|
1230
|
+
<div className="text-3xl font-bold text-orange-600">
|
|
1231
|
+
{ordersLoading ? '...' : orders?.length || 0}
|
|
1232
|
+
</div>
|
|
1233
|
+
<p className="text-gray-500 text-sm mt-1">Orders this month</p>
|
|
1234
|
+
</div>`);
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
const hookCalls = [];
|
|
1238
|
+
if (features.includes('crm')) {
|
|
1239
|
+
hookCalls.push("const { data: contacts, isLoading: contactsLoading } = useContacts();");
|
|
1240
|
+
}
|
|
1241
|
+
if (features.includes('events')) {
|
|
1242
|
+
hookCalls.push("const { data: events, isLoading: eventsLoading } = useEvents({ status: 'upcoming' });");
|
|
1243
|
+
}
|
|
1244
|
+
if (features.includes('products') || features.includes('checkout')) {
|
|
1245
|
+
hookCalls.push("const { data: products, isLoading: productsLoading } = useProducts();");
|
|
1246
|
+
hookCalls.push("const { data: orders, isLoading: ordersLoading } = useOrders();");
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
return `/**
|
|
1250
|
+
* Dashboard Page
|
|
1251
|
+
* Overview of L4YERCAK3 data
|
|
1252
|
+
* Auto-generated by @l4yercak3/cli
|
|
1253
|
+
*/
|
|
1254
|
+
|
|
1255
|
+
'use client';
|
|
1256
|
+
|
|
1257
|
+
${imports.join('\n')}
|
|
1258
|
+
|
|
1259
|
+
export default function DashboardPage() {
|
|
1260
|
+
${hookCalls.join('\n ')}
|
|
1261
|
+
|
|
1262
|
+
return (
|
|
1263
|
+
<div className="container mx-auto px-4 py-8">
|
|
1264
|
+
<h1 className="text-2xl font-bold mb-6">Dashboard</h1>
|
|
1265
|
+
|
|
1266
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
1267
|
+
${cards.join('\n ')}
|
|
1268
|
+
</div>
|
|
1269
|
+
</div>
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
`;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
getDashboardPageJS(features) {
|
|
1276
|
+
const imports = [];
|
|
1277
|
+
const cards = [];
|
|
1278
|
+
|
|
1279
|
+
if (features.includes('crm')) {
|
|
1280
|
+
imports.push("import { useContacts } from '@/lib/l4yercak3/hooks/use-contacts';");
|
|
1281
|
+
cards.push(`
|
|
1282
|
+
{/* Contacts Card */}
|
|
1283
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1284
|
+
<h2 className="text-lg font-semibold mb-2">Contacts</h2>
|
|
1285
|
+
<div className="text-3xl font-bold text-blue-600">
|
|
1286
|
+
{contactsLoading ? '...' : contacts?.length || 0}
|
|
1287
|
+
</div>
|
|
1288
|
+
<p className="text-gray-500 text-sm mt-1">Total contacts</p>
|
|
1289
|
+
<a href="/contacts" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
|
|
1290
|
+
View all →
|
|
1291
|
+
</a>
|
|
1292
|
+
</div>`);
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
if (features.includes('events')) {
|
|
1296
|
+
imports.push("import { useEvents } from '@/lib/l4yercak3/hooks/use-events';");
|
|
1297
|
+
cards.push(`
|
|
1298
|
+
{/* Events Card */}
|
|
1299
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1300
|
+
<h2 className="text-lg font-semibold mb-2">Upcoming Events</h2>
|
|
1301
|
+
<div className="text-3xl font-bold text-green-600">
|
|
1302
|
+
{eventsLoading ? '...' : events?.length || 0}
|
|
1303
|
+
</div>
|
|
1304
|
+
<p className="text-gray-500 text-sm mt-1">Events scheduled</p>
|
|
1305
|
+
<a href="/events" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
|
|
1306
|
+
View all →
|
|
1307
|
+
</a>
|
|
1308
|
+
</div>`);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
if (features.includes('products') || features.includes('checkout')) {
|
|
1312
|
+
imports.push("import { useProducts, useOrders } from '@/lib/l4yercak3/hooks/use-products';");
|
|
1313
|
+
cards.push(`
|
|
1314
|
+
{/* Products Card */}
|
|
1315
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1316
|
+
<h2 className="text-lg font-semibold mb-2">Products</h2>
|
|
1317
|
+
<div className="text-3xl font-bold text-purple-600">
|
|
1318
|
+
{productsLoading ? '...' : products?.length || 0}
|
|
1319
|
+
</div>
|
|
1320
|
+
<p className="text-gray-500 text-sm mt-1">Active products</p>
|
|
1321
|
+
<a href="/products" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
|
|
1322
|
+
View all →
|
|
1323
|
+
</a>
|
|
1324
|
+
</div>`);
|
|
1325
|
+
cards.push(`
|
|
1326
|
+
{/* Orders Card */}
|
|
1327
|
+
<div className="bg-white p-6 rounded-lg border shadow-sm">
|
|
1328
|
+
<h2 className="text-lg font-semibold mb-2">Recent Orders</h2>
|
|
1329
|
+
<div className="text-3xl font-bold text-orange-600">
|
|
1330
|
+
{ordersLoading ? '...' : orders?.length || 0}
|
|
1331
|
+
</div>
|
|
1332
|
+
<p className="text-gray-500 text-sm mt-1">Orders this month</p>
|
|
1333
|
+
</div>`);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
const hookCalls = [];
|
|
1337
|
+
if (features.includes('crm')) {
|
|
1338
|
+
hookCalls.push("const { data: contacts, isLoading: contactsLoading } = useContacts();");
|
|
1339
|
+
}
|
|
1340
|
+
if (features.includes('events')) {
|
|
1341
|
+
hookCalls.push("const { data: events, isLoading: eventsLoading } = useEvents({ status: 'upcoming' });");
|
|
1342
|
+
}
|
|
1343
|
+
if (features.includes('products') || features.includes('checkout')) {
|
|
1344
|
+
hookCalls.push("const { data: products, isLoading: productsLoading } = useProducts();");
|
|
1345
|
+
hookCalls.push("const { data: orders, isLoading: ordersLoading } = useOrders();");
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
return `/**
|
|
1349
|
+
* Dashboard Page
|
|
1350
|
+
* Overview of L4YERCAK3 data
|
|
1351
|
+
* Auto-generated by @l4yercak3/cli
|
|
1352
|
+
*/
|
|
1353
|
+
|
|
1354
|
+
'use client';
|
|
1355
|
+
|
|
1356
|
+
${imports.join('\n')}
|
|
1357
|
+
|
|
1358
|
+
export default function DashboardPage() {
|
|
1359
|
+
${hookCalls.join('\n ')}
|
|
1360
|
+
|
|
1361
|
+
return (
|
|
1362
|
+
<div className="container mx-auto px-4 py-8">
|
|
1363
|
+
<h1 className="text-2xl font-bold mb-6">Dashboard</h1>
|
|
1364
|
+
|
|
1365
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
1366
|
+
${cards.join('\n ')}
|
|
1367
|
+
</div>
|
|
1368
|
+
</div>
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
`;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
async generateProviders(appDir, ext, isTypeScript) {
|
|
1375
|
+
const outputPath = path.join(appDir, `providers.${ext}`);
|
|
1376
|
+
|
|
1377
|
+
const action = await checkFileOverwrite(outputPath);
|
|
1378
|
+
if (action === 'skip') {
|
|
1379
|
+
return null;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
const content = isTypeScript
|
|
1383
|
+
? this.getProvidersTS()
|
|
1384
|
+
: this.getProvidersJS();
|
|
1385
|
+
|
|
1386
|
+
return writeFileWithBackup(outputPath, content, action);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
getProvidersTS() {
|
|
1390
|
+
return `/**
|
|
1391
|
+
* App Providers
|
|
1392
|
+
* Wraps the app with necessary providers (React Query, etc.)
|
|
1393
|
+
* Auto-generated by @l4yercak3/cli
|
|
1394
|
+
*/
|
|
1395
|
+
|
|
1396
|
+
'use client';
|
|
1397
|
+
|
|
1398
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
1399
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
1400
|
+
import { useState, type ReactNode } from 'react';
|
|
1401
|
+
|
|
1402
|
+
interface ProvidersProps {
|
|
1403
|
+
children: ReactNode;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
export function Providers({ children }: ProvidersProps) {
|
|
1407
|
+
const [queryClient] = useState(
|
|
1408
|
+
() =>
|
|
1409
|
+
new QueryClient({
|
|
1410
|
+
defaultOptions: {
|
|
1411
|
+
queries: {
|
|
1412
|
+
staleTime: 60 * 1000, // 1 minute
|
|
1413
|
+
refetchOnWindowFocus: false,
|
|
1414
|
+
},
|
|
1415
|
+
},
|
|
1416
|
+
})
|
|
1417
|
+
);
|
|
1418
|
+
|
|
1419
|
+
return (
|
|
1420
|
+
<QueryClientProvider client={queryClient}>
|
|
1421
|
+
{children}
|
|
1422
|
+
<ReactQueryDevtools initialIsOpen={false} />
|
|
1423
|
+
</QueryClientProvider>
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
`;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
getProvidersJS() {
|
|
1430
|
+
return `/**
|
|
1431
|
+
* App Providers
|
|
1432
|
+
* Wraps the app with necessary providers (React Query, etc.)
|
|
1433
|
+
* Auto-generated by @l4yercak3/cli
|
|
1434
|
+
*/
|
|
1435
|
+
|
|
1436
|
+
'use client';
|
|
1437
|
+
|
|
1438
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
1439
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
1440
|
+
import { useState } from 'react';
|
|
1441
|
+
|
|
1442
|
+
export function Providers({ children }) {
|
|
1443
|
+
const [queryClient] = useState(
|
|
1444
|
+
() =>
|
|
1445
|
+
new QueryClient({
|
|
1446
|
+
defaultOptions: {
|
|
1447
|
+
queries: {
|
|
1448
|
+
staleTime: 60 * 1000, // 1 minute
|
|
1449
|
+
refetchOnWindowFocus: false,
|
|
1450
|
+
},
|
|
1451
|
+
},
|
|
1452
|
+
})
|
|
1453
|
+
);
|
|
1454
|
+
|
|
1455
|
+
return (
|
|
1456
|
+
<QueryClientProvider client={queryClient}>
|
|
1457
|
+
{children}
|
|
1458
|
+
<ReactQueryDevtools initialIsOpen={false} />
|
|
1459
|
+
</QueryClientProvider>
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
`;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
module.exports = new PageGenerator();
|