Compare commits

..

3 Commits

Author SHA1 Message Date
9f1e38ce47 Fixes login redirection 2025-06-13 11:21:23 -07:00
c28073d516 Revert "Start supporting edit forms for any document type."
This reverts commit 6845bd06bf.
2025-06-13 11:16:37 -07:00
6845bd06bf Start supporting edit forms for any document type. 2025-06-13 11:14:58 -07:00

View File

@@ -3,6 +3,7 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import type { ReactNode } from "react";
import { pb } from "@/lib/pocketbase";
import type { AuthRecord } from "pocketbase";
import { useNavigate } from "@tanstack/react-router";
/**
* Represents the shape of the authenticated user object from PocketBase.
@@ -43,6 +44,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
queryKey: ["auth", "user"],
queryFn: fetchUser,
});
const navigate = useNavigate();
const loginMutation = useMutation({
mutationFn: async ({
@@ -92,6 +94,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const login = useCallback(
async (email: string, password: string) => {
await loginMutation.mutateAsync({ email, password });
navigate({ to: "/campaigns" });
},
[loginMutation],
);
@@ -99,12 +102,14 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const signup = useCallback(
async (email: string, password: string, passwordConfirm: string) => {
await signupMutation.mutateAsync({ email, password, passwordConfirm });
navigate({ to: "/campaigns" });
},
[signupMutation],
);
const logout = useCallback(async () => {
await logoutMutation.mutateAsync();
navigate({ to: "/" });
}, [logoutMutation]);
return (