@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.
Files changed (199) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/index.js +45 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/templates/web/base/template/package.json +20 -10
  6. package/dist/templates/web/base/template/src/app/error.tsx +97 -0
  7. package/dist/templates/web/base/template/src/app/layout.tsx +8 -2
  8. package/dist/templates/web/base/template/src/app/loading.tsx +34 -0
  9. package/dist/templates/web/base/template/src/components/__tests__/example.test.tsx +49 -0
  10. package/dist/templates/web/base/template/src/components/providers/app-providers.tsx +6 -2
  11. package/dist/templates/web/base/template/src/components/providers/theme-provider.tsx +94 -0
  12. package/dist/templates/web/base/template/src/components/shared/footer.tsx +36 -0
  13. package/dist/templates/web/base/template/src/components/shared/header.tsx +2 -0
  14. package/dist/templates/web/base/template/src/components/ui/theme-toggle.tsx +34 -0
  15. package/dist/templates/web/base/template/src/lib/auth-server.ts +177 -0
  16. package/dist/templates/web/base/template/src/lib/env.ts +46 -0
  17. package/dist/templates/web/base/template/src/lib/utils.ts +133 -0
  18. package/dist/templates/web/base/template/src/test/setup.ts +79 -0
  19. package/dist/templates/web/base/template/vitest.config.ts +17 -0
  20. package/dist/templates/web/ui-auth/template/package.json +14 -4
  21. package/dist/templates/web/ui-auth/template/src/app/error.tsx +67 -0
  22. package/dist/templates/web/ui-auth/template/src/app/layout.tsx +6 -2
  23. package/dist/templates/web/ui-auth/template/src/app/loading.tsx +20 -0
  24. package/dist/templates/web/ui-auth/template/src/components/__tests__/example.test.tsx +49 -0
  25. package/dist/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +6 -2
  26. package/dist/templates/web/ui-auth/template/src/components/providers/theme-provider.tsx +94 -0
  27. package/dist/templates/web/ui-auth/template/src/components/shared/footer.tsx +36 -0
  28. package/dist/templates/web/ui-auth/template/src/components/shared/header.tsx +2 -0
  29. package/dist/templates/web/ui-auth/template/src/components/ui/theme-toggle.tsx +34 -0
  30. package/dist/templates/web/ui-auth/template/src/lib/env.ts +49 -0
  31. package/dist/templates/web/ui-auth/template/src/lib/utils.ts +133 -0
  32. package/dist/templates/web/ui-auth/template/src/test/setup.ts +79 -0
  33. package/dist/templates/web/ui-auth/template/vitest.config.ts +17 -0
  34. package/dist/templates/web/ui-auth-payments/template/middleware.ts +68 -0
  35. package/dist/templates/web/ui-auth-payments/template/package.json +14 -4
  36. package/dist/templates/web/ui-auth-payments/template/src/app/dashboard/layout.tsx +22 -0
  37. package/dist/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +183 -0
  38. package/dist/templates/web/ui-auth-payments/template/src/app/error.tsx +67 -0
  39. package/dist/templates/web/ui-auth-payments/template/src/app/layout.tsx +6 -2
  40. package/dist/templates/web/ui-auth-payments/template/src/app/loading.tsx +20 -0
  41. package/dist/templates/web/ui-auth-payments/template/src/app/login/loading.tsx +38 -0
  42. package/dist/templates/web/ui-auth-payments/template/src/app/signup/loading.tsx +50 -0
  43. package/dist/templates/web/ui-auth-payments/template/src/components/__tests__/example.test.tsx +49 -0
  44. package/dist/templates/web/ui-auth-payments/template/src/components/client/auth-status.tsx +52 -0
  45. package/dist/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +144 -0
  46. package/dist/templates/web/ui-auth-payments/template/src/components/client/newsletter-signup.tsx +68 -0
  47. package/dist/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +185 -0
  48. package/dist/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +6 -2
  49. package/dist/templates/web/ui-auth-payments/template/src/components/providers/theme-provider.tsx +94 -0
  50. package/dist/templates/web/ui-auth-payments/template/src/components/shared/footer.tsx +36 -0
  51. package/dist/templates/web/ui-auth-payments/template/src/components/shared/header.tsx +2 -0
  52. package/dist/templates/web/ui-auth-payments/template/src/components/ui/theme-toggle.tsx +34 -0
  53. package/dist/templates/web/ui-auth-payments/template/src/lib/actions/auth.ts +246 -0
  54. package/dist/templates/web/ui-auth-payments/template/src/lib/actions/index.ts +340 -0
  55. package/dist/templates/web/ui-auth-payments/template/src/lib/auth-server.ts +177 -0
  56. package/dist/templates/web/ui-auth-payments/template/src/lib/env.ts +49 -0
  57. package/dist/templates/web/ui-auth-payments/template/src/lib/utils.ts +133 -0
  58. package/dist/templates/web/ui-auth-payments/template/src/test/setup.ts +79 -0
  59. package/dist/templates/web/ui-auth-payments/template/vitest.config.ts +17 -0
  60. package/dist/templates/web/ui-auth-payments-audio/template/package.json +14 -4
  61. package/dist/templates/web/ui-auth-payments-audio/template/src/app/error.tsx +67 -0
  62. package/dist/templates/web/ui-auth-payments-audio/template/src/app/layout.tsx +8 -2
  63. package/dist/templates/web/ui-auth-payments-audio/template/src/app/loading.tsx +20 -0
  64. package/dist/templates/web/ui-auth-payments-audio/template/src/components/__tests__/example.test.tsx +49 -0
  65. package/dist/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +6 -2
  66. package/dist/templates/web/ui-auth-payments-audio/template/src/components/providers/theme-provider.tsx +94 -0
  67. package/dist/templates/web/ui-auth-payments-audio/template/src/components/shared/footer.tsx +36 -0
  68. package/dist/templates/web/ui-auth-payments-audio/template/src/components/shared/header.tsx +2 -0
  69. package/dist/templates/web/ui-auth-payments-audio/template/src/components/ui/theme-toggle.tsx +34 -0
  70. package/dist/templates/web/ui-auth-payments-audio/template/src/lib/env.ts +49 -0
  71. package/dist/templates/web/ui-auth-payments-audio/template/src/lib/utils.ts +133 -0
  72. package/dist/templates/web/ui-auth-payments-audio/template/src/test/setup.ts +79 -0
  73. package/dist/templates/web/ui-auth-payments-audio/template/vitest.config.ts +17 -0
  74. package/dist/templates/web/ui-auth-payments-video/template/package.json +14 -4
  75. package/dist/templates/web/ui-auth-payments-video/template/src/app/error.tsx +67 -0
  76. package/dist/templates/web/ui-auth-payments-video/template/src/app/layout.tsx +6 -2
  77. package/dist/templates/web/ui-auth-payments-video/template/src/app/loading.tsx +20 -0
  78. package/dist/templates/web/ui-auth-payments-video/template/src/components/__tests__/example.test.tsx +49 -0
  79. package/dist/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +6 -2
  80. package/dist/templates/web/ui-auth-payments-video/template/src/components/providers/theme-provider.tsx +94 -0
  81. package/dist/templates/web/ui-auth-payments-video/template/src/components/shared/footer.tsx +36 -0
  82. package/dist/templates/web/ui-auth-payments-video/template/src/components/shared/header.tsx +2 -0
  83. package/dist/templates/web/ui-auth-payments-video/template/src/components/ui/theme-toggle.tsx +34 -0
  84. package/dist/templates/web/ui-auth-payments-video/template/src/lib/env.ts +49 -0
  85. package/dist/templates/web/ui-auth-payments-video/template/src/lib/utils.ts +133 -0
  86. package/dist/templates/web/ui-auth-payments-video/template/src/test/setup.ts +79 -0
  87. package/dist/templates/web/ui-auth-payments-video/template/vitest.config.ts +17 -0
  88. package/dist/templates/web/ui-only/template/package.json +14 -4
  89. package/dist/templates/web/ui-only/template/src/app/error.tsx +67 -0
  90. package/dist/templates/web/ui-only/template/src/app/layout.tsx +6 -2
  91. package/dist/templates/web/ui-only/template/src/app/loading.tsx +20 -0
  92. package/dist/templates/web/ui-only/template/src/components/__tests__/example.test.tsx +49 -0
  93. package/dist/templates/web/ui-only/template/src/components/providers/app-providers.tsx +6 -2
  94. package/dist/templates/web/ui-only/template/src/components/providers/theme-provider.tsx +94 -0
  95. package/dist/templates/web/ui-only/template/src/components/shared/footer.tsx +36 -0
  96. package/dist/templates/web/ui-only/template/src/components/shared/header.tsx +2 -0
  97. package/dist/templates/web/ui-only/template/src/components/ui/theme-toggle.tsx +34 -0
  98. package/dist/templates/web/ui-only/template/src/lib/env.ts +49 -0
  99. package/dist/templates/web/ui-only/template/src/lib/utils.ts +133 -0
  100. package/dist/templates/web/ui-only/template/src/test/setup.ts +79 -0
  101. package/dist/templates/web/ui-only/template/vitest.config.ts +17 -0
  102. package/package.json +1 -1
  103. package/src/templates/web/base/template/package.json +20 -10
  104. package/src/templates/web/base/template/src/app/error.tsx +97 -0
  105. package/src/templates/web/base/template/src/app/layout.tsx +8 -2
  106. package/src/templates/web/base/template/src/app/loading.tsx +34 -0
  107. package/src/templates/web/base/template/src/components/__tests__/example.test.tsx +49 -0
  108. package/src/templates/web/base/template/src/components/providers/app-providers.tsx +6 -2
  109. package/src/templates/web/base/template/src/components/providers/theme-provider.tsx +94 -0
  110. package/src/templates/web/base/template/src/components/shared/footer.tsx +36 -0
  111. package/src/templates/web/base/template/src/components/shared/header.tsx +2 -0
  112. package/src/templates/web/base/template/src/components/ui/theme-toggle.tsx +34 -0
  113. package/src/templates/web/base/template/src/lib/auth-server.ts +177 -0
  114. package/src/templates/web/base/template/src/lib/env.ts +46 -0
  115. package/src/templates/web/base/template/src/lib/utils.ts +133 -0
  116. package/src/templates/web/base/template/src/test/setup.ts +79 -0
  117. package/src/templates/web/base/template/vitest.config.ts +17 -0
  118. package/src/templates/web/ui-auth/template/package.json +14 -4
  119. package/src/templates/web/ui-auth/template/src/app/error.tsx +67 -0
  120. package/src/templates/web/ui-auth/template/src/app/layout.tsx +6 -2
  121. package/src/templates/web/ui-auth/template/src/app/loading.tsx +20 -0
  122. package/src/templates/web/ui-auth/template/src/components/__tests__/example.test.tsx +49 -0
  123. package/src/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +6 -2
  124. package/src/templates/web/ui-auth/template/src/components/providers/theme-provider.tsx +94 -0
  125. package/src/templates/web/ui-auth/template/src/components/shared/footer.tsx +36 -0
  126. package/src/templates/web/ui-auth/template/src/components/shared/header.tsx +2 -0
  127. package/src/templates/web/ui-auth/template/src/components/ui/theme-toggle.tsx +34 -0
  128. package/src/templates/web/ui-auth/template/src/lib/env.ts +49 -0
  129. package/src/templates/web/ui-auth/template/src/lib/utils.ts +133 -0
  130. package/src/templates/web/ui-auth/template/src/test/setup.ts +79 -0
  131. package/src/templates/web/ui-auth/template/vitest.config.ts +17 -0
  132. package/src/templates/web/ui-auth-payments/template/middleware.ts +68 -0
  133. package/src/templates/web/ui-auth-payments/template/package.json +14 -4
  134. package/src/templates/web/ui-auth-payments/template/src/app/dashboard/layout.tsx +22 -0
  135. package/src/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +183 -0
  136. package/src/templates/web/ui-auth-payments/template/src/app/error.tsx +67 -0
  137. package/src/templates/web/ui-auth-payments/template/src/app/layout.tsx +6 -2
  138. package/src/templates/web/ui-auth-payments/template/src/app/loading.tsx +20 -0
  139. package/src/templates/web/ui-auth-payments/template/src/app/login/loading.tsx +38 -0
  140. package/src/templates/web/ui-auth-payments/template/src/app/signup/loading.tsx +50 -0
  141. package/src/templates/web/ui-auth-payments/template/src/components/__tests__/example.test.tsx +49 -0
  142. package/src/templates/web/ui-auth-payments/template/src/components/client/auth-status.tsx +52 -0
  143. package/src/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +144 -0
  144. package/src/templates/web/ui-auth-payments/template/src/components/client/newsletter-signup.tsx +68 -0
  145. package/src/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +185 -0
  146. package/src/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +6 -2
  147. package/src/templates/web/ui-auth-payments/template/src/components/providers/theme-provider.tsx +94 -0
  148. package/src/templates/web/ui-auth-payments/template/src/components/shared/footer.tsx +36 -0
  149. package/src/templates/web/ui-auth-payments/template/src/components/shared/header.tsx +2 -0
  150. package/src/templates/web/ui-auth-payments/template/src/components/ui/theme-toggle.tsx +34 -0
  151. package/src/templates/web/ui-auth-payments/template/src/lib/actions/auth.ts +246 -0
  152. package/src/templates/web/ui-auth-payments/template/src/lib/actions/index.ts +340 -0
  153. package/src/templates/web/ui-auth-payments/template/src/lib/auth-server.ts +177 -0
  154. package/src/templates/web/ui-auth-payments/template/src/lib/env.ts +49 -0
  155. package/src/templates/web/ui-auth-payments/template/src/lib/utils.ts +133 -0
  156. package/src/templates/web/ui-auth-payments/template/src/test/setup.ts +79 -0
  157. package/src/templates/web/ui-auth-payments/template/vitest.config.ts +17 -0
  158. package/src/templates/web/ui-auth-payments-audio/template/package.json +14 -4
  159. package/src/templates/web/ui-auth-payments-audio/template/src/app/error.tsx +67 -0
  160. package/src/templates/web/ui-auth-payments-audio/template/src/app/layout.tsx +8 -2
  161. package/src/templates/web/ui-auth-payments-audio/template/src/app/loading.tsx +20 -0
  162. package/src/templates/web/ui-auth-payments-audio/template/src/components/__tests__/example.test.tsx +49 -0
  163. package/src/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +6 -2
  164. package/src/templates/web/ui-auth-payments-audio/template/src/components/providers/theme-provider.tsx +94 -0
  165. package/src/templates/web/ui-auth-payments-audio/template/src/components/shared/footer.tsx +36 -0
  166. package/src/templates/web/ui-auth-payments-audio/template/src/components/shared/header.tsx +2 -0
  167. package/src/templates/web/ui-auth-payments-audio/template/src/components/ui/theme-toggle.tsx +34 -0
  168. package/src/templates/web/ui-auth-payments-audio/template/src/lib/env.ts +49 -0
  169. package/src/templates/web/ui-auth-payments-audio/template/src/lib/utils.ts +133 -0
  170. package/src/templates/web/ui-auth-payments-audio/template/src/test/setup.ts +79 -0
  171. package/src/templates/web/ui-auth-payments-audio/template/vitest.config.ts +17 -0
  172. package/src/templates/web/ui-auth-payments-video/template/package.json +14 -4
  173. package/src/templates/web/ui-auth-payments-video/template/src/app/error.tsx +67 -0
  174. package/src/templates/web/ui-auth-payments-video/template/src/app/layout.tsx +6 -2
  175. package/src/templates/web/ui-auth-payments-video/template/src/app/loading.tsx +20 -0
  176. package/src/templates/web/ui-auth-payments-video/template/src/components/__tests__/example.test.tsx +49 -0
  177. package/src/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +6 -2
  178. package/src/templates/web/ui-auth-payments-video/template/src/components/providers/theme-provider.tsx +94 -0
  179. package/src/templates/web/ui-auth-payments-video/template/src/components/shared/footer.tsx +36 -0
  180. package/src/templates/web/ui-auth-payments-video/template/src/components/shared/header.tsx +2 -0
  181. package/src/templates/web/ui-auth-payments-video/template/src/components/ui/theme-toggle.tsx +34 -0
  182. package/src/templates/web/ui-auth-payments-video/template/src/lib/env.ts +49 -0
  183. package/src/templates/web/ui-auth-payments-video/template/src/lib/utils.ts +133 -0
  184. package/src/templates/web/ui-auth-payments-video/template/src/test/setup.ts +79 -0
  185. package/src/templates/web/ui-auth-payments-video/template/vitest.config.ts +17 -0
  186. package/src/templates/web/ui-only/template/package.json +14 -4
  187. package/src/templates/web/ui-only/template/src/app/error.tsx +67 -0
  188. package/src/templates/web/ui-only/template/src/app/layout.tsx +6 -2
  189. package/src/templates/web/ui-only/template/src/app/loading.tsx +20 -0
  190. package/src/templates/web/ui-only/template/src/components/__tests__/example.test.tsx +49 -0
  191. package/src/templates/web/ui-only/template/src/components/providers/app-providers.tsx +6 -2
  192. package/src/templates/web/ui-only/template/src/components/providers/theme-provider.tsx +94 -0
  193. package/src/templates/web/ui-only/template/src/components/shared/footer.tsx +36 -0
  194. package/src/templates/web/ui-only/template/src/components/shared/header.tsx +2 -0
  195. package/src/templates/web/ui-only/template/src/components/ui/theme-toggle.tsx +34 -0
  196. package/src/templates/web/ui-only/template/src/lib/env.ts +49 -0
  197. package/src/templates/web/ui-only/template/src/lib/utils.ts +133 -0
  198. package/src/templates/web/ui-only/template/src/test/setup.ts +79 -0
  199. package/src/templates/web/ui-only/template/vitest.config.ts +17 -0
@@ -0,0 +1,97 @@
1
+ 'use client'
2
+
3
+ import { useEffect } from 'react'
4
+ import { Button, Card } from '@digilogiclabs/saas-factory-ui'
5
+ import { AlertTriangle, RefreshCw, Home } from 'lucide-react'
6
+ import Link from 'next/link'
7
+
8
+ interface ErrorProps {
9
+ error: Error & { digest?: string }
10
+ reset: () => void
11
+ }
12
+
13
+ export default function Error({ error, reset }: ErrorProps) {
14
+ useEffect(() => {
15
+ // Log error to error reporting service
16
+ console.error('Application error:', error)
17
+ }, [error])
18
+
19
+ return (
20
+ <div className="min-h-screen bg-gradient-to-br from-red-50 to-orange-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4">
21
+ <Card className="p-8 max-w-lg w-full">
22
+ <div className="flex flex-col items-center space-y-6 text-center">
23
+ {/* Error icon */}
24
+ <div className="w-16 h-16 bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center">
25
+ <AlertTriangle className="w-8 h-8 text-red-600 dark:text-red-400" />
26
+ </div>
27
+
28
+ {/* Error content */}
29
+ <div>
30
+ <h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-2">
31
+ Something went wrong!
32
+ </h1>
33
+ <p className="text-gray-600 dark:text-gray-300 mb-4">
34
+ We encountered an unexpected error. This has been logged and our team will look into it.
35
+ </p>
36
+
37
+ {/* Error details in development */}
38
+ {process.env.NODE_ENV === 'development' && (
39
+ <details className="mt-4 text-left">
40
+ <summary className="cursor-pointer text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
41
+ Error details (development only)
42
+ </summary>
43
+ <div className="mt-2 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono text-gray-700 dark:text-gray-300 overflow-auto max-h-40">
44
+ <div className="mb-2">
45
+ <strong>Message:</strong> {error.message}
46
+ </div>
47
+ {error.digest && (
48
+ <div className="mb-2">
49
+ <strong>Digest:</strong> {error.digest}
50
+ </div>
51
+ )}
52
+ {error.stack && (
53
+ <div>
54
+ <strong>Stack:</strong>
55
+ <pre className="whitespace-pre-wrap mt-1">{error.stack}</pre>
56
+ </div>
57
+ )}
58
+ </div>
59
+ </details>
60
+ )}
61
+ </div>
62
+
63
+ {/* Action buttons */}
64
+ <div className="flex flex-col sm:flex-row gap-3 w-full">
65
+ <Button
66
+ onClick={reset}
67
+ className="flex-1"
68
+ size="lg"
69
+ >
70
+ <RefreshCw className="w-4 h-4 mr-2" />
71
+ Try again
72
+ </Button>
73
+
74
+ <Link href="/" className="flex-1">
75
+ <Button
76
+ variant="outline"
77
+ className="w-full"
78
+ size="lg"
79
+ >
80
+ <Home className="w-4 h-4 mr-2" />
81
+ Go home
82
+ </Button>
83
+ </Link>
84
+ </div>
85
+
86
+ {/* Help text */}
87
+ <p className="text-sm text-gray-500 dark:text-gray-400">
88
+ If this problem persists, please{' '}
89
+ <Link href="/contact" className="text-blue-600 hover:underline dark:text-blue-400">
90
+ contact support
91
+ </Link>
92
+ </p>
93
+ </div>
94
+ </Card>
95
+ </div>
96
+ )
97
+ }
@@ -3,6 +3,7 @@ import { Inter } from 'next/font/google'
3
3
  import './globals.css'
4
4
  import { AppProviders } from '@/components/providers/app-providers'
5
5
  import { Header } from '@/components/shared/header'
6
+ import { Footer } from '@/components/shared/footer'
6
7
 
7
8
  const inter = Inter({ subsets: ['latin'] })
8
9
 
@@ -20,8 +21,13 @@ export default function RootLayout({
20
21
  <html lang="en" suppressHydrationWarning>
21
22
  <body className={inter.className}>
22
23
  <AppProviders>
23
- <Header />
24
- {children}
24
+ <div className="min-h-screen flex flex-col">
25
+ <Header />
26
+ <main className="flex-1">
27
+ {children}
28
+ </main>
29
+ <Footer />
30
+ </div>
25
31
  </AppProviders>
26
32
  </body>
27
33
  </html>
@@ -0,0 +1,34 @@
1
+ import { Card } from '@digilogiclabs/saas-factory-ui'
2
+
3
+ export default function Loading() {
4
+ return (
5
+ <div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center">
6
+ <Card className="p-8 max-w-sm w-full mx-4">
7
+ <div className="flex flex-col items-center space-y-4">
8
+ {/* Animated spinner */}
9
+ <div className="relative">
10
+ <div className="w-12 h-12 border-4 border-gray-200 dark:border-gray-700 rounded-full animate-spin"></div>
11
+ <div className="absolute top-0 left-0 w-12 h-12 border-4 border-blue-600 border-t-transparent rounded-full animate-spin"></div>
12
+ </div>
13
+
14
+ {/* Loading text */}
15
+ <div className="text-center">
16
+ <h2 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
17
+ Loading...
18
+ </h2>
19
+ <p className="text-sm text-gray-600 dark:text-gray-300">
20
+ Please wait while we prepare your content
21
+ </p>
22
+ </div>
23
+
24
+ {/* Pulsing dots */}
25
+ <div className="flex space-x-1">
26
+ <div className="w-2 h-2 bg-blue-600 rounded-full animate-pulse"></div>
27
+ <div className="w-2 h-2 bg-blue-600 rounded-full animate-pulse" style={{ animationDelay: '0.2s' }}></div>
28
+ <div className="w-2 h-2 bg-blue-600 rounded-full animate-pulse" style={{ animationDelay: '0.4s' }}></div>
29
+ </div>
30
+ </div>
31
+ </Card>
32
+ </div>
33
+ )
34
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Example test file demonstrating testing patterns for SaaS Factory components
3
+ *
4
+ * This is optional and serves as a reference for testing your components.
5
+ * You can delete this file if you don't need example tests.
6
+ */
7
+
8
+ import { render, screen } from '@testing-library/react'
9
+ import { Button } from '@digilogiclabs/saas-factory-ui'
10
+
11
+ // Example: Testing UI components
12
+ describe('UI Components', () => {
13
+ it('renders button with correct text', () => {
14
+ render(<Button>Click me</Button>)
15
+ expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument()
16
+ })
17
+
18
+ it('button can be disabled', () => {
19
+ render(<Button disabled>Disabled button</Button>)
20
+ expect(screen.getByRole('button')).toBeDisabled()
21
+ })
22
+ })
23
+
24
+ // Example: Testing custom components
25
+ function MockComponent({ title }: { title: string }) {
26
+ return <h1>{title}</h1>
27
+ }
28
+
29
+ describe('Custom Components', () => {
30
+ it('renders with correct title', () => {
31
+ render(<MockComponent title="Test Title" />)
32
+ expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Test Title')
33
+ })
34
+ })
35
+
36
+ // Example: Testing utilities
37
+ function formatCurrency(amount: number): string {
38
+ return new Intl.NumberFormat('en-US', {
39
+ style: 'currency',
40
+ currency: 'USD',
41
+ }).format(amount)
42
+ }
43
+
44
+ describe('Utilities', () => {
45
+ it('formats currency correctly', () => {
46
+ expect(formatCurrency(1000)).toBe('$1,000.00')
47
+ expect(formatCurrency(0)).toBe('$0.00')
48
+ })
49
+ })
@@ -4,6 +4,7 @@ import React from 'react'
4
4
  import { AuthProvider } from '@digilogiclabs/saas-factory-auth'
5
5
  import { ThemeProvider } from 'next-themes'
6
6
  import { StripeProvider } from '@digilogiclabs/saas-factory-payments'
7
+ import { AppThemeProvider } from './theme-provider'
7
8
 
8
9
  interface AppProvidersProps {
9
10
  children: React.ReactNode
@@ -17,11 +18,14 @@ export function AppProviders({ children }: AppProvidersProps) {
17
18
  >
18
19
  <ThemeProvider
19
20
  attribute="class"
20
- defaultTheme="system"
21
+ defaultTheme="{{defaultTheme}}"
21
22
  enableSystem
22
23
  disableTransitionOnChange
24
+ storageKey="{{packageName}}-theme"
23
25
  >
24
- {children}
26
+ <AppThemeProvider themeColor="{{themeColor}}">
27
+ {children}
28
+ </AppThemeProvider>
25
29
  </ThemeProvider>
26
30
  </StripeProvider>
27
31
  </AuthProvider>
@@ -0,0 +1,94 @@
1
+ 'use client'
2
+
3
+ import React, { createContext, useContext, useEffect } from 'react'
4
+
5
+ interface ThemeContextType {
6
+ themeColor: string
7
+ }
8
+
9
+ const ThemeContext = createContext<ThemeContextType | undefined>(undefined)
10
+
11
+ interface AppThemeProviderProps {
12
+ children: React.ReactNode
13
+ themeColor: string
14
+ }
15
+
16
+ const THEME_COLORS = {
17
+ blue: {
18
+ primary: '221.2 83.2% 53.3%',
19
+ primaryForeground: '210 40% 98%',
20
+ secondary: '210 40% 96%',
21
+ accent: '210 40% 96%',
22
+ ring: '221.2 83.2% 53.3%',
23
+ },
24
+ green: {
25
+ primary: '142.1 76.2% 36.3%',
26
+ primaryForeground: '355.7 100% 97.3%',
27
+ secondary: '138.5 76.2% 96.7%',
28
+ accent: '138.5 76.2% 96.7%',
29
+ ring: '142.1 76.2% 36.3%',
30
+ },
31
+ purple: {
32
+ primary: '262.1 83.3% 57.8%',
33
+ primaryForeground: '210 40% 98%',
34
+ secondary: '270 3.18% 96.5%',
35
+ accent: '270 3.18% 96.5%',
36
+ ring: '262.1 83.3% 57.8%',
37
+ },
38
+ orange: {
39
+ primary: '24.6 95% 53.1%',
40
+ primaryForeground: '60 9.1% 97.8%',
41
+ secondary: '60 4.8% 95.9%',
42
+ accent: '60 4.8% 95.9%',
43
+ ring: '24.6 95% 53.1%',
44
+ },
45
+ red: {
46
+ primary: '0 72.2% 50.6%',
47
+ primaryForeground: '0 85.7% 97.3%',
48
+ secondary: '0 0% 96.3%',
49
+ accent: '0 0% 96.3%',
50
+ ring: '0 72.2% 50.6%',
51
+ },
52
+ slate: {
53
+ primary: '215 27.9% 16.9%',
54
+ primaryForeground: '0 0% 98%',
55
+ secondary: '210 40% 96%',
56
+ accent: '210 40% 96%',
57
+ ring: '215 27.9% 16.9%',
58
+ },
59
+ }
60
+
61
+ export function AppThemeProvider({ children, themeColor }: AppThemeProviderProps) {
62
+ useEffect(() => {
63
+ const colorScheme = THEME_COLORS[themeColor as keyof typeof THEME_COLORS] || THEME_COLORS.blue
64
+
65
+ // Apply theme colors to CSS custom properties
66
+ const root = document.documentElement
67
+ root.style.setProperty('--primary', colorScheme.primary)
68
+ root.style.setProperty('--primary-foreground', colorScheme.primaryForeground)
69
+ root.style.setProperty('--secondary', colorScheme.secondary)
70
+ root.style.setProperty('--accent', colorScheme.accent)
71
+ root.style.setProperty('--ring', colorScheme.ring)
72
+
73
+ // Store theme color preference
74
+ localStorage.setItem('{{packageName}}-theme-color', themeColor)
75
+ }, [themeColor])
76
+
77
+ const contextValue: ThemeContextType = {
78
+ themeColor,
79
+ }
80
+
81
+ return (
82
+ <ThemeContext.Provider value={contextValue}>
83
+ {children}
84
+ </ThemeContext.Provider>
85
+ )
86
+ }
87
+
88
+ export function useAppTheme() {
89
+ const context = useContext(ThemeContext)
90
+ if (context === undefined) {
91
+ throw new Error('useAppTheme must be used within a AppThemeProvider')
92
+ }
93
+ return context
94
+ }
@@ -0,0 +1,36 @@
1
+ 'use client'
2
+
3
+ import React from 'react'
4
+
5
+ interface FooterProps {
6
+ className?: string
7
+ }
8
+
9
+ export function Footer({ className = '' }: FooterProps) {
10
+ return (
11
+ <footer className={`border-t bg-background py-4 ${className}`}>
12
+ <div className="container mx-auto px-4">
13
+ <div className="flex flex-col sm:flex-row justify-between items-center gap-4 text-sm text-muted-foreground">
14
+ <div className="flex items-center gap-2">
15
+ <span>&copy; {new Date().getFullYear()} {{titleCaseName}}</span>
16
+ </div>
17
+
18
+ <div className="flex items-center gap-2 text-xs">
19
+ <span>Generated with</span>
20
+ <a
21
+ href="https://docs.digilogiclabs.com"
22
+ target="_blank"
23
+ rel="noopener noreferrer"
24
+ className="hover:text-foreground transition-colors"
25
+ >
26
+ Digi Logic Labs
27
+ </a>
28
+ <span className="text-muted-foreground/60">
29
+ • UI v{{uiVersion}} • Auth v{{authVersion}} • {{generatedDate}}
30
+ </span>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </footer>
35
+ )
36
+ }
@@ -4,6 +4,7 @@ import React from 'react';
4
4
  import Link from 'next/link';
5
5
  import { useAuth } from '@digilogiclabs/saas-factory-auth';
6
6
  import { Button } from '@/components/ui/button';
7
+ import { ThemeToggle } from '@/components/ui/theme-toggle';
7
8
  import { LogOut } from 'lucide-react';
8
9
 
9
10
  export function Header() {
@@ -16,6 +17,7 @@ export function Header() {
16
17
  {{titleCaseName}}
17
18
  </Link>
18
19
  <nav className="flex items-center gap-4">
20
+ <ThemeToggle />
19
21
  {user ? (
20
22
  <>
21
23
  <Link href="/dashboard" className="text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white">
@@ -0,0 +1,34 @@
1
+ 'use client'
2
+
3
+ import * as React from "react"
4
+ import { Moon, Sun } from "lucide-react"
5
+ import { useTheme } from "next-themes"
6
+
7
+ import { Button } from "@/components/ui/button"
8
+
9
+ export function ThemeToggle() {
10
+ const { theme, setTheme } = useTheme()
11
+
12
+ const toggleTheme = () => {
13
+ if (theme === 'light') {
14
+ setTheme('dark')
15
+ } else if (theme === 'dark') {
16
+ setTheme('system')
17
+ } else {
18
+ setTheme('light')
19
+ }
20
+ }
21
+
22
+ return (
23
+ <Button
24
+ variant="outline"
25
+ size="icon"
26
+ onClick={toggleTheme}
27
+ className="h-9 w-9"
28
+ >
29
+ <Sun className="h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
30
+ <Moon className="absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
31
+ <span className="sr-only">Toggle theme</span>
32
+ </Button>
33
+ )
34
+ }
@@ -0,0 +1,177 @@
1
+ import { cookies } from 'next/headers'
2
+ import { redirect } from 'next/navigation'
3
+
4
+ // Server-side auth utilities that work with @digilogiclabs/saas-factory-auth
5
+ // These functions provide server-side access to auth state
6
+
7
+ export type User = {
8
+ id: string
9
+ email: string
10
+ name?: string
11
+ avatar?: string
12
+ [key: string]: any
13
+ }
14
+
15
+ /**
16
+ * Get the current user from server-side cookies
17
+ * This function should be called in Server Components, Server Actions, or Route Handlers
18
+ */
19
+ export async function getCurrentUser(): Promise<User | null> {
20
+ try {
21
+ const cookieStore = await cookies()
22
+
23
+ // Check for auth token in cookies set by @digilogiclabs/saas-factory-auth
24
+ const authToken = cookieStore.get('saas-factory-auth-token')?.value
25
+ const userCookie = cookieStore.get('saas-factory-auth-user')?.value
26
+
27
+ if (!authToken || !userCookie) {
28
+ return null
29
+ }
30
+
31
+ // Parse user data from cookie
32
+ try {
33
+ const userData = JSON.parse(userCookie)
34
+ return userData
35
+ } catch {
36
+ return null
37
+ }
38
+ } catch (error) {
39
+ console.error('Error getting current user:', error)
40
+ return null
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Require authentication - redirects to login if not authenticated
46
+ * Use this in Server Components that require authentication
47
+ */
48
+ export async function requireAuth(): Promise<User> {
49
+ const user = await getCurrentUser()
50
+
51
+ if (!user) {
52
+ redirect('/login')
53
+ }
54
+
55
+ return user
56
+ }
57
+
58
+ /**
59
+ * Check if user is authenticated (without redirecting)
60
+ * Returns boolean for conditional rendering
61
+ */
62
+ export async function isAuthenticated(): Promise<boolean> {
63
+ const user = await getCurrentUser()
64
+ return !!user
65
+ }
66
+
67
+ /**
68
+ * Redirect if already authenticated
69
+ * Use this on login/signup pages
70
+ */
71
+ export async function redirectIfAuthenticated(redirectTo: string = '/') {
72
+ const user = await getCurrentUser()
73
+
74
+ if (user) {
75
+ redirect(redirectTo)
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Get user session data for server components
81
+ * Returns both user and loading state info
82
+ */
83
+ export async function getServerSession() {
84
+ const user = await getCurrentUser()
85
+
86
+ return {
87
+ user,
88
+ isAuthenticated: !!user,
89
+ isLoading: false, // Server-side is never loading
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Server-side auth check for API routes
95
+ */
96
+ export async function getAuthFromRequest(request?: Request): Promise<User | null> {
97
+ try {
98
+ // If request is provided, extract cookies from it
99
+ if (request) {
100
+ const cookie = request.headers.get('cookie')
101
+ if (!cookie) return null
102
+
103
+ // Parse cookies manually from request
104
+ const cookies = cookie.split(';').reduce((acc, cookie) => {
105
+ const [key, value] = cookie.trim().split('=')
106
+ acc[key] = value
107
+ return acc
108
+ }, {} as Record<string, string>)
109
+
110
+ const authToken = cookies['saas-factory-auth-token']
111
+ const userCookie = cookies['saas-factory-auth-user']
112
+
113
+ if (!authToken || !userCookie) {
114
+ return null
115
+ }
116
+
117
+ try {
118
+ const userData = JSON.parse(decodeURIComponent(userCookie))
119
+ return userData
120
+ } catch {
121
+ return null
122
+ }
123
+ }
124
+
125
+ // Fallback to cookies() API
126
+ return await getCurrentUser()
127
+ } catch (error) {
128
+ console.error('Error getting auth from request:', error)
129
+ return null
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Create server action wrapper that requires authentication
135
+ */
136
+ export function withAuth<T extends any[], R>(
137
+ action: (user: User, ...args: T) => Promise<R>
138
+ ) {
139
+ return async (...args: T): Promise<R> => {
140
+ const user = await requireAuth()
141
+ return action(user, ...args)
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Server-side utility to check specific roles/permissions
147
+ * Extend this based on your user data structure
148
+ */
149
+ export async function hasRole(role: string): Promise<boolean> {
150
+ const user = await getCurrentUser()
151
+
152
+ if (!user) return false
153
+
154
+ // Assuming role is stored in user.role or user.roles
155
+ if (Array.isArray(user.roles)) {
156
+ return user.roles.includes(role)
157
+ }
158
+
159
+ return user.role === role
160
+ }
161
+
162
+ /**
163
+ * Server-side utility to require specific roles
164
+ */
165
+ export async function requireRole(role: string): Promise<User> {
166
+ const user = await requireAuth()
167
+
168
+ const hasRequiredRole = Array.isArray(user.roles)
169
+ ? user.roles.includes(role)
170
+ : user.role === role
171
+
172
+ if (!hasRequiredRole) {
173
+ redirect('/unauthorized')
174
+ }
175
+
176
+ return user
177
+ }
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod'
2
+
3
+ const envSchema = z.object({
4
+ // Next.js environment
5
+ NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
6
+
7
+ // Supabase Configuration (if needed for custom auth)
8
+ NEXT_PUBLIC_SUPABASE_URL: z.string().url().optional(),
9
+ NEXT_PUBLIC_SUPABASE_ANON_KEY: z.string().optional(),
10
+ SUPABASE_SERVICE_ROLE_KEY: z.string().optional(),
11
+
12
+ // Stripe Configuration (from @digilogiclabs/saas-factory-payments)
13
+ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().optional(),
14
+ STRIPE_SECRET_KEY: z.string().optional(),
15
+ STRIPE_WEBHOOK_SECRET: z.string().optional(),
16
+
17
+ // App Configuration
18
+ NEXT_PUBLIC_APP_URL: z.string().url().default('http://localhost:3000'),
19
+
20
+ // Database (if using custom database)
21
+ DATABASE_URL: z.string().optional(),
22
+ })
23
+
24
+ export type Env = z.infer<typeof envSchema>
25
+
26
+ const parsedEnv = envSchema.safeParse(process.env)
27
+
28
+ if (!parsedEnv.success) {
29
+ console.error('❌ Invalid environment variables:', parsedEnv.error.format())
30
+ throw new Error('Invalid environment variables')
31
+ }
32
+
33
+ export const env = parsedEnv.data
34
+
35
+ // Export for easier access in server components
36
+ export const {
37
+ NODE_ENV,
38
+ NEXT_PUBLIC_SUPABASE_URL,
39
+ NEXT_PUBLIC_SUPABASE_ANON_KEY,
40
+ SUPABASE_SERVICE_ROLE_KEY,
41
+ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY,
42
+ STRIPE_SECRET_KEY,
43
+ STRIPE_WEBHOOK_SECRET,
44
+ NEXT_PUBLIC_APP_URL,
45
+ DATABASE_URL,
46
+ } = env