mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-01 00:06:38 +00:00
add credenza
This commit is contained in:
@@ -42,6 +42,7 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
@@ -53,6 +54,9 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
||||
|
||||
async function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
const { email, password } = values;
|
||||
|
||||
setLoading(true);
|
||||
|
||||
const res = await api
|
||||
.post<AxiosResponse<LoginResponse>>("/auth/login", {
|
||||
email,
|
||||
@@ -86,6 +90,8 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
||||
router.push("/");
|
||||
}
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -140,7 +146,7 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
||||
<AlertDescription>{error}</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
<Button type="submit" className="w-full">
|
||||
<Button type="submit" className="w-full" loading={loading}>
|
||||
Login
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
@@ -46,6 +46,7 @@ const formSchema = z
|
||||
export default function SignupForm({ redirect }: SignupFormProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
@@ -59,6 +60,8 @@ export default function SignupForm({ redirect }: SignupFormProps) {
|
||||
|
||||
async function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
const { email, password } = values;
|
||||
|
||||
setLoading(true);
|
||||
const res = await api
|
||||
.put<AxiosResponse<SignUpResponse>>("/auth/signup", {
|
||||
email,
|
||||
@@ -92,6 +95,8 @@ export default function SignupForm({ redirect }: SignupFormProps) {
|
||||
router.push("/");
|
||||
}
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user