mirror of
https://gitlab.massbug.com/massbug/judge4c.git
synced 2025-07-04 15:22:25 +00:00
refactor(auth): update sign-in and sign-up cards to use loading states
This commit is contained in:
parent
afb1b05c0a
commit
40636d2d52
@ -1,3 +1,5 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {
|
import {
|
||||||
@ -19,7 +21,7 @@ import { Separator } from "@/components/ui/separator";
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
|
||||||
export const SignInCard = () => {
|
export const SignInCard = () => {
|
||||||
const { mutate } = useLogin();
|
const { mutate, isPending } = useLogin();
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof loginSchema>>({
|
const form = useForm<z.infer<typeof loginSchema>>({
|
||||||
resolver: zodResolver(loginSchema),
|
resolver: zodResolver(loginSchema),
|
||||||
@ -78,7 +80,7 @@ export const SignInCard = () => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Button disabled={false} size="lg" className="w-full">
|
<Button disabled={isPending} size="lg" className="w-full">
|
||||||
Login
|
Login
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
@ -89,7 +91,7 @@ export const SignInCard = () => {
|
|||||||
</div>
|
</div>
|
||||||
<CardContent className="p-7 flex flex-col gap-y-4">
|
<CardContent className="p-7 flex flex-col gap-y-4">
|
||||||
<Button
|
<Button
|
||||||
disabled={false}
|
disabled={isPending}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
@ -98,7 +100,7 @@ export const SignInCard = () => {
|
|||||||
Login with Google
|
Login with Google
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
disabled={false}
|
disabled={isPending}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {
|
import {
|
||||||
@ -25,7 +27,7 @@ import { Separator } from "@/components/ui/separator";
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
|
||||||
export const SignUpCard = () => {
|
export const SignUpCard = () => {
|
||||||
const { mutate } = useRegister();
|
const { mutate, isPending } = useRegister();
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof registerSchema>>({
|
const form = useForm<z.infer<typeof registerSchema>>({
|
||||||
resolver: zodResolver(registerSchema),
|
resolver: zodResolver(registerSchema),
|
||||||
@ -113,8 +115,8 @@ export const SignUpCard = () => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Button disabled={false} size="lg" className="w-full">
|
<Button disabled={isPending} size="lg" className="w-full">
|
||||||
Login
|
Register
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
@ -124,7 +126,7 @@ export const SignUpCard = () => {
|
|||||||
</div>
|
</div>
|
||||||
<CardContent className="p-7 flex flex-col gap-y-4">
|
<CardContent className="p-7 flex flex-col gap-y-4">
|
||||||
<Button
|
<Button
|
||||||
disabled={false}
|
disabled={isPending}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
@ -133,7 +135,7 @@ export const SignUpCard = () => {
|
|||||||
Login with Google
|
Login with Google
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
disabled={false}
|
disabled={isPending}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
Loading…
Reference in New Issue
Block a user