mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-28 04:41:49 +01:00
Attempt to send proxy to backend during onboarding.
This commit is contained in:
parent
e9e2f3f470
commit
8e22d4f96e
@ -2,6 +2,7 @@ import { useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAsyncFn } from "react-use";
|
import { useAsyncFn } from "react-use";
|
||||||
|
|
||||||
|
import { updateSettings } from "@/backend/accounts/settings";
|
||||||
import { singularProxiedFetch } from "@/backend/helpers/fetch";
|
import { singularProxiedFetch } from "@/backend/helpers/fetch";
|
||||||
import { Button } from "@/components/buttons/Button";
|
import { Button } from "@/components/buttons/Button";
|
||||||
import { Stepper } from "@/components/layout/Stepper";
|
import { Stepper } from "@/components/layout/Stepper";
|
||||||
@ -10,6 +11,7 @@ import { AuthInputBox } from "@/components/text-inputs/AuthInputBox";
|
|||||||
import { Divider } from "@/components/utils/Divider";
|
import { Divider } from "@/components/utils/Divider";
|
||||||
import { ErrorLine } from "@/components/utils/ErrorLine";
|
import { ErrorLine } from "@/components/utils/ErrorLine";
|
||||||
import { Heading2, Paragraph } from "@/components/utils/Text";
|
import { Heading2, Paragraph } from "@/components/utils/Text";
|
||||||
|
import { useBackendUrl } from "@/hooks/auth/useBackendUrl";
|
||||||
import { MinimalPageLayout } from "@/pages/layouts/MinimalPageLayout";
|
import { MinimalPageLayout } from "@/pages/layouts/MinimalPageLayout";
|
||||||
import {
|
import {
|
||||||
useNavigateOnboarding,
|
useNavigateOnboarding,
|
||||||
@ -29,6 +31,8 @@ export function OnboardingProxyPage() {
|
|||||||
const [url, setUrl] = useState("");
|
const [url, setUrl] = useState("");
|
||||||
const setProxySet = useAuthStore((s) => s.setProxySet);
|
const setProxySet = useAuthStore((s) => s.setProxySet);
|
||||||
const installLink = conf().ONBOARDING_PROXY_INSTALL_LINK;
|
const installLink = conf().ONBOARDING_PROXY_INSTALL_LINK;
|
||||||
|
const backendUrl = useBackendUrl();
|
||||||
|
const account = useAuthStore((s) => s.account);
|
||||||
|
|
||||||
const [{ loading, error }, test] = useAsyncFn(async () => {
|
const [{ loading, error }, test] = useAsyncFn(async () => {
|
||||||
if (!url.startsWith("http"))
|
if (!url.startsWith("http"))
|
||||||
@ -38,6 +42,13 @@ export function OnboardingProxyPage() {
|
|||||||
if (res.url !== testUrl)
|
if (res.url !== testUrl)
|
||||||
throw new Error("onboarding.proxy.input.errorNotProxy");
|
throw new Error("onboarding.proxy.input.errorNotProxy");
|
||||||
setProxySet([url]);
|
setProxySet([url]);
|
||||||
|
|
||||||
|
if (account) {
|
||||||
|
await updateSettings(backendUrl, account, {
|
||||||
|
proxyUrls: [url],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
completeAndRedirect();
|
completeAndRedirect();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("onboarding.proxy.input.errorConnection");
|
throw new Error("onboarding.proxy.input.errorConnection");
|
||||||
|
Loading…
Reference in New Issue
Block a user