@digilogiclabs/create-saas-app 1.4.0 → 1.5.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.
- package/CHANGELOG.md +42 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.js +45 -3
- package/dist/index.js.map +1 -1
- package/dist/templates/web/base/template/package.json +20 -10
- package/dist/templates/web/base/template/src/app/error.tsx +97 -0
- package/dist/templates/web/base/template/src/app/layout.tsx +8 -2
- package/dist/templates/web/base/template/src/app/loading.tsx +34 -0
- package/dist/templates/web/base/template/src/components/__tests__/example.test.tsx +49 -0
- package/dist/templates/web/base/template/src/components/providers/app-providers.tsx +6 -2
- package/dist/templates/web/base/template/src/components/providers/theme-provider.tsx +94 -0
- package/dist/templates/web/base/template/src/components/shared/footer.tsx +36 -0
- package/dist/templates/web/base/template/src/components/shared/header.tsx +2 -0
- package/dist/templates/web/base/template/src/components/ui/theme-toggle.tsx +34 -0
- package/dist/templates/web/base/template/src/lib/auth-server.ts +177 -0
- package/dist/templates/web/base/template/src/lib/env.ts +46 -0
- package/dist/templates/web/base/template/src/lib/utils.ts +133 -0
- package/dist/templates/web/base/template/src/test/setup.ts +79 -0
- package/dist/templates/web/base/template/vitest.config.ts +17 -0
- package/dist/templates/web/ui-auth/template/package.json +14 -4
- package/dist/templates/web/ui-auth/template/src/app/error.tsx +67 -0
- package/dist/templates/web/ui-auth/template/src/app/layout.tsx +6 -2
- package/dist/templates/web/ui-auth/template/src/app/loading.tsx +20 -0
- package/dist/templates/web/ui-auth/template/src/components/__tests__/example.test.tsx +49 -0
- package/dist/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +6 -2
- package/dist/templates/web/ui-auth/template/src/components/providers/theme-provider.tsx +94 -0
- package/dist/templates/web/ui-auth/template/src/components/shared/footer.tsx +36 -0
- package/dist/templates/web/ui-auth/template/src/components/shared/header.tsx +2 -0
- package/dist/templates/web/ui-auth/template/src/components/ui/theme-toggle.tsx +34 -0
- package/dist/templates/web/ui-auth/template/src/lib/env.ts +49 -0
- package/dist/templates/web/ui-auth/template/src/lib/utils.ts +133 -0
- package/dist/templates/web/ui-auth/template/src/test/setup.ts +79 -0
- package/dist/templates/web/ui-auth/template/vitest.config.ts +17 -0
- package/dist/templates/web/ui-auth-payments/template/middleware.ts +68 -0
- package/dist/templates/web/ui-auth-payments/template/package.json +14 -4
- package/dist/templates/web/ui-auth-payments/template/src/app/dashboard/layout.tsx +22 -0
- package/dist/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +183 -0
- package/dist/templates/web/ui-auth-payments/template/src/app/error.tsx +67 -0
- package/dist/templates/web/ui-auth-payments/template/src/app/layout.tsx +6 -2
- package/dist/templates/web/ui-auth-payments/template/src/app/loading.tsx +20 -0
- package/dist/templates/web/ui-auth-payments/template/src/app/login/loading.tsx +38 -0
- package/dist/templates/web/ui-auth-payments/template/src/app/signup/loading.tsx +50 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/__tests__/example.test.tsx +49 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/client/auth-status.tsx +52 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +144 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/client/newsletter-signup.tsx +68 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +185 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +6 -2
- package/dist/templates/web/ui-auth-payments/template/src/components/providers/theme-provider.tsx +94 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/shared/footer.tsx +36 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/shared/header.tsx +2 -0
- package/dist/templates/web/ui-auth-payments/template/src/components/ui/theme-toggle.tsx +34 -0
- package/dist/templates/web/ui-auth-payments/template/src/lib/actions/auth.ts +246 -0
- package/dist/templates/web/ui-auth-payments/template/src/lib/actions/index.ts +340 -0
- package/dist/templates/web/ui-auth-payments/template/src/lib/auth-server.ts +177 -0
- package/dist/templates/web/ui-auth-payments/template/src/lib/env.ts +49 -0
- package/dist/templates/web/ui-auth-payments/template/src/lib/utils.ts +133 -0
- package/dist/templates/web/ui-auth-payments/template/src/test/setup.ts +79 -0
- package/dist/templates/web/ui-auth-payments/template/vitest.config.ts +17 -0
- package/dist/templates/web/ui-auth-payments-audio/template/package.json +14 -4
- package/dist/templates/web/ui-auth-payments-audio/template/src/app/error.tsx +67 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/app/layout.tsx +8 -2
- package/dist/templates/web/ui-auth-payments-audio/template/src/app/loading.tsx +20 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/__tests__/example.test.tsx +49 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +6 -2
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/providers/theme-provider.tsx +94 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/shared/footer.tsx +36 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/shared/header.tsx +2 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/ui/theme-toggle.tsx +34 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/lib/env.ts +49 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/lib/utils.ts +133 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/test/setup.ts +79 -0
- package/dist/templates/web/ui-auth-payments-audio/template/vitest.config.ts +17 -0
- package/dist/templates/web/ui-auth-payments-video/template/package.json +14 -4
- package/dist/templates/web/ui-auth-payments-video/template/src/app/error.tsx +67 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/app/layout.tsx +6 -2
- package/dist/templates/web/ui-auth-payments-video/template/src/app/loading.tsx +20 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/components/__tests__/example.test.tsx +49 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +6 -2
- package/dist/templates/web/ui-auth-payments-video/template/src/components/providers/theme-provider.tsx +94 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/components/shared/footer.tsx +36 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/components/shared/header.tsx +2 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/components/ui/theme-toggle.tsx +34 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/lib/env.ts +49 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/lib/utils.ts +133 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/test/setup.ts +79 -0
- package/dist/templates/web/ui-auth-payments-video/template/vitest.config.ts +17 -0
- package/dist/templates/web/ui-only/template/package.json +14 -4
- package/dist/templates/web/ui-only/template/src/app/error.tsx +67 -0
- package/dist/templates/web/ui-only/template/src/app/layout.tsx +6 -2
- package/dist/templates/web/ui-only/template/src/app/loading.tsx +20 -0
- package/dist/templates/web/ui-only/template/src/components/__tests__/example.test.tsx +49 -0
- package/dist/templates/web/ui-only/template/src/components/providers/app-providers.tsx +6 -2
- package/dist/templates/web/ui-only/template/src/components/providers/theme-provider.tsx +94 -0
- package/dist/templates/web/ui-only/template/src/components/shared/footer.tsx +36 -0
- package/dist/templates/web/ui-only/template/src/components/shared/header.tsx +2 -0
- package/dist/templates/web/ui-only/template/src/components/ui/theme-toggle.tsx +34 -0
- package/dist/templates/web/ui-only/template/src/lib/env.ts +49 -0
- package/dist/templates/web/ui-only/template/src/lib/utils.ts +133 -0
- package/dist/templates/web/ui-only/template/src/test/setup.ts +79 -0
- package/dist/templates/web/ui-only/template/vitest.config.ts +17 -0
- package/package.json +1 -1
- package/src/templates/web/base/template/package.json +20 -10
- package/src/templates/web/base/template/src/app/error.tsx +97 -0
- package/src/templates/web/base/template/src/app/layout.tsx +8 -2
- package/src/templates/web/base/template/src/app/loading.tsx +34 -0
- package/src/templates/web/base/template/src/components/__tests__/example.test.tsx +49 -0
- package/src/templates/web/base/template/src/components/providers/app-providers.tsx +6 -2
- package/src/templates/web/base/template/src/components/providers/theme-provider.tsx +94 -0
- package/src/templates/web/base/template/src/components/shared/footer.tsx +36 -0
- package/src/templates/web/base/template/src/components/shared/header.tsx +2 -0
- package/src/templates/web/base/template/src/components/ui/theme-toggle.tsx +34 -0
- package/src/templates/web/base/template/src/lib/auth-server.ts +177 -0
- package/src/templates/web/base/template/src/lib/env.ts +46 -0
- package/src/templates/web/base/template/src/lib/utils.ts +133 -0
- package/src/templates/web/base/template/src/test/setup.ts +79 -0
- package/src/templates/web/base/template/vitest.config.ts +17 -0
- package/src/templates/web/ui-auth/template/package.json +14 -4
- package/src/templates/web/ui-auth/template/src/app/error.tsx +67 -0
- package/src/templates/web/ui-auth/template/src/app/layout.tsx +6 -2
- package/src/templates/web/ui-auth/template/src/app/loading.tsx +20 -0
- package/src/templates/web/ui-auth/template/src/components/__tests__/example.test.tsx +49 -0
- package/src/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +6 -2
- package/src/templates/web/ui-auth/template/src/components/providers/theme-provider.tsx +94 -0
- package/src/templates/web/ui-auth/template/src/components/shared/footer.tsx +36 -0
- package/src/templates/web/ui-auth/template/src/components/shared/header.tsx +2 -0
- package/src/templates/web/ui-auth/template/src/components/ui/theme-toggle.tsx +34 -0
- package/src/templates/web/ui-auth/template/src/lib/env.ts +49 -0
- package/src/templates/web/ui-auth/template/src/lib/utils.ts +133 -0
- package/src/templates/web/ui-auth/template/src/test/setup.ts +79 -0
- package/src/templates/web/ui-auth/template/vitest.config.ts +17 -0
- package/src/templates/web/ui-auth-payments/template/middleware.ts +68 -0
- package/src/templates/web/ui-auth-payments/template/package.json +14 -4
- package/src/templates/web/ui-auth-payments/template/src/app/dashboard/layout.tsx +22 -0
- package/src/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +183 -0
- package/src/templates/web/ui-auth-payments/template/src/app/error.tsx +67 -0
- package/src/templates/web/ui-auth-payments/template/src/app/layout.tsx +6 -2
- package/src/templates/web/ui-auth-payments/template/src/app/loading.tsx +20 -0
- package/src/templates/web/ui-auth-payments/template/src/app/login/loading.tsx +38 -0
- package/src/templates/web/ui-auth-payments/template/src/app/signup/loading.tsx +50 -0
- package/src/templates/web/ui-auth-payments/template/src/components/__tests__/example.test.tsx +49 -0
- package/src/templates/web/ui-auth-payments/template/src/components/client/auth-status.tsx +52 -0
- package/src/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +144 -0
- package/src/templates/web/ui-auth-payments/template/src/components/client/newsletter-signup.tsx +68 -0
- package/src/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +185 -0
- package/src/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +6 -2
- package/src/templates/web/ui-auth-payments/template/src/components/providers/theme-provider.tsx +94 -0
- package/src/templates/web/ui-auth-payments/template/src/components/shared/footer.tsx +36 -0
- package/src/templates/web/ui-auth-payments/template/src/components/shared/header.tsx +2 -0
- package/src/templates/web/ui-auth-payments/template/src/components/ui/theme-toggle.tsx +34 -0
- package/src/templates/web/ui-auth-payments/template/src/lib/actions/auth.ts +246 -0
- package/src/templates/web/ui-auth-payments/template/src/lib/actions/index.ts +340 -0
- package/src/templates/web/ui-auth-payments/template/src/lib/auth-server.ts +177 -0
- package/src/templates/web/ui-auth-payments/template/src/lib/env.ts +49 -0
- package/src/templates/web/ui-auth-payments/template/src/lib/utils.ts +133 -0
- package/src/templates/web/ui-auth-payments/template/src/test/setup.ts +79 -0
- package/src/templates/web/ui-auth-payments/template/vitest.config.ts +17 -0
- package/src/templates/web/ui-auth-payments-audio/template/package.json +14 -4
- package/src/templates/web/ui-auth-payments-audio/template/src/app/error.tsx +67 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/app/layout.tsx +8 -2
- package/src/templates/web/ui-auth-payments-audio/template/src/app/loading.tsx +20 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/components/__tests__/example.test.tsx +49 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +6 -2
- package/src/templates/web/ui-auth-payments-audio/template/src/components/providers/theme-provider.tsx +94 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/components/shared/footer.tsx +36 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/components/shared/header.tsx +2 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/components/ui/theme-toggle.tsx +34 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/lib/env.ts +49 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/lib/utils.ts +133 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/test/setup.ts +79 -0
- package/src/templates/web/ui-auth-payments-audio/template/vitest.config.ts +17 -0
- package/src/templates/web/ui-auth-payments-video/template/package.json +14 -4
- package/src/templates/web/ui-auth-payments-video/template/src/app/error.tsx +67 -0
- package/src/templates/web/ui-auth-payments-video/template/src/app/layout.tsx +6 -2
- package/src/templates/web/ui-auth-payments-video/template/src/app/loading.tsx +20 -0
- package/src/templates/web/ui-auth-payments-video/template/src/components/__tests__/example.test.tsx +49 -0
- package/src/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +6 -2
- package/src/templates/web/ui-auth-payments-video/template/src/components/providers/theme-provider.tsx +94 -0
- package/src/templates/web/ui-auth-payments-video/template/src/components/shared/footer.tsx +36 -0
- package/src/templates/web/ui-auth-payments-video/template/src/components/shared/header.tsx +2 -0
- package/src/templates/web/ui-auth-payments-video/template/src/components/ui/theme-toggle.tsx +34 -0
- package/src/templates/web/ui-auth-payments-video/template/src/lib/env.ts +49 -0
- package/src/templates/web/ui-auth-payments-video/template/src/lib/utils.ts +133 -0
- package/src/templates/web/ui-auth-payments-video/template/src/test/setup.ts +79 -0
- package/src/templates/web/ui-auth-payments-video/template/vitest.config.ts +17 -0
- package/src/templates/web/ui-only/template/package.json +14 -4
- package/src/templates/web/ui-only/template/src/app/error.tsx +67 -0
- package/src/templates/web/ui-only/template/src/app/layout.tsx +6 -2
- package/src/templates/web/ui-only/template/src/app/loading.tsx +20 -0
- package/src/templates/web/ui-only/template/src/components/__tests__/example.test.tsx +49 -0
- package/src/templates/web/ui-only/template/src/components/providers/app-providers.tsx +6 -2
- package/src/templates/web/ui-only/template/src/components/providers/theme-provider.tsx +94 -0
- package/src/templates/web/ui-only/template/src/components/shared/footer.tsx +36 -0
- package/src/templates/web/ui-only/template/src/components/shared/header.tsx +2 -0
- package/src/templates/web/ui-only/template/src/components/ui/theme-toggle.tsx +34 -0
- package/src/templates/web/ui-only/template/src/lib/env.ts +49 -0
- package/src/templates/web/ui-only/template/src/lib/utils.ts +133 -0
- package/src/templates/web/ui-only/template/src/test/setup.ts +79 -0
- package/src/templates/web/ui-only/template/vitest.config.ts +17 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional Environment Configuration with Zod validation
|
|
3
|
+
*
|
|
4
|
+
* This provides type-safe environment variable validation.
|
|
5
|
+
* Usage is optional - existing templates will continue to work without this.
|
|
6
|
+
*
|
|
7
|
+
* To use: import { env } from '@/lib/env' instead of process.env
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { z } from 'zod'
|
|
11
|
+
|
|
12
|
+
const envSchema = z.object({
|
|
13
|
+
// Next.js built-in
|
|
14
|
+
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
|
15
|
+
|
|
16
|
+
// App configuration
|
|
17
|
+
NEXT_PUBLIC_APP_URL: z.string().url().optional(),
|
|
18
|
+
NEXT_PUBLIC_APP_NAME: z.string().default('{{titleCaseName}}'),
|
|
19
|
+
|
|
20
|
+
// Auth configuration (if using server-side auth)
|
|
21
|
+
SUPABASE_URL: z.string().url().optional(),
|
|
22
|
+
SUPABASE_ANON_KEY: z.string().optional(),
|
|
23
|
+
SUPABASE_SERVICE_ROLE_KEY: z.string().optional(),
|
|
24
|
+
|
|
25
|
+
// Payment configuration
|
|
26
|
+
STRIPE_SECRET_KEY: z.string().optional(),
|
|
27
|
+
STRIPE_WEBHOOK_SECRET: z.string().optional(),
|
|
28
|
+
|
|
29
|
+
// Optional analytics
|
|
30
|
+
ANALYTICS_ID: z.string().optional(),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
// Parse with fallback to process.env for backward compatibility
|
|
34
|
+
function parseEnv() {
|
|
35
|
+
try {
|
|
36
|
+
return envSchema.parse(process.env)
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (process.env.NODE_ENV === 'development') {
|
|
39
|
+
console.warn('Environment validation failed. Using process.env fallback:', error)
|
|
40
|
+
}
|
|
41
|
+
// Fallback to process.env for backward compatibility
|
|
42
|
+
return process.env as any
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const env = parseEnv()
|
|
47
|
+
|
|
48
|
+
// Type helper for environment variables
|
|
49
|
+
export type Env = z.infer<typeof envSchema>
|
|
@@ -1,7 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced utility functions for {{titleCaseName}}
|
|
3
|
+
*
|
|
4
|
+
* This extends the basic utils with additional functionality while
|
|
5
|
+
* maintaining compatibility with existing templates.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { type ClassValue, clsx } from "clsx"
|
|
2
9
|
import { twMerge } from "tailwind-merge"
|
|
3
10
|
|
|
11
|
+
// Core utility function (keeps existing functionality)
|
|
4
12
|
export function cn(...inputs: ClassValue[]) {
|
|
5
13
|
return twMerge(clsx(inputs))
|
|
6
14
|
}
|
|
7
15
|
|
|
16
|
+
// Additional utilities for enhanced templates
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Format currency with proper locale support
|
|
20
|
+
*/
|
|
21
|
+
export function formatCurrency(
|
|
22
|
+
amount: number,
|
|
23
|
+
currency: string = 'USD',
|
|
24
|
+
locale: string = 'en-US'
|
|
25
|
+
): string {
|
|
26
|
+
return new Intl.NumberFormat(locale, {
|
|
27
|
+
style: 'currency',
|
|
28
|
+
currency,
|
|
29
|
+
}).format(amount)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Format date with relative time support
|
|
34
|
+
*/
|
|
35
|
+
export function formatDate(
|
|
36
|
+
date: Date | string,
|
|
37
|
+
options?: Intl.DateTimeFormatOptions
|
|
38
|
+
): string {
|
|
39
|
+
const dateObj = typeof date === 'string' ? new Date(date) : date
|
|
40
|
+
|
|
41
|
+
const defaultOptions: Intl.DateTimeFormatOptions = {
|
|
42
|
+
year: 'numeric',
|
|
43
|
+
month: 'short',
|
|
44
|
+
day: 'numeric',
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return new Intl.DateTimeFormat('en-US', options || defaultOptions).format(dateObj)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get relative time string (e.g., "2 hours ago")
|
|
52
|
+
*/
|
|
53
|
+
export function getRelativeTime(date: Date | string): string {
|
|
54
|
+
const dateObj = typeof date === 'string' ? new Date(date) : date
|
|
55
|
+
const now = new Date()
|
|
56
|
+
const diffInMs = now.getTime() - dateObj.getTime()
|
|
57
|
+
const diffInSeconds = Math.floor(diffInMs / 1000)
|
|
58
|
+
const diffInMinutes = Math.floor(diffInSeconds / 60)
|
|
59
|
+
const diffInHours = Math.floor(diffInMinutes / 60)
|
|
60
|
+
const diffInDays = Math.floor(diffInHours / 24)
|
|
61
|
+
|
|
62
|
+
if (diffInSeconds < 60) return 'just now'
|
|
63
|
+
if (diffInMinutes < 60) return `${diffInMinutes} minute${diffInMinutes > 1 ? 's' : ''} ago`
|
|
64
|
+
if (diffInHours < 24) return `${diffInHours} hour${diffInHours > 1 ? 's' : ''} ago`
|
|
65
|
+
if (diffInDays < 7) return `${diffInDays} day${diffInDays > 1 ? 's' : ''} ago`
|
|
66
|
+
|
|
67
|
+
return formatDate(dateObj)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Truncate text to specified length with ellipsis
|
|
72
|
+
*/
|
|
73
|
+
export function truncate(text: string, length: number = 50): string {
|
|
74
|
+
if (text.length <= length) return text
|
|
75
|
+
return text.slice(0, length).trim() + '...'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generate initials from a name
|
|
80
|
+
*/
|
|
81
|
+
export function getInitials(name: string): string {
|
|
82
|
+
return name
|
|
83
|
+
.split(' ')
|
|
84
|
+
.map(word => word.charAt(0).toUpperCase())
|
|
85
|
+
.slice(0, 2)
|
|
86
|
+
.join('')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Validate email format
|
|
91
|
+
*/
|
|
92
|
+
export function isValidEmail(email: string): boolean {
|
|
93
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
|
94
|
+
return emailRegex.test(email)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Generate a random ID
|
|
99
|
+
*/
|
|
100
|
+
export function generateId(prefix: string = ''): string {
|
|
101
|
+
const timestamp = Date.now().toString(36)
|
|
102
|
+
const randomString = Math.random().toString(36).substring(2)
|
|
103
|
+
return prefix ? `${prefix}-${timestamp}-${randomString}` : `${timestamp}-${randomString}`
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Debounce function
|
|
108
|
+
*/
|
|
109
|
+
export function debounce<T extends (...args: any[]) => any>(
|
|
110
|
+
func: T,
|
|
111
|
+
delay: number
|
|
112
|
+
): (...args: Parameters<T>) => void {
|
|
113
|
+
let timeoutId: NodeJS.Timeout | null = null
|
|
114
|
+
|
|
115
|
+
return (...args: Parameters<T>) => {
|
|
116
|
+
if (timeoutId !== null) {
|
|
117
|
+
clearTimeout(timeoutId)
|
|
118
|
+
}
|
|
119
|
+
timeoutId = setTimeout(() => func(...args), delay)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Sleep/delay function for async operations
|
|
125
|
+
*/
|
|
126
|
+
export function sleep(ms: number): Promise<void> {
|
|
127
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Safe JSON parse with fallback
|
|
132
|
+
*/
|
|
133
|
+
export function safeJsonParse<T>(json: string, fallback: T): T {
|
|
134
|
+
try {
|
|
135
|
+
return JSON.parse(json)
|
|
136
|
+
} catch {
|
|
137
|
+
return fallback
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
import { vi } from 'vitest'
|
|
3
|
+
|
|
4
|
+
// Mock Next.js router
|
|
5
|
+
vi.mock('next/navigation', () => ({
|
|
6
|
+
useRouter: () => ({
|
|
7
|
+
push: vi.fn(),
|
|
8
|
+
back: vi.fn(),
|
|
9
|
+
forward: vi.fn(),
|
|
10
|
+
refresh: vi.fn(),
|
|
11
|
+
replace: vi.fn(),
|
|
12
|
+
prefetch: vi.fn(),
|
|
13
|
+
}),
|
|
14
|
+
useSearchParams: () => new URLSearchParams(),
|
|
15
|
+
usePathname: () => '/',
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
// Mock SaaS Factory Auth (optional - only if testing auth components)
|
|
19
|
+
vi.mock('@digilogiclabs/saas-factory-auth', () => ({
|
|
20
|
+
useAuth: () => ({
|
|
21
|
+
user: null,
|
|
22
|
+
loading: false,
|
|
23
|
+
error: null,
|
|
24
|
+
signIn: vi.fn(),
|
|
25
|
+
signUp: vi.fn(),
|
|
26
|
+
signOut: vi.fn(),
|
|
27
|
+
signInWithOAuth: vi.fn(),
|
|
28
|
+
}),
|
|
29
|
+
AuthProvider: ({ children }: { children: React.ReactNode }) => children,
|
|
30
|
+
}))
|
|
31
|
+
|
|
32
|
+
// Mock SaaS Factory Payments (optional - only if testing payment components)
|
|
33
|
+
vi.mock('@digilogiclabs/saas-factory-payments', () => ({
|
|
34
|
+
usePayments: () => ({
|
|
35
|
+
createCheckoutSession: vi.fn(),
|
|
36
|
+
createPortalSession: vi.fn(),
|
|
37
|
+
subscription: null,
|
|
38
|
+
loading: false,
|
|
39
|
+
}),
|
|
40
|
+
PaymentsProvider: ({ children }: { children: React.ReactNode }) => children,
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
// Global test utilities
|
|
44
|
+
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
45
|
+
observe: vi.fn(),
|
|
46
|
+
unobserve: vi.fn(),
|
|
47
|
+
disconnect: vi.fn(),
|
|
48
|
+
}))
|
|
49
|
+
|
|
50
|
+
// Suppress console warnings in tests unless needed
|
|
51
|
+
const originalConsoleError = console.error
|
|
52
|
+
const originalConsoleWarn = console.warn
|
|
53
|
+
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
console.error = (...args: any[]) => {
|
|
56
|
+
if (
|
|
57
|
+
typeof args[0] === 'string' &&
|
|
58
|
+
args[0].includes('Warning: ReactDOM.render is no longer supported')
|
|
59
|
+
) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
originalConsoleError.call(console, ...args)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.warn = (...args: any[]) => {
|
|
66
|
+
if (
|
|
67
|
+
typeof args[0] === 'string' &&
|
|
68
|
+
args[0].includes('useLayoutEffect does nothing on the server')
|
|
69
|
+
) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
originalConsoleWarn.call(console, ...args)
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
afterAll(() => {
|
|
77
|
+
console.error = originalConsoleError
|
|
78
|
+
console.warn = originalConsoleWarn
|
|
79
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
test: {
|
|
8
|
+
environment: 'jsdom',
|
|
9
|
+
setupFiles: ['./src/test/setup.ts'],
|
|
10
|
+
globals: true,
|
|
11
|
+
},
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
'@': path.resolve(__dirname, './src'),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server'
|
|
2
|
+
import { env } from './src/lib/env'
|
|
3
|
+
|
|
4
|
+
export async function middleware(request: NextRequest) {
|
|
5
|
+
// Get auth token from cookies
|
|
6
|
+
const authToken = request.cookies.get('saas-factory-auth-token')?.value
|
|
7
|
+
const user = request.cookies.get('saas-factory-auth-user')?.value
|
|
8
|
+
|
|
9
|
+
const isAuthenticated = !!(authToken && user)
|
|
10
|
+
const { pathname } = request.nextUrl
|
|
11
|
+
|
|
12
|
+
// Define protected routes
|
|
13
|
+
const protectedRoutes = ['/dashboard', '/profile', '/settings']
|
|
14
|
+
const authRoutes = ['/login', '/signup']
|
|
15
|
+
|
|
16
|
+
// Check if the current path is protected
|
|
17
|
+
const isProtectedRoute = protectedRoutes.some(route =>
|
|
18
|
+
pathname.startsWith(route)
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// Check if the current path is an auth route
|
|
22
|
+
const isAuthRoute = authRoutes.some(route =>
|
|
23
|
+
pathname.startsWith(route)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
// Redirect unauthenticated users from protected routes
|
|
27
|
+
if (isProtectedRoute && !isAuthenticated) {
|
|
28
|
+
const loginUrl = new URL('/login', request.url)
|
|
29
|
+
loginUrl.searchParams.set('from', pathname)
|
|
30
|
+
return NextResponse.redirect(loginUrl)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Redirect authenticated users from auth routes
|
|
34
|
+
if (isAuthRoute && isAuthenticated) {
|
|
35
|
+
const redirectUrl = request.nextUrl.searchParams.get('from') || '/'
|
|
36
|
+
return NextResponse.redirect(new URL(redirectUrl, request.url))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Add security headers
|
|
40
|
+
const response = NextResponse.next()
|
|
41
|
+
|
|
42
|
+
// Add CSRF protection headers
|
|
43
|
+
response.headers.set('X-Frame-Options', 'DENY')
|
|
44
|
+
response.headers.set('X-Content-Type-Options', 'nosniff')
|
|
45
|
+
response.headers.set('Referrer-Policy', 'origin-when-cross-origin')
|
|
46
|
+
|
|
47
|
+
// Add CSP header for additional security
|
|
48
|
+
if (env.NODE_ENV === 'production') {
|
|
49
|
+
response.headers.set(
|
|
50
|
+
'Content-Security-Policy',
|
|
51
|
+
"default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://js.stripe.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' https://api.stripe.com"
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return response
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const config = {
|
|
59
|
+
matcher: [
|
|
60
|
+
// Match all request paths except for the ones starting with:
|
|
61
|
+
// - api (API routes)
|
|
62
|
+
// - _next/static (static files)
|
|
63
|
+
// - _next/image (image optimization files)
|
|
64
|
+
// - favicon.ico (favicon file)
|
|
65
|
+
// - public folder files
|
|
66
|
+
'/((?!api|_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
|
|
67
|
+
],
|
|
68
|
+
}
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
"description": "{{description}} (with UI Package v0.11.1 + Auth v1.0.0 + Payments)",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "next dev",
|
|
7
|
+
"dev": "next dev --turbo",
|
|
8
8
|
"build": "next build",
|
|
9
9
|
"start": "next start",
|
|
10
10
|
"lint": "next lint",
|
|
11
|
-
"type-check": "tsc --noEmit"
|
|
11
|
+
"type-check": "tsc --noEmit",
|
|
12
|
+
"test": "vitest",
|
|
13
|
+
"test:ui": "vitest --ui",
|
|
14
|
+
"test:run": "vitest run"
|
|
12
15
|
},
|
|
13
16
|
"dependencies": {
|
|
14
17
|
"next": "^15.0.0",
|
|
@@ -25,7 +28,8 @@
|
|
|
25
28
|
"class-variance-authority": "^0.7.0",
|
|
26
29
|
"tailwind-merge": "^2.0.0",
|
|
27
30
|
"next-themes": "^0.2.1",
|
|
28
|
-
"lucide-react": "^0.542.0"
|
|
31
|
+
"lucide-react": "^0.542.0",
|
|
32
|
+
"zod": "^3.22.4"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
31
35
|
"typescript": "^5.0.0",
|
|
@@ -34,7 +38,13 @@
|
|
|
34
38
|
"@types/react-dom": "^19.0.0",
|
|
35
39
|
"eslint": "^8.0.0",
|
|
36
40
|
"eslint-config-next": "^15.0.0",
|
|
37
|
-
"prettier": "^3.0.0"
|
|
41
|
+
"prettier": "^3.0.0",
|
|
42
|
+
"vitest": "^1.0.0",
|
|
43
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
44
|
+
"@testing-library/react": "^14.0.0",
|
|
45
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
46
|
+
"@testing-library/user-event": "^14.0.0",
|
|
47
|
+
"jsdom": "^24.0.0"
|
|
38
48
|
},
|
|
39
49
|
"engines": {
|
|
40
50
|
"node": ">=18.0.0"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { requireAuth } from '@/lib/auth-server'
|
|
2
|
+
import { redirect } from 'next/navigation'
|
|
3
|
+
|
|
4
|
+
export default async function DashboardLayout({
|
|
5
|
+
children,
|
|
6
|
+
}: {
|
|
7
|
+
children: React.ReactNode
|
|
8
|
+
}) {
|
|
9
|
+
// Ensure user is authenticated at the layout level
|
|
10
|
+
try {
|
|
11
|
+
await requireAuth()
|
|
12
|
+
} catch (error) {
|
|
13
|
+
// This will happen if requireAuth redirects, but just in case
|
|
14
|
+
redirect('/login')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="dashboard-layout">
|
|
19
|
+
{children}
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { Suspense } from 'react'
|
|
2
|
+
import { Button, Card } from '@digilogiclabs/saas-factory-ui'
|
|
3
|
+
import { User, Settings, CreditCard, Activity } from 'lucide-react'
|
|
4
|
+
import { requireAuth } from '@/lib/auth-server'
|
|
5
|
+
import Link from 'next/link'
|
|
6
|
+
|
|
7
|
+
// Example of server component data fetching
|
|
8
|
+
async function getUserStats(userId: string) {
|
|
9
|
+
// Simulate API call
|
|
10
|
+
await new Promise(resolve => setTimeout(resolve, 100))
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
totalPosts: 42,
|
|
14
|
+
totalViews: 1337,
|
|
15
|
+
totalLikes: 256,
|
|
16
|
+
joinedDate: '2024-01-15'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function StatsCard({ title, value, icon: Icon, href }: {
|
|
21
|
+
title: string
|
|
22
|
+
value: string | number
|
|
23
|
+
icon: React.ComponentType<any>
|
|
24
|
+
href?: string
|
|
25
|
+
}) {
|
|
26
|
+
const content = (
|
|
27
|
+
<Card className="p-6 hover:shadow-lg transition-shadow">
|
|
28
|
+
<div className="flex items-center justify-between">
|
|
29
|
+
<div>
|
|
30
|
+
<p className="text-sm font-medium text-gray-600 dark:text-gray-400">{title}</p>
|
|
31
|
+
<p className="text-2xl font-bold text-gray-900 dark:text-white">{value}</p>
|
|
32
|
+
</div>
|
|
33
|
+
<Icon className="h-8 w-8 text-blue-600 dark:text-blue-400" />
|
|
34
|
+
</div>
|
|
35
|
+
</Card>
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if (href) {
|
|
39
|
+
return <Link href={href}>{content}</Link>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return content
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function UserStats({ userId }: { userId: string }) {
|
|
46
|
+
const stats = await getUserStats(userId)
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
|
50
|
+
<StatsCard
|
|
51
|
+
title="Total Posts"
|
|
52
|
+
value={stats.totalPosts}
|
|
53
|
+
icon={Activity}
|
|
54
|
+
/>
|
|
55
|
+
<StatsCard
|
|
56
|
+
title="Total Views"
|
|
57
|
+
value={stats.totalViews.toLocaleString()}
|
|
58
|
+
icon={Activity}
|
|
59
|
+
/>
|
|
60
|
+
<StatsCard
|
|
61
|
+
title="Total Likes"
|
|
62
|
+
value={stats.totalLikes}
|
|
63
|
+
icon={Activity}
|
|
64
|
+
/>
|
|
65
|
+
<StatsCard
|
|
66
|
+
title="Member Since"
|
|
67
|
+
value={new Date(stats.joinedDate).getFullYear()}
|
|
68
|
+
icon={User}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function UserStatsSkeleton() {
|
|
75
|
+
return (
|
|
76
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
|
77
|
+
{[...Array(4)].map((_, i) => (
|
|
78
|
+
<Card key={i} className="p-6">
|
|
79
|
+
<div className="animate-pulse">
|
|
80
|
+
<div className="h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/2 mb-2"></div>
|
|
81
|
+
<div className="h-8 bg-gray-200 dark:bg-gray-700 rounded w-1/3"></div>
|
|
82
|
+
</div>
|
|
83
|
+
</Card>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default async function DashboardPage() {
|
|
90
|
+
// Server-side authentication requirement
|
|
91
|
+
const user = await requireAuth()
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className="min-h-screen bg-gray-50 dark:bg-gray-900">
|
|
95
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
96
|
+
{/* Header */}
|
|
97
|
+
<div className="mb-8">
|
|
98
|
+
<h1 className="text-3xl font-bold text-gray-900 dark:text-white">
|
|
99
|
+
Welcome back, {user.name || user.email}!
|
|
100
|
+
</h1>
|
|
101
|
+
<p className="text-gray-600 dark:text-gray-300 mt-2">
|
|
102
|
+
Here's what's happening with your account today.
|
|
103
|
+
</p>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
{/* Stats - Streaming with Suspense */}
|
|
107
|
+
<Suspense fallback={<UserStatsSkeleton />}>
|
|
108
|
+
<UserStats userId={user.id} />
|
|
109
|
+
</Suspense>
|
|
110
|
+
|
|
111
|
+
{/* Quick Actions */}
|
|
112
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
|
|
113
|
+
<Card className="p-6">
|
|
114
|
+
<div className="flex items-center mb-4">
|
|
115
|
+
<User className="h-6 w-6 text-blue-600 dark:text-blue-400 mr-3" />
|
|
116
|
+
<h3 className="text-lg font-semibold text-gray-900 dark:text-white">Profile</h3>
|
|
117
|
+
</div>
|
|
118
|
+
<p className="text-gray-600 dark:text-gray-300 mb-4">
|
|
119
|
+
Update your personal information and preferences
|
|
120
|
+
</p>
|
|
121
|
+
<Link href="/profile">
|
|
122
|
+
<Button className="w-full">Manage Profile</Button>
|
|
123
|
+
</Link>
|
|
124
|
+
</Card>
|
|
125
|
+
|
|
126
|
+
<Card className="p-6">
|
|
127
|
+
<div className="flex items-center mb-4">
|
|
128
|
+
<Settings className="h-6 w-6 text-blue-600 dark:text-blue-400 mr-3" />
|
|
129
|
+
<h3 className="text-lg font-semibold text-gray-900 dark:text-white">Settings</h3>
|
|
130
|
+
</div>
|
|
131
|
+
<p className="text-gray-600 dark:text-gray-300 mb-4">
|
|
132
|
+
Configure your account settings and security options
|
|
133
|
+
</p>
|
|
134
|
+
<Link href="/settings">
|
|
135
|
+
<Button variant="outline" className="w-full">Open Settings</Button>
|
|
136
|
+
</Link>
|
|
137
|
+
</Card>
|
|
138
|
+
|
|
139
|
+
<Card className="p-6">
|
|
140
|
+
<div className="flex items-center mb-4">
|
|
141
|
+
<CreditCard className="h-6 w-6 text-blue-600 dark:text-blue-400 mr-3" />
|
|
142
|
+
<h3 className="text-lg font-semibold text-gray-900 dark:text-white">Billing</h3>
|
|
143
|
+
</div>
|
|
144
|
+
<p className="text-gray-600 dark:text-gray-300 mb-4">
|
|
145
|
+
View your subscription and payment information
|
|
146
|
+
</p>
|
|
147
|
+
<Link href="/billing">
|
|
148
|
+
<Button variant="outline" className="w-full">View Billing</Button>
|
|
149
|
+
</Link>
|
|
150
|
+
</Card>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
{/* Recent Activity */}
|
|
154
|
+
<Card className="p-6">
|
|
155
|
+
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-4">Recent Activity</h3>
|
|
156
|
+
<div className="space-y-4">
|
|
157
|
+
<div className="flex items-center justify-between py-3 border-b border-gray-200 dark:border-gray-700">
|
|
158
|
+
<div className="flex items-center">
|
|
159
|
+
<div className="w-2 h-2 bg-green-500 rounded-full mr-3"></div>
|
|
160
|
+
<span className="text-gray-900 dark:text-white">Account created</span>
|
|
161
|
+
</div>
|
|
162
|
+
<span className="text-sm text-gray-500 dark:text-gray-400">2 days ago</span>
|
|
163
|
+
</div>
|
|
164
|
+
<div className="flex items-center justify-between py-3 border-b border-gray-200 dark:border-gray-700">
|
|
165
|
+
<div className="flex items-center">
|
|
166
|
+
<div className="w-2 h-2 bg-blue-500 rounded-full mr-3"></div>
|
|
167
|
+
<span className="text-gray-900 dark:text-white">Profile updated</span>
|
|
168
|
+
</div>
|
|
169
|
+
<span className="text-sm text-gray-500 dark:text-gray-400">1 week ago</span>
|
|
170
|
+
</div>
|
|
171
|
+
<div className="flex items-center justify-between py-3">
|
|
172
|
+
<div className="flex items-center">
|
|
173
|
+
<div className="w-2 h-2 bg-purple-500 rounded-full mr-3"></div>
|
|
174
|
+
<span className="text-gray-900 dark:text-white">Subscription started</span>
|
|
175
|
+
</div>
|
|
176
|
+
<span className="text-sm text-gray-500 dark:text-gray-400">2 weeks ago</span>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</Card>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
|
+
import { Button, Card } from '@digilogiclabs/saas-factory-ui'
|
|
5
|
+
import { RefreshCw, Home, AlertCircle } from 'lucide-react'
|
|
6
|
+
|
|
7
|
+
interface ErrorProps {
|
|
8
|
+
error: Error & { digest?: string }
|
|
9
|
+
reset: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function Error({ error, reset }: ErrorProps) {
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
// Log the error to an error reporting service
|
|
15
|
+
console.error('Application error:', error)
|
|
16
|
+
}, [error])
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="min-h-screen bg-gray-50 dark:bg-gray-900 flex items-center justify-center p-4">
|
|
20
|
+
<Card className="w-full max-w-md p-8 text-center">
|
|
21
|
+
<div className="mb-6">
|
|
22
|
+
<div className="mx-auto w-16 h-16 bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center mb-4">
|
|
23
|
+
<AlertCircle className="h-8 w-8 text-red-600 dark:text-red-400" />
|
|
24
|
+
</div>
|
|
25
|
+
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-2">
|
|
26
|
+
Something went wrong
|
|
27
|
+
</h1>
|
|
28
|
+
<p className="text-gray-600 dark:text-gray-300 mb-6">
|
|
29
|
+
We apologize for the inconvenience. Please try again or return to the home page.
|
|
30
|
+
</p>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div className="space-y-3">
|
|
34
|
+
<Button
|
|
35
|
+
onClick={reset}
|
|
36
|
+
className="w-full"
|
|
37
|
+
variant="default"
|
|
38
|
+
>
|
|
39
|
+
<RefreshCw className="w-4 h-4 mr-2" />
|
|
40
|
+
Try Again
|
|
41
|
+
</Button>
|
|
42
|
+
|
|
43
|
+
<Button
|
|
44
|
+
onClick={() => window.location.href = '/'}
|
|
45
|
+
variant="outline"
|
|
46
|
+
className="w-full"
|
|
47
|
+
>
|
|
48
|
+
<Home className="w-4 h-4 mr-2" />
|
|
49
|
+
Go Home
|
|
50
|
+
</Button>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
{process.env.NODE_ENV === 'development' && (
|
|
54
|
+
<details className="mt-6 text-left">
|
|
55
|
+
<summary className="text-sm font-medium text-gray-500 cursor-pointer hover:text-gray-700 dark:hover:text-gray-300">
|
|
56
|
+
Error Details (Development)
|
|
57
|
+
</summary>
|
|
58
|
+
<pre className="mt-2 text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded-md overflow-auto">
|
|
59
|
+
{error.message}
|
|
60
|
+
{error.stack}
|
|
61
|
+
</pre>
|
|
62
|
+
</details>
|
|
63
|
+
)}
|
|
64
|
+
</Card>
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|