@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,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
+ })
@@ -4,11 +4,14 @@
4
4
  "description": "{{description}} - Audio Player App (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,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
+ }
@@ -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,20 @@
1
+ import { Card } from '@digilogiclabs/saas-factory-ui'
2
+ import { Loader2 } from 'lucide-react'
3
+
4
+ export default function Loading() {
5
+ return (
6
+ <div className="min-h-screen bg-gray-50 dark:bg-gray-900 flex items-center justify-center p-4">
7
+ <Card className="w-full max-w-md p-8 text-center">
8
+ <div className="flex flex-col items-center">
9
+ <Loader2 className="h-8 w-8 animate-spin text-blue-600 dark:text-blue-400 mb-4" />
10
+ <h2 className="text-lg font-medium text-gray-900 dark:text-white mb-2">
11
+ Loading
12
+ </h2>
13
+ <p className="text-sm text-gray-600 dark:text-gray-300">
14
+ Please wait while we load your content...
15
+ </p>
16
+ </div>
17
+ </Card>
18
+ </div>
19
+ )
20
+ }
@@ -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 { ThemeProvider } from 'next-themes'
5
5
  import { AuthProvider } from '@digilogiclabs/saas-factory-auth'
6
6
  import { PaymentsProvider } from '@digilogiclabs/saas-factory-payments'
7
+ import { AppThemeProvider } from './theme-provider'
7
8
 
8
9
  interface AppProvidersProps {
9
10
  children: React.ReactNode
@@ -13,13 +14,16 @@ export function AppProviders({ children }: AppProvidersProps) {
13
14
  return (
14
15
  <ThemeProvider
15
16
  attribute="class"
16
- defaultTheme="system"
17
+ defaultTheme="{{defaultTheme}}"
17
18
  enableSystem
18
19
  disableTransitionOnChange
20
+ storageKey="{{packageName}}-theme"
19
21
  >
20
22
  <AuthProvider>
21
23
  <PaymentsProvider>
22
- {children}
24
+ <AppThemeProvider themeColor="{{themeColor}}">
25
+ {children}
26
+ </AppThemeProvider>
23
27
  </PaymentsProvider>
24
28
  </AuthProvider>
25
29
  </ThemeProvider>
@@ -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}} • Payments v{{paymentsVersion}} • {{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 { LogOut, CreditCard } from 'lucide-react';
6
6
  import { useAuth } from '@digilogiclabs/saas-factory-auth';
7
+ import { ThemeToggle } from '@/components/ui/theme-toggle';
7
8
 
8
9
  export function Header() {
9
10
  const { user, signOut } = useAuth();
@@ -23,6 +24,7 @@ export function Header() {
23
24
  {{titleCaseName}}
24
25
  </Link>
25
26
  <nav className="flex items-center gap-4">
27
+ <ThemeToggle />
26
28
  {user ? (
27
29
  <>
28
30
  <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 "@digilogiclabs/saas-factory-ui"
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,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>