fix: replay pending action after login
This commit is contained in:
@@ -16,6 +16,7 @@ import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { currentUser } from "@/lib/mock"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
import { useLoginDialogStore } from "@/store/login-dialog"
|
||||
|
||||
const loginSchema = z.object({
|
||||
phone: z.string().min(11, "请输入正确的手机号"),
|
||||
@@ -30,6 +31,7 @@ interface LoginDialogProps {
|
||||
export function LoginDialog({ open, onOpenChange }: LoginDialogProps) {
|
||||
const router = useRouter()
|
||||
const { login } = useAuthStore()
|
||||
const consumePendingAction = useLoginDialogStore((state) => state.consumePendingAction)
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
@@ -41,6 +43,7 @@ export function LoginDialog({ open, onOpenChange }: LoginDialogProps) {
|
||||
const onSubmit = async (_data: z.infer<typeof loginSchema>) => {
|
||||
await new Promise((r) => setTimeout(r, 500))
|
||||
login(currentUser, ["consumer", "player", "owner"])
|
||||
consumePendingAction()
|
||||
onOpenChange(false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user