feat: redirect to index after add account

This commit is contained in:
reya
2024-05-29 14:41:33 +07:00
parent 41b66b18f5
commit 70c5143445
6 changed files with 16 additions and 23 deletions

View File

@@ -9,7 +9,7 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
export const Route = createFileRoute("/auth/new/$account/backup")({
export const Route = createFileRoute("/auth/$account/backup")({
component: Screen,
});
@@ -33,8 +33,7 @@ function Screen() {
}
return navigate({
to: "/auth/$account/settings",
params: { account },
to: "/auth/settings",
});
}

View File

@@ -45,7 +45,7 @@ function Screen() {
if (eventId) {
navigate({
to: "/auth/new/$account/backup",
to: "/auth/$account/backup",
params: { account: account.npub },
replace: true,
});

View File

@@ -28,8 +28,7 @@ function Screen() {
if (npub) {
navigate({
to: "/auth/$account/settings",
params: { account: npub },
to: "/auth/settings",
replace: true,
});
}

View File

@@ -27,8 +27,7 @@ function Screen() {
if (npub) {
navigate({
to: "/auth/$account/settings",
params: { account: npub },
to: "/auth/settings",
replace: true,
});
}

View File

@@ -8,7 +8,7 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
export const Route = createFileRoute("/auth/$account/settings")({
export const Route = createFileRoute("/auth/settings")({
beforeLoad: async () => {
const settings = await NostrQuery.getSettings();
return { settings };
@@ -18,14 +18,14 @@ export const Route = createFileRoute("/auth/$account/settings")({
});
function Screen() {
const navigate = Route.useNavigate();
const { account } = Route.useParams();
const { settings } = Route.useRouteContext();
const { t } = useTranslation();
const [newSettings, setNewSettings] = useState(settings);
const [loading, setLoading] = useState(false);
const navigate = Route.useNavigate();
const toggleNofitication = async () => {
await requestPermission();
setNewSettings((prev) => ({
@@ -72,8 +72,7 @@ function Screen() {
if (eventId) {
return navigate({
to: "/$account/home",
params: { account },
to: "/",
replace: true,
});
}