force router refresh on save closes #198

This commit is contained in:
Milo Schwartz
2025-02-14 12:27:03 -05:00
parent f61d442989
commit 4c1366ef91
3 changed files with 15 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ import {
} from "@app/components/Settings";
import { SwitchInput } from "@app/components/SwitchInput";
import { InfoPopup } from "@app/components/ui/info-popup";
import { useRouter } from "next/navigation";
const UsersRolesFormSchema = z.object({
roles: z.array(
@@ -82,6 +83,7 @@ export default function ResourceAuthenticationPage() {
const { env } = useEnvContext();
const api = createApiClient({ env });
const router = useRouter();
const [pageLoading, setPageLoading] = useState(true);
@@ -236,6 +238,7 @@ export default function ResourceAuthenticationPage() {
title: "Saved successfully",
description: "Whitelist settings have been saved"
});
router.refresh();
} catch (e) {
console.error(e);
toast({
@@ -283,6 +286,7 @@ export default function ResourceAuthenticationPage() {
title: "Saved successfully",
description: "Authentication settings have been saved"
});
router.refresh();
} catch (e) {
console.error(e);
toast({
@@ -314,6 +318,7 @@ export default function ResourceAuthenticationPage() {
updateAuthInfo({
password: false
});
router.refresh();
})
.catch((e) => {
toast({
@@ -344,6 +349,7 @@ export default function ResourceAuthenticationPage() {
updateAuthInfo({
pincode: false
});
router.refresh();
})
.catch((e) => {
toast({

View File

@@ -64,6 +64,7 @@ import {
import { SwitchInput } from "@app/components/SwitchInput";
import { useSiteContext } from "@app/hooks/useSiteContext";
import { InfoPopup } from "@app/components/ui/info-popup";
import { useRouter } from "next/navigation";
// Regular expressions for validation
const DOMAIN_REGEX =
@@ -125,6 +126,7 @@ export default function ReverseProxyTargets(props: {
const [loading, setLoading] = useState(false);
const [pageLoading, setPageLoading] = useState(true);
const router = useRouter();
const addTargetForm = useForm({
resolver: zodResolver(addTargetSchema),
@@ -299,6 +301,7 @@ export default function ReverseProxyTargets(props: {
});
setTargetsToRemove([]);
router.refresh();
} catch (err) {
console.error(err);
toast({
@@ -339,6 +342,7 @@ export default function ReverseProxyTargets(props: {
title: "SSL Configuration",
description: "SSL configuration updated successfully"
});
router.refresh();
}
}

View File

@@ -71,6 +71,7 @@ import {
isValidUrlGlobPattern
} from "@server/lib/validators";
import { Switch } from "@app/components/ui/switch";
import { useRouter } from "next/navigation";
// Schema for rule validation
const addRuleSchema = z.object({
@@ -107,6 +108,7 @@ export default function ResourceRules(props: {
const [loading, setLoading] = useState(false);
const [pageLoading, setPageLoading] = useState(true);
const [rulesEnabled, setRulesEnabled] = useState(resource.applyRules);
const router = useRouter();
const addRuleForm = useForm({
resolver: zodResolver(addRuleSchema),
@@ -253,6 +255,7 @@ export default function ResourceRules(props: {
title: "Enable Rules",
description: "Rule evaluation has been updated"
});
router.refresh();
}
}
@@ -370,6 +373,7 @@ export default function ResourceRules(props: {
});
setRulesToRemove([]);
router.refresh();
} catch (err) {
console.error(err);
toast({
@@ -590,7 +594,7 @@ export default function ResourceRules(props: {
<SwitchInput
id="rules-toggle"
label="Enable Rules"
defaultChecked={resource.applyRules}
defaultChecked={rulesEnabled}
onCheckedChange={async (val) => {
await saveApplyRules(val);
}}