mirror of
https://github.com/idanoo/autobrr
synced 2025-07-26 10:19:13 +00:00
refactor(web): replace pkg react-query with tanstack/react-query (#868)
* refactor: move to tanstack/react-query and fix cache * refactor(releases): move to tanstack/react-query * refactor(logs): move to tanstack/react-query * refactor(base): move to tanstack/react-query * refactor(base): move to tanstack/react-query * refactor(dashboard): move to tanstack/react-query * refactor(auth): move to tanstack/react-query * refactor(filters): move to tanstack/react-query * refactor(settings): move to tanstack/react-query * chore(pkg): add tanstack/react-query * refactor(filters): move to tanstack/react-query * refactor: move to tanstack/react-query * refactor: invalidate queries * chore(pkg): remove old react-query * chore: change imports to root prefixes * build: remove needs web from test * set enableReinitialize to true to fix formik caching issues * fix all property for apiKeys const * fix toast when enabling/disabling feed --------- Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com>
This commit is contained in:
parent
0be92bef65
commit
6e5385a490
54 changed files with 1101 additions and 1117 deletions
|
@ -1,14 +1,15 @@
|
|||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useMutation } from "react-query";
|
||||
import logo from "../../logo.png";
|
||||
import { APIClient } from "../../api/APIClient";
|
||||
import { AuthContext } from "../../utils/Context";
|
||||
import { PasswordInput, TextInput } from "../../components/inputs/text";
|
||||
import { Tooltip } from "react-tooltip";
|
||||
import Toast from "@/components/notifications/Toast";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import toast from "react-hot-toast";
|
||||
import { Tooltip } from "react-tooltip";
|
||||
|
||||
import logo from "@app/logo.png";
|
||||
import { APIClient } from "@api/APIClient";
|
||||
import { AuthContext } from "@utils/Context";
|
||||
import { PasswordInput, TextInput } from "@components/inputs/text";
|
||||
import Toast from "@components/notifications/Toast";
|
||||
|
||||
type LoginFormFields = {
|
||||
username: string;
|
||||
|
@ -37,23 +38,21 @@ export const Login = () => {
|
|||
.catch(() => { /*don't log to console PAHLLEEEASSSE*/ });
|
||||
}, []);
|
||||
|
||||
const loginMutation = useMutation(
|
||||
(data: LoginFormFields) => APIClient.auth.login(data.username, data.password),
|
||||
{
|
||||
onSuccess: (_, variables: LoginFormFields) => {
|
||||
setAuthContext({
|
||||
username: variables.username,
|
||||
isLoggedIn: true
|
||||
});
|
||||
navigate("/");
|
||||
},
|
||||
onError: () => {
|
||||
toast.custom((t) => (
|
||||
<Toast type="error" body="Wrong password or username!" t={t} />
|
||||
));
|
||||
}
|
||||
const loginMutation = useMutation({
|
||||
mutationFn: (data: LoginFormFields) => APIClient.auth.login(data.username, data.password),
|
||||
onSuccess: (_, variables: LoginFormFields) => {
|
||||
setAuthContext({
|
||||
username: variables.username,
|
||||
isLoggedIn: true
|
||||
});
|
||||
navigate("/");
|
||||
},
|
||||
onError: () => {
|
||||
toast.custom((t) => (
|
||||
<Toast type="error" body="Wrong password or username!" t={t} />
|
||||
));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const onSubmit = (data: LoginFormFields) => loginMutation.mutate(data);
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Form, Formik } from "formik";
|
||||
import { useMutation } from "react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { APIClient } from "../../api/APIClient";
|
||||
|
||||
import { TextField, PasswordField } from "../../components/inputs";
|
||||
import logo from "../../logo.png";
|
||||
import { APIClient } from "@api/APIClient";
|
||||
import { TextField, PasswordField } from "@components/inputs";
|
||||
import logo from "@app/logo.png";
|
||||
|
||||
interface InputValues {
|
||||
username: string;
|
||||
|
@ -33,10 +33,10 @@ export const Onboarding = () => {
|
|||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const mutation = useMutation(
|
||||
(data: InputValues) => APIClient.auth.onboard(data.username, data.password1),
|
||||
{ onSuccess: () => navigate("/") }
|
||||
);
|
||||
const mutation = useMutation({
|
||||
mutationFn: (data: InputValues) => APIClient.auth.onboard(data.username, data.password1),
|
||||
onSuccess: () => navigate("/")
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue