Migrate route loaders and password flows to new client API

This commit is contained in:
Yurii Motov
2026-07-23 21:52:43 +02:00
parent 266a7a37c8
commit 865a31954f
4 changed files with 7 additions and 5 deletions
+3 -2
View File
@@ -11,7 +11,8 @@ import useAuth from "@/hooks/useAuth"
function getUsersQueryOptions() { function getUsersQueryOptions() {
return { return {
queryFn: () => UsersService.readUsers({ skip: 0, limit: 100 }), queryFn: async () =>
(await UsersService.readUsers({ query: { skip: 0, limit: 100 } })).data,
queryKey: ["users"], queryKey: ["users"],
} }
} }
@@ -19,7 +20,7 @@ function getUsersQueryOptions() {
export const Route = createFileRoute("/_layout/admin")({ export const Route = createFileRoute("/_layout/admin")({
component: Admin, component: Admin,
beforeLoad: async () => { beforeLoad: async () => {
const user = await UsersService.readUserMe() const { data: user } = await UsersService.readUserMe()
if (!user.is_superuser) { if (!user.is_superuser) {
throw redirect({ throw redirect({
to: "/", to: "/",
+2 -1
View File
@@ -11,7 +11,8 @@ import PendingItems from "@/components/Pending/PendingItems"
function getItemsQueryOptions() { function getItemsQueryOptions() {
return { return {
queryFn: () => ItemsService.readItems({ skip: 0, limit: 100 }), queryFn: async () =>
(await ItemsService.readItems({ query: { skip: 0, limit: 100 } })).data,
queryKey: ["items"], queryKey: ["items"],
} }
} }
+1 -1
View File
@@ -59,7 +59,7 @@ function RecoverPassword() {
const recoverPassword = async (data: FormData) => { const recoverPassword = async (data: FormData) => {
await LoginService.recoverPassword({ await LoginService.recoverPassword({
email: data.email, path: { email: data.email },
}) })
} }
+1 -1
View File
@@ -83,7 +83,7 @@ function ResetPassword() {
const mutation = useMutation({ const mutation = useMutation({
mutationFn: (data: { new_password: string; token: string }) => mutationFn: (data: { new_password: string; token: string }) =>
LoginService.resetPassword({ requestBody: data }), LoginService.resetPassword({ body: data }),
onSuccess: () => { onSuccess: () => {
showSuccessToast("Password updated successfully") showSuccessToast("Password updated successfully")
form.reset() form.reset()