refactor(auth): unify current user state usage across UI
This commit is contained in:
@@ -9,7 +9,7 @@ import { z } from "zod"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { currentUser } from "@/lib/mock"
|
||||
import { getCurrentUserForLogin } from "@/lib/api"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
|
||||
const loginSchema = z.object({
|
||||
@@ -30,7 +30,7 @@ export default function LoginPage() {
|
||||
|
||||
const onSubmit = async (_data: z.infer<typeof loginSchema>) => {
|
||||
await new Promise((r) => setTimeout(r, 500))
|
||||
login(currentUser, ["consumer", "player", "owner"])
|
||||
login(getCurrentUserForLogin(), ["consumer", "player", "owner"])
|
||||
router.push("/")
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { z } from "zod"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { currentUser } from "@/lib/mock"
|
||||
import { getCurrentUserForLogin } from "@/lib/api"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
|
||||
const registerSchema = z
|
||||
@@ -37,7 +37,7 @@ export default function RegisterPage() {
|
||||
|
||||
const onSubmit = async (_data: z.infer<typeof registerSchema>) => {
|
||||
await new Promise((r) => setTimeout(r, 500))
|
||||
login(currentUser, ["consumer"])
|
||||
login(getCurrentUserForLogin(), ["consumer"])
|
||||
router.push("/")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user