|
1 | 1 | "use client";
|
2 | 2 |
|
3 | 3 | import { signIn, getProviders } from "next-auth/react";
|
4 |
| -import { Text, TextInput, Button, Card } from "@tremor/react"; |
5 |
| -import Image from "next/image"; |
| 4 | +import { Text, TextInput, Button } from "@tremor/react"; |
6 | 5 | import { useEffect, useState } from "react";
|
7 | 6 | import { useForm } from "react-hook-form";
|
8 |
| -import "../../globals.css"; |
9 | 7 | import { authenticate, revalidateAfterAuth } from "@/app/actions/authactions";
|
10 | 8 | import { useRouter } from "next/navigation";
|
| 9 | +import "../../globals.css"; |
11 | 10 |
|
12 | 11 | export interface Provider {
|
13 | 12 | id: string;
|
@@ -109,129 +108,92 @@ export default function SignInForm({ params }: { params?: { amt: string } }) {
|
109 | 108 | // Show loading state during redirect
|
110 | 109 | if (isRedirecting) {
|
111 | 110 | return (
|
112 |
| - <div className="min-h-screen flex items-center justify-center bg-tremor-background-subtle p-4"> |
113 |
| - <Card |
114 |
| - className="w-full max-w-md p-8" |
115 |
| - decoration="top" |
116 |
| - decorationColor="orange" |
117 |
| - > |
118 |
| - <div className="flex flex-col items-center gap-6"> |
119 |
| - <div className="relative w-32 h-32"> |
120 |
| - <Image |
121 |
| - src="/keep_big.svg" |
122 |
| - alt="Keep Logo" |
123 |
| - width={128} |
124 |
| - height={128} |
125 |
| - priority |
126 |
| - className="object-contain" |
127 |
| - /> |
128 |
| - </div> |
129 |
| - <Text className="text-tremor-title font-bold text-tremor-content-strong"> |
130 |
| - Authentication successful, redirecting... |
131 |
| - </Text> |
132 |
| - </div> |
133 |
| - </Card> |
134 |
| - </div> |
| 111 | + <Text className="text-tremor-title h-full flex items-center justify-center font-bold text-tremor-content-strong"> |
| 112 | + Authentication successful, redirecting... |
| 113 | + </Text> |
135 | 114 | );
|
136 | 115 | }
|
137 | 116 |
|
138 | 117 | if (providers?.credentials) {
|
139 | 118 | return (
|
140 |
| - <div className="min-h-screen flex items-center justify-center bg-tremor-background-subtle p-4"> |
141 |
| - <Card |
142 |
| - className="w-full max-w-md p-8" |
143 |
| - decoration="top" |
144 |
| - decorationColor="orange" |
145 |
| - > |
146 |
| - <div className="flex flex-col items-center gap-6"> |
147 |
| - <div className="relative w-32 h-32"> |
148 |
| - <Image |
149 |
| - src="/keep_big.svg" |
150 |
| - alt="Keep Logo" |
151 |
| - width={128} |
152 |
| - height={128} |
153 |
| - priority |
154 |
| - className="object-contain" |
155 |
| - /> |
| 119 | + <> |
| 120 | + <Text className="text-tremor-title font-bold text-tremor-content-strong"> |
| 121 | + Log in to your account |
| 122 | + </Text> |
| 123 | + |
| 124 | + <form className="w-full space-y-6" onSubmit={handleSubmit(onSubmit)}> |
| 125 | + {errors.root && ( |
| 126 | + <div className="w-full rounded-md bg-red-50 p-4"> |
| 127 | + <Text className="text-sm text-red-500 text-center"> |
| 128 | + {errors.root.message} |
| 129 | + </Text> |
156 | 130 | </div>
|
157 |
| - |
158 |
| - <Text className="text-tremor-title font-bold text-tremor-content-strong"> |
159 |
| - Sign in to Keep |
| 131 | + )} |
| 132 | + <div className="space-y-2"> |
| 133 | + <Text className="text-tremor-default font-medium text-tremor-content-strong"> |
| 134 | + Username |
160 | 135 | </Text>
|
| 136 | + <TextInput |
| 137 | + {...register("username", { |
| 138 | + required: "Username is required", |
| 139 | + })} |
| 140 | + type="text" |
| 141 | + placeholder="Enter your username" |
| 142 | + className="w-full" |
| 143 | + error={!!errors.username} |
| 144 | + disabled={isSubmitting || isRedirecting} |
| 145 | + /> |
| 146 | + {errors.username && ( |
| 147 | + <Text className="text-sm text-red-500 mt-1"> |
| 148 | + {errors.username.message} |
| 149 | + </Text> |
| 150 | + )} |
| 151 | + </div> |
161 | 152 |
|
162 |
| - <form |
163 |
| - className="w-full space-y-6" |
164 |
| - onSubmit={handleSubmit(onSubmit)} |
165 |
| - > |
166 |
| - <div className="space-y-2"> |
167 |
| - <Text className="text-tremor-default font-medium text-tremor-content-strong"> |
168 |
| - Username |
169 |
| - </Text> |
170 |
| - <TextInput |
171 |
| - {...register("username", { |
172 |
| - required: "Username is required", |
173 |
| - })} |
174 |
| - type="text" |
175 |
| - placeholder="Enter your username" |
176 |
| - className="w-full" |
177 |
| - error={!!errors.username} |
178 |
| - disabled={isSubmitting || isRedirecting} |
179 |
| - /> |
180 |
| - {errors.username && ( |
181 |
| - <Text className="text-sm text-red-500 mt-1"> |
182 |
| - {errors.username.message} |
183 |
| - </Text> |
184 |
| - )} |
185 |
| - </div> |
186 |
| - |
187 |
| - <div className="space-y-2"> |
188 |
| - <Text className="text-tremor-default font-medium text-tremor-content-strong"> |
189 |
| - Password |
190 |
| - </Text> |
191 |
| - <TextInput |
192 |
| - {...register("password", { |
193 |
| - required: "Password is required", |
194 |
| - })} |
195 |
| - type="password" |
196 |
| - placeholder="Enter your password" |
197 |
| - className="w-full" |
198 |
| - error={!!errors.password} |
199 |
| - disabled={isSubmitting || isRedirecting} |
200 |
| - /> |
201 |
| - {errors.password && ( |
202 |
| - <Text className="text-sm text-red-500 mt-1"> |
203 |
| - {errors.password.message} |
204 |
| - </Text> |
205 |
| - )} |
206 |
| - </div> |
207 |
| - |
208 |
| - <Button |
209 |
| - type="submit" |
210 |
| - size="lg" |
211 |
| - className="w-full bg-tremor-brand hover:bg-tremor-brand-emphasis text-tremor-brand-inverted" |
212 |
| - disabled={isSubmitting || isRedirecting} |
213 |
| - loading={isSubmitting || isRedirecting} |
214 |
| - > |
215 |
| - {isSubmitting |
216 |
| - ? "Signing in..." |
217 |
| - : isRedirecting |
218 |
| - ? "Redirecting..." |
219 |
| - : "Sign in"} |
220 |
| - </Button> |
221 |
| - |
222 |
| - {errors.root && ( |
223 |
| - <div className="w-full rounded-md bg-red-50 p-4"> |
224 |
| - <Text className="text-sm text-red-500 text-center"> |
225 |
| - {errors.root.message} |
226 |
| - </Text> |
227 |
| - </div> |
228 |
| - )} |
229 |
| - </form> |
| 153 | + <div className="space-y-2"> |
| 154 | + <Text className="text-tremor-default font-medium text-tremor-content-strong"> |
| 155 | + Password |
| 156 | + </Text> |
| 157 | + <TextInput |
| 158 | + {...register("password", { |
| 159 | + required: "Password is required", |
| 160 | + })} |
| 161 | + type="password" |
| 162 | + placeholder="Enter your password" |
| 163 | + className="w-full" |
| 164 | + error={!!errors.password} |
| 165 | + disabled={isSubmitting || isRedirecting} |
| 166 | + /> |
| 167 | + {errors.password && ( |
| 168 | + <Text className="text-sm text-red-500 mt-1"> |
| 169 | + {errors.password.message} |
| 170 | + </Text> |
| 171 | + )} |
230 | 172 | </div>
|
231 |
| - </Card> |
232 |
| - </div> |
| 173 | + |
| 174 | + <Button |
| 175 | + type="submit" |
| 176 | + size="lg" |
| 177 | + color="orange" |
| 178 | + variant="primary" |
| 179 | + className="w-full" |
| 180 | + disabled={isSubmitting || isRedirecting} |
| 181 | + loading={isSubmitting || isRedirecting} |
| 182 | + > |
| 183 | + {isSubmitting |
| 184 | + ? "Signing in..." |
| 185 | + : isRedirecting |
| 186 | + ? "Redirecting..." |
| 187 | + : "Sign in"} |
| 188 | + </Button> |
| 189 | + </form> |
| 190 | + </> |
233 | 191 | );
|
234 | 192 | }
|
235 | 193 |
|
236 |
| - return <>Redirecting to authentication...</>; |
| 194 | + return ( |
| 195 | + <Text className="h-full flex items-center justify-center text-tremor-title font-bold text-tremor-content-strong"> |
| 196 | + Redirecting to authentication... |
| 197 | + </Text> |
| 198 | + ); |
237 | 199 | }
|
0 commit comments