@digilogiclabs/create-saas-app 2.8.1 → 2.9.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/dist/.tsbuildinfo +1 -1
- package/dist/generators/template-generator.js +8 -8
- package/dist/generators/template-generator.js.map +1 -1
- package/dist/templates/shared/quality/web/src/__tests__/accessibility.test.tsx +3 -3
- package/dist/templates/web/ai-platform/template/src/app/page.tsx +207 -207
- package/dist/templates/web/base/template/src/app/dashboard/page.tsx +6 -43
- package/dist/templates/web/base/template/src/app/page.tsx +2 -2
- package/dist/templates/web/ui-auth/template/src/app/dev-setup/page.tsx +800 -800
- package/dist/templates/web/ui-auth/template/src/app/login/page.tsx +109 -109
- package/dist/templates/web/ui-auth/template/src/app/page.tsx +3 -3
- package/dist/templates/web/ui-auth/template/src/app/signup/page.tsx +128 -128
- package/dist/templates/web/ui-auth-ai/template/src/app/globals.css +35 -40
- package/dist/templates/web/ui-auth-ai/template/src/app/layout.tsx +1 -0
- package/dist/templates/web/ui-auth-payments/template/src/app/checkout/page.tsx +3 -3
- package/dist/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +10 -49
- package/dist/templates/web/ui-auth-payments/template/src/app/dev-setup/page.tsx +800 -800
- package/dist/templates/web/ui-auth-payments/template/src/app/login/page.tsx +109 -109
- package/dist/templates/web/ui-auth-payments/template/src/app/page.tsx +350 -350
- package/dist/templates/web/ui-auth-payments/template/src/app/setup/page.tsx +506 -506
- package/dist/templates/web/ui-auth-payments/template/src/app/signup/page.tsx +128 -128
- package/dist/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +143 -143
- package/dist/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +184 -184
- package/dist/templates/web/ui-auth-payments-ai/template/src/app/billing/page.tsx +143 -233
- package/dist/templates/web/ui-auth-payments-ai/template/src/app/dashboard/page.tsx +10 -50
- package/dist/templates/web/ui-auth-payments-ai/template/src/app/dev-setup/page.tsx +800 -800
- package/dist/templates/web/ui-auth-payments-ai/template/src/app/onboarding/page.tsx +325 -364
- package/dist/templates/web/ui-auth-payments-ai/template/src/app/page.tsx +1 -1
- package/dist/templates/web/ui-auth-payments-ai/template/src/app/settings/page.tsx +389 -532
- package/dist/templates/web/ui-auth-payments-ai/template/src/app/setup/page.tsx +644 -644
- package/dist/templates/web/ui-auth-payments-ai/template/src/components/client/login-form.tsx +119 -163
- package/dist/templates/web/ui-auth-payments-ai/template/src/components/client/signup-form.tsx +158 -201
- package/dist/templates/web/ui-auth-payments-audio/template/src/app/dashboard/page.tsx +10 -51
- package/dist/templates/web/ui-auth-payments-audio/template/src/app/page.tsx +402 -403
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/client/login-form.tsx +143 -143
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/client/signup-form.tsx +184 -184
- package/dist/templates/web/ui-auth-payments-video/template/src/app/login/page.tsx +1 -1
- package/dist/templates/web/ui-auth-payments-video/template/src/app/page.tsx +3 -7
- package/dist/templates/web/ui-auth-payments-video/template/src/app/signup/page.tsx +1 -1
- package/package.json +1 -1
- package/src/templates/shared/quality/web/src/__tests__/accessibility.test.tsx +3 -3
- package/src/templates/web/ai-platform/template/src/app/page.tsx +207 -207
- package/src/templates/web/base/template/src/app/dashboard/page.tsx +6 -43
- package/src/templates/web/base/template/src/app/page.tsx +2 -2
- package/src/templates/web/ui-auth/template/src/app/dev-setup/page.tsx +800 -800
- package/src/templates/web/ui-auth/template/src/app/login/page.tsx +109 -109
- package/src/templates/web/ui-auth/template/src/app/page.tsx +3 -3
- package/src/templates/web/ui-auth/template/src/app/signup/page.tsx +128 -128
- package/src/templates/web/ui-auth-ai/template/src/app/globals.css +35 -40
- package/src/templates/web/ui-auth-ai/template/src/app/layout.tsx +1 -0
- package/src/templates/web/ui-auth-payments/template/src/app/checkout/page.tsx +3 -3
- package/src/templates/web/ui-auth-payments/template/src/app/dashboard/page.tsx +10 -49
- package/src/templates/web/ui-auth-payments/template/src/app/dev-setup/page.tsx +800 -800
- package/src/templates/web/ui-auth-payments/template/src/app/login/page.tsx +109 -109
- package/src/templates/web/ui-auth-payments/template/src/app/page.tsx +350 -350
- package/src/templates/web/ui-auth-payments/template/src/app/setup/page.tsx +506 -506
- package/src/templates/web/ui-auth-payments/template/src/app/signup/page.tsx +128 -128
- package/src/templates/web/ui-auth-payments/template/src/components/client/login-form.tsx +143 -143
- package/src/templates/web/ui-auth-payments/template/src/components/client/signup-form.tsx +184 -184
- package/src/templates/web/ui-auth-payments-ai/template/src/app/billing/page.tsx +143 -233
- package/src/templates/web/ui-auth-payments-ai/template/src/app/dashboard/page.tsx +10 -50
- package/src/templates/web/ui-auth-payments-ai/template/src/app/dev-setup/page.tsx +800 -800
- package/src/templates/web/ui-auth-payments-ai/template/src/app/onboarding/page.tsx +325 -364
- package/src/templates/web/ui-auth-payments-ai/template/src/app/page.tsx +1 -1
- package/src/templates/web/ui-auth-payments-ai/template/src/app/settings/page.tsx +389 -532
- package/src/templates/web/ui-auth-payments-ai/template/src/app/setup/page.tsx +644 -644
- package/src/templates/web/ui-auth-payments-ai/template/src/components/client/login-form.tsx +119 -163
- package/src/templates/web/ui-auth-payments-ai/template/src/components/client/signup-form.tsx +158 -201
- package/src/templates/web/ui-auth-payments-audio/template/src/app/dashboard/page.tsx +10 -51
- package/src/templates/web/ui-auth-payments-audio/template/src/app/page.tsx +402 -403
- package/src/templates/web/ui-auth-payments-audio/template/src/components/client/login-form.tsx +143 -143
- package/src/templates/web/ui-auth-payments-audio/template/src/components/client/signup-form.tsx +184 -184
- package/src/templates/web/ui-auth-payments-video/template/src/app/login/page.tsx +1 -1
- package/src/templates/web/ui-auth-payments-video/template/src/app/page.tsx +3 -7
- package/src/templates/web/ui-auth-payments-video/template/src/app/signup/page.tsx +1 -1
|
@@ -1,163 +1,119 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useState
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Card,
|
|
7
|
-
Input,
|
|
8
|
-
Label
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
validation={['required', 'minLength:6']}
|
|
121
|
-
disabled={loading}
|
|
122
|
-
className="mb-6"
|
|
123
|
-
showPasswordStrength={false}
|
|
124
|
-
/>
|
|
125
|
-
</SingleStepForm>
|
|
126
|
-
</FormProvider>
|
|
127
|
-
|
|
128
|
-
{/* Social Auth */}
|
|
129
|
-
<Button
|
|
130
|
-
type="button"
|
|
131
|
-
variant="outline"
|
|
132
|
-
className="w-full mt-4"
|
|
133
|
-
onClick={handleGoogleLogin}
|
|
134
|
-
disabled={loading}
|
|
135
|
-
>
|
|
136
|
-
Sign in with Google
|
|
137
|
-
</Button>
|
|
138
|
-
|
|
139
|
-
{/* Legacy error display */}
|
|
140
|
-
{actionState?.error && (
|
|
141
|
-
<div className="mt-4 p-3 bg-red-100 border border-red-400 text-red-700 rounded">
|
|
142
|
-
{actionState.error}
|
|
143
|
-
</div>
|
|
144
|
-
)}
|
|
145
|
-
|
|
146
|
-
{error && (
|
|
147
|
-
<div className="mt-4 p-3 bg-red-100 border border-red-400 text-red-700 rounded">
|
|
148
|
-
{error.message}
|
|
149
|
-
</div>
|
|
150
|
-
)}
|
|
151
|
-
|
|
152
|
-
<div className="mt-6 text-center">
|
|
153
|
-
<p className="text-sm text-gray-600 dark:text-gray-300">
|
|
154
|
-
Don't have an account?{' '}
|
|
155
|
-
<a href="/signup" className="text-blue-600 hover:underline dark:text-blue-400">
|
|
156
|
-
Sign up
|
|
157
|
-
</a>
|
|
158
|
-
</p>
|
|
159
|
-
</div>
|
|
160
|
-
</Card>
|
|
161
|
-
</div>
|
|
162
|
-
)
|
|
163
|
-
}
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React, { useState } from 'react'
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Card,
|
|
7
|
+
Input,
|
|
8
|
+
Label
|
|
9
|
+
} from '@digilogiclabs/saas-factory-ui'
|
|
10
|
+
import { useAuth } from '@digilogiclabs/app-sdk'
|
|
11
|
+
import { useRouter } from 'next/navigation'
|
|
12
|
+
|
|
13
|
+
export function LoginForm() {
|
|
14
|
+
const [email, setEmail] = useState('')
|
|
15
|
+
const [password, setPassword] = useState('')
|
|
16
|
+
const { signIn, signInWithOAuth, loading, error, user } = useAuth()
|
|
17
|
+
const router = useRouter()
|
|
18
|
+
|
|
19
|
+
// Redirect if already logged in
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
if (user) {
|
|
22
|
+
router.push('/')
|
|
23
|
+
}
|
|
24
|
+
}, [user, router])
|
|
25
|
+
|
|
26
|
+
const handleLogin = async (e: React.FormEvent) => {
|
|
27
|
+
e.preventDefault()
|
|
28
|
+
try {
|
|
29
|
+
await signIn(email, password)
|
|
30
|
+
router.push('/')
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error('Login error:', err)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const handleGoogleLogin = async () => {
|
|
37
|
+
try {
|
|
38
|
+
await signInWithOAuth('google')
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error('Google login error:', err)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (loading) {
|
|
45
|
+
return (
|
|
46
|
+
<div className="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-900">
|
|
47
|
+
<div>Loading...</div>
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-900">
|
|
54
|
+
<Card className="w-full max-w-md p-8">
|
|
55
|
+
<h1 className="text-2xl font-bold text-center mb-6">Sign In</h1>
|
|
56
|
+
|
|
57
|
+
<form onSubmit={handleLogin} className="space-y-4">
|
|
58
|
+
<div>
|
|
59
|
+
<Label htmlFor="email">Email</Label>
|
|
60
|
+
<Input
|
|
61
|
+
id="email"
|
|
62
|
+
name="email"
|
|
63
|
+
type="email"
|
|
64
|
+
value={email}
|
|
65
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
66
|
+
placeholder="Enter your email"
|
|
67
|
+
required
|
|
68
|
+
disabled={loading}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div>
|
|
73
|
+
<Label htmlFor="password">Password</Label>
|
|
74
|
+
<Input
|
|
75
|
+
id="password"
|
|
76
|
+
name="password"
|
|
77
|
+
type="password"
|
|
78
|
+
value={password}
|
|
79
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
80
|
+
placeholder="Enter your password"
|
|
81
|
+
required
|
|
82
|
+
disabled={loading}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<Button type="submit" className="w-full" disabled={loading}>
|
|
87
|
+
{loading ? 'Signing In...' : 'Sign In'}
|
|
88
|
+
</Button>
|
|
89
|
+
</form>
|
|
90
|
+
|
|
91
|
+
{/* Social Auth */}
|
|
92
|
+
<Button
|
|
93
|
+
type="button"
|
|
94
|
+
variant="outline"
|
|
95
|
+
className="w-full mt-4"
|
|
96
|
+
onClick={handleGoogleLogin}
|
|
97
|
+
disabled={loading}
|
|
98
|
+
>
|
|
99
|
+
Sign in with Google
|
|
100
|
+
</Button>
|
|
101
|
+
|
|
102
|
+
{error && (
|
|
103
|
+
<div className="mt-4 p-3 bg-red-100 border border-red-400 text-red-700 rounded">
|
|
104
|
+
{error.message}
|
|
105
|
+
</div>
|
|
106
|
+
)}
|
|
107
|
+
|
|
108
|
+
<div className="mt-6 text-center">
|
|
109
|
+
<p className="text-sm text-gray-600 dark:text-gray-300">
|
|
110
|
+
Don't have an account?{' '}
|
|
111
|
+
<a href="/signup" className="text-blue-600 hover:underline dark:text-blue-400">
|
|
112
|
+
Sign up
|
|
113
|
+
</a>
|
|
114
|
+
</p>
|
|
115
|
+
</div>
|
|
116
|
+
</Card>
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
}
|
package/src/templates/web/ui-auth-payments-ai/template/src/components/client/signup-form.tsx
CHANGED
|
@@ -1,201 +1,158 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useState
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Card,
|
|
7
|
-
Input,
|
|
8
|
-
Label
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
placeholder="Enter your password"
|
|
160
|
-
validation={['required', 'minLength:8', 'hasUppercase', 'hasLowercase', 'hasNumber']}
|
|
161
|
-
disabled={loading}
|
|
162
|
-
className="mb-4"
|
|
163
|
-
showPasswordStrength={true}
|
|
164
|
-
helpText="Password must be at least 8 characters with uppercase, lowercase, and number"
|
|
165
|
-
/>
|
|
166
|
-
|
|
167
|
-
<FormField
|
|
168
|
-
name="confirmPassword"
|
|
169
|
-
type="password"
|
|
170
|
-
label="Confirm Password"
|
|
171
|
-
placeholder="Confirm your password"
|
|
172
|
-
validation={['required']}
|
|
173
|
-
disabled={loading}
|
|
174
|
-
className="mb-6"
|
|
175
|
-
/>
|
|
176
|
-
</SingleStepForm>
|
|
177
|
-
</FormProvider>
|
|
178
|
-
|
|
179
|
-
{/* Social Auth */}
|
|
180
|
-
<Button
|
|
181
|
-
type="button"
|
|
182
|
-
variant="outline"
|
|
183
|
-
className="w-full mt-4"
|
|
184
|
-
onClick={handleGoogleSignUp}
|
|
185
|
-
disabled={loading}
|
|
186
|
-
>
|
|
187
|
-
Sign up with Google
|
|
188
|
-
</Button>
|
|
189
|
-
|
|
190
|
-
<div className="mt-4 text-center">
|
|
191
|
-
<p className="text-sm text-gray-600 dark:text-gray-300">
|
|
192
|
-
Already have an account?{' '}
|
|
193
|
-
<a href="/login" className="text-blue-600 hover:underline dark:text-blue-400">
|
|
194
|
-
Sign in
|
|
195
|
-
</a>
|
|
196
|
-
</p>
|
|
197
|
-
</div>
|
|
198
|
-
</Card>
|
|
199
|
-
</div>
|
|
200
|
-
)
|
|
201
|
-
}
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React, { useState } from 'react'
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Card,
|
|
7
|
+
Input,
|
|
8
|
+
Label
|
|
9
|
+
} from '@digilogiclabs/saas-factory-ui'
|
|
10
|
+
import { useAuth } from '@digilogiclabs/app-sdk'
|
|
11
|
+
import { useRouter } from 'next/navigation'
|
|
12
|
+
|
|
13
|
+
export function SignupForm() {
|
|
14
|
+
const [name, setName] = useState('')
|
|
15
|
+
const [email, setEmail] = useState('')
|
|
16
|
+
const [password, setPassword] = useState('')
|
|
17
|
+
const [confirmPassword, setConfirmPassword] = useState('')
|
|
18
|
+
const { signUp, signInWithOAuth, loading, error, user } = useAuth()
|
|
19
|
+
const router = useRouter()
|
|
20
|
+
|
|
21
|
+
// Redirect if already logged in
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (user) {
|
|
24
|
+
router.push('/')
|
|
25
|
+
}
|
|
26
|
+
}, [user, router])
|
|
27
|
+
|
|
28
|
+
const handleSignUp = async (e: React.FormEvent) => {
|
|
29
|
+
e.preventDefault()
|
|
30
|
+
|
|
31
|
+
if (password !== confirmPassword) {
|
|
32
|
+
console.error('Passwords do not match')
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
await signUp(email, password)
|
|
38
|
+
router.push('/')
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error('Sign up error:', err)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const handleGoogleSignUp = async () => {
|
|
45
|
+
try {
|
|
46
|
+
await signInWithOAuth('google')
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error('Google sign up error:', err)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (loading) {
|
|
53
|
+
return (
|
|
54
|
+
<div className="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-900">
|
|
55
|
+
<div>Loading...</div>
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-900">
|
|
62
|
+
<Card className="w-full max-w-md p-8">
|
|
63
|
+
<h1 className="text-2xl font-bold text-center mb-6">Sign Up</h1>
|
|
64
|
+
|
|
65
|
+
{error && (
|
|
66
|
+
<div className="mb-4 p-3 bg-red-100 border border-red-400 text-red-700 rounded">
|
|
67
|
+
{error.message}
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
<form onSubmit={handleSignUp} className="space-y-4">
|
|
72
|
+
<div>
|
|
73
|
+
<Label htmlFor="name">Name</Label>
|
|
74
|
+
<Input
|
|
75
|
+
id="name"
|
|
76
|
+
name="name"
|
|
77
|
+
type="text"
|
|
78
|
+
value={name}
|
|
79
|
+
onChange={(e) => setName(e.target.value)}
|
|
80
|
+
placeholder="Enter your full name"
|
|
81
|
+
required
|
|
82
|
+
disabled={loading}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div>
|
|
87
|
+
<Label htmlFor="email">Email</Label>
|
|
88
|
+
<Input
|
|
89
|
+
id="email"
|
|
90
|
+
name="email"
|
|
91
|
+
type="email"
|
|
92
|
+
value={email}
|
|
93
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
94
|
+
placeholder="Enter your email"
|
|
95
|
+
required
|
|
96
|
+
disabled={loading}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div>
|
|
101
|
+
<Label htmlFor="password">Password</Label>
|
|
102
|
+
<Input
|
|
103
|
+
id="password"
|
|
104
|
+
name="password"
|
|
105
|
+
type="password"
|
|
106
|
+
value={password}
|
|
107
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
108
|
+
placeholder="Enter your password"
|
|
109
|
+
required
|
|
110
|
+
disabled={loading}
|
|
111
|
+
/>
|
|
112
|
+
<p className="text-xs text-gray-500 mt-1">
|
|
113
|
+
Password must be at least 8 characters with uppercase, lowercase, and number
|
|
114
|
+
</p>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div>
|
|
118
|
+
<Label htmlFor="confirmPassword">Confirm Password</Label>
|
|
119
|
+
<Input
|
|
120
|
+
id="confirmPassword"
|
|
121
|
+
name="confirmPassword"
|
|
122
|
+
type="password"
|
|
123
|
+
value={confirmPassword}
|
|
124
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
125
|
+
placeholder="Confirm your password"
|
|
126
|
+
required
|
|
127
|
+
disabled={loading}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<Button type="submit" className="w-full" disabled={loading}>
|
|
132
|
+
{loading ? 'Signing Up...' : 'Sign Up'}
|
|
133
|
+
</Button>
|
|
134
|
+
</form>
|
|
135
|
+
|
|
136
|
+
{/* Social Auth */}
|
|
137
|
+
<Button
|
|
138
|
+
type="button"
|
|
139
|
+
variant="outline"
|
|
140
|
+
className="w-full mt-4"
|
|
141
|
+
onClick={handleGoogleSignUp}
|
|
142
|
+
disabled={loading}
|
|
143
|
+
>
|
|
144
|
+
Sign up with Google
|
|
145
|
+
</Button>
|
|
146
|
+
|
|
147
|
+
<div className="mt-4 text-center">
|
|
148
|
+
<p className="text-sm text-gray-600 dark:text-gray-300">
|
|
149
|
+
Already have an account?{' '}
|
|
150
|
+
<a href="/login" className="text-blue-600 hover:underline dark:text-blue-400">
|
|
151
|
+
Sign in
|
|
152
|
+
</a>
|
|
153
|
+
</p>
|
|
154
|
+
</div>
|
|
155
|
+
</Card>
|
|
156
|
+
</div>
|
|
157
|
+
)
|
|
158
|
+
}
|