mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 12:45:47 +00:00
chore: update to react query v5
This commit is contained in:
Binary file not shown.
@@ -14,7 +14,7 @@
|
|||||||
"@mantine/form": "^7.16.0",
|
"@mantine/form": "^7.16.0",
|
||||||
"@mantine/hooks": "^7.16.0",
|
"@mantine/hooks": "^7.16.0",
|
||||||
"@mantine/notifications": "^7.16.0",
|
"@mantine/notifications": "^7.16.0",
|
||||||
"@tanstack/react-query": "4",
|
"@tanstack/react-query": "5",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"i18next": "^25.0.0",
|
"i18next": "^25.0.0",
|
||||||
"i18next-browser-languagedetector": "^8.0.4",
|
"i18next-browser-languagedetector": "^8.0.4",
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import { LoginFormValues, loginSchema } from "../../schemas/login-schema";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
interface LoginFormProps {
|
interface LoginFormProps {
|
||||||
isLoading: boolean;
|
isPending: boolean;
|
||||||
onSubmit: (values: LoginFormValues) => void;
|
onSubmit: (values: LoginFormValues) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LoginForm = (props: LoginFormProps) => {
|
export const LoginForm = (props: LoginFormProps) => {
|
||||||
const { isLoading, onSubmit } = props;
|
const { isPending, onSubmit } = props;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
@@ -27,7 +27,7 @@ export const LoginForm = (props: LoginFormProps) => {
|
|||||||
label={t("loginUsername")}
|
label={t("loginUsername")}
|
||||||
placeholder="username"
|
placeholder="username"
|
||||||
required
|
required
|
||||||
disabled={isLoading}
|
disabled={isPending}
|
||||||
key={form.key("username")}
|
key={form.key("username")}
|
||||||
{...form.getInputProps("username")}
|
{...form.getInputProps("username")}
|
||||||
/>
|
/>
|
||||||
@@ -36,11 +36,11 @@ export const LoginForm = (props: LoginFormProps) => {
|
|||||||
placeholder="password"
|
placeholder="password"
|
||||||
required
|
required
|
||||||
mt="md"
|
mt="md"
|
||||||
disabled={isLoading}
|
disabled={isPending}
|
||||||
key={form.key("password")}
|
key={form.key("password")}
|
||||||
{...form.getInputProps("password")}
|
{...form.getInputProps("password")}
|
||||||
/>
|
/>
|
||||||
<Button fullWidth mt="xl" type="submit" loading={isLoading}>
|
<Button fullWidth mt="xl" type="submit" loading={isPending}>
|
||||||
{t("loginSubmit")}
|
{t("loginSubmit")}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import { OAuthIcon } from "../../icons/oauth";
|
|||||||
|
|
||||||
interface OAuthButtonsProps {
|
interface OAuthButtonsProps {
|
||||||
oauthProviders: string[];
|
oauthProviders: string[];
|
||||||
isLoading: boolean;
|
isPending: boolean;
|
||||||
mutate: (provider: string) => void;
|
mutate: (provider: string) => void;
|
||||||
genericName: string;
|
genericName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OAuthButtons = (props: OAuthButtonsProps) => {
|
export const OAuthButtons = (props: OAuthButtonsProps) => {
|
||||||
const { oauthProviders, isLoading, genericName, mutate } = props;
|
const { oauthProviders, isPending, genericName, mutate } = props;
|
||||||
return (
|
return (
|
||||||
<Grid mb="md" mt="md" align="center" justify="center">
|
<Grid mb="md" mt="md" align="center" justify="center">
|
||||||
{oauthProviders.includes("google") && (
|
{oauthProviders.includes("google") && (
|
||||||
@@ -21,7 +21,7 @@ export const OAuthButtons = (props: OAuthButtonsProps) => {
|
|||||||
leftSection={<GoogleIcon style={{ width: 14, height: 14 }} />}
|
leftSection={<GoogleIcon style={{ width: 14, height: 14 }} />}
|
||||||
variant="default"
|
variant="default"
|
||||||
onClick={() => mutate("google")}
|
onClick={() => mutate("google")}
|
||||||
loading={isLoading}
|
loading={isPending}
|
||||||
>
|
>
|
||||||
Google
|
Google
|
||||||
</Button>
|
</Button>
|
||||||
@@ -34,7 +34,7 @@ export const OAuthButtons = (props: OAuthButtonsProps) => {
|
|||||||
leftSection={<GithubIcon style={{ width: 14, height: 14 }} />}
|
leftSection={<GithubIcon style={{ width: 14, height: 14 }} />}
|
||||||
variant="default"
|
variant="default"
|
||||||
onClick={() => mutate("github")}
|
onClick={() => mutate("github")}
|
||||||
loading={isLoading}
|
loading={isPending}
|
||||||
>
|
>
|
||||||
Github
|
Github
|
||||||
</Button>
|
</Button>
|
||||||
@@ -47,7 +47,7 @@ export const OAuthButtons = (props: OAuthButtonsProps) => {
|
|||||||
leftSection={<OAuthIcon style={{ width: 14, height: 14 }} />}
|
leftSection={<OAuthIcon style={{ width: 14, height: 14 }} />}
|
||||||
variant="default"
|
variant="default"
|
||||||
onClick={() => mutate("generic")}
|
onClick={() => mutate("generic")}
|
||||||
loading={isLoading}
|
loading={isPending}
|
||||||
>
|
>
|
||||||
{genericName}
|
{genericName}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ type FormValues = z.infer<typeof schema>;
|
|||||||
|
|
||||||
interface TotpFormProps {
|
interface TotpFormProps {
|
||||||
onSubmit: (values: FormValues) => void;
|
onSubmit: (values: FormValues) => void;
|
||||||
isLoading: boolean;
|
isPending: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TotpForm = (props: TotpFormProps) => {
|
export const TotpForm = (props: TotpFormProps) => {
|
||||||
const { onSubmit, isLoading } = props;
|
const { onSubmit, isPending } = props;
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
mode: "uncontrolled",
|
mode: "uncontrolled",
|
||||||
@@ -32,7 +32,7 @@ export const TotpForm = (props: TotpFormProps) => {
|
|||||||
placeholder=""
|
placeholder=""
|
||||||
{...form.getInputProps("code")}
|
{...form.getInputProps("code")}
|
||||||
/>
|
/>
|
||||||
<Button type="submit" mt="xl" loading={isLoading} fullWidth>
|
<Button type="submit" mt="xl" loading={isPending} fullWidth>
|
||||||
Verify
|
Verify
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import React, { createContext, useContext } from "react";
|
import React, { createContext, useContext } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { AppContextSchemaType } from "../schemas/app-context-schema";
|
import { AppContextSchemaType } from "../schemas/app-context-schema";
|
||||||
@@ -14,7 +14,7 @@ export const AppContextProvider = ({
|
|||||||
data: userContext,
|
data: userContext,
|
||||||
isLoading,
|
isLoading,
|
||||||
error,
|
error,
|
||||||
} = useQuery({
|
} = useSuspenseQuery({
|
||||||
queryKey: ["appContext"],
|
queryKey: ["appContext"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const res = await axios.get("/api/app");
|
const res = await axios.get("/api/app");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import React, { createContext, useContext } from "react";
|
import React, { createContext, useContext } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { UserContextSchemaType } from "../schemas/user-context-schema";
|
import { UserContextSchemaType } from "../schemas/user-context-schema";
|
||||||
@@ -14,7 +14,7 @@ export const UserContextProvider = ({
|
|||||||
data: userContext,
|
data: userContext,
|
||||||
isLoading,
|
isLoading,
|
||||||
error,
|
error,
|
||||||
} = useQuery({
|
} = useSuspenseQuery({
|
||||||
queryKey: ["userContext"],
|
queryKey: ["userContext"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const res = await axios.get("/api/user");
|
const res = await axios.get("/api/user");
|
||||||
|
|||||||
@@ -19,13 +19,7 @@ import { TotpPage } from "./pages/totp-page.tsx";
|
|||||||
import { AppContextProvider } from "./context/app-context.tsx";
|
import { AppContextProvider } from "./context/app-context.tsx";
|
||||||
import "./lib/i18n/i18n.ts";
|
import "./lib/i18n/i18n.ts";
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient();
|
||||||
defaultOptions: {
|
|
||||||
queries: {
|
|
||||||
suspense: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export const LoginPage = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
<OAuthButtons
|
<OAuthButtons
|
||||||
oauthProviders={oauthProviders}
|
oauthProviders={oauthProviders}
|
||||||
isLoading={loginOAuthMutation.isLoading}
|
isPending={loginOAuthMutation.isPending}
|
||||||
mutate={loginOAuthMutation.mutate}
|
mutate={loginOAuthMutation.mutate}
|
||||||
genericName={genericName}
|
genericName={genericName}
|
||||||
/>
|
/>
|
||||||
@@ -128,7 +128,7 @@ export const LoginPage = () => {
|
|||||||
)}
|
)}
|
||||||
{configuredProviders.includes("username") && (
|
{configuredProviders.includes("username") && (
|
||||||
<LoginForm
|
<LoginForm
|
||||||
isLoading={loginMutation.isLoading}
|
isPending={loginMutation.isPending}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export const LogoutPage = () => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
mt="xl"
|
mt="xl"
|
||||||
onClick={() => logoutMutation.mutate()}
|
onClick={() => logoutMutation.mutate()}
|
||||||
loading={logoutMutation.isLoading}
|
loading={logoutMutation.isPending}
|
||||||
>
|
>
|
||||||
{t("logoutTitle")}
|
{t("logoutTitle")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const TotpPage = () => {
|
|||||||
{t("totpTitle")}
|
{t("totpTitle")}
|
||||||
</Text>
|
</Text>
|
||||||
<TotpForm
|
<TotpForm
|
||||||
isLoading={totpMutation.isLoading}
|
isPending={totpMutation.isPending}
|
||||||
onSubmit={(values) => totpMutation.mutate(values)}
|
onSubmit={(values) => totpMutation.mutate(values)}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
Reference in New Issue
Block a user