Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { useCallback } from "react";
import { Toggle } from "@/components/Toggle";
import { enableMultiRuleSelectionAction } from "@/utils/actions/rule";
import { toastError } from "@/components/Toast";
Expand All @@ -19,6 +20,7 @@ export function MultiRuleSetting() {
mutate();
},
onError: (error) => {
mutate();
toastError({
description: `There was an error: ${error.error.serverError || "Unknown error"}`,
});
Expand All @@ -28,6 +30,21 @@ export function MultiRuleSetting() {

const enabled = data?.multiRuleSelectionEnabled ?? false;

const handleToggle = useCallback(
(enable: boolean) => {
if (!data) return;

const optimisticData = {
...data,
multiRuleSelectionEnabled: enable,
};
mutate(optimisticData, false);

execute({ enable });
},
[data, mutate, execute],
);

return (
<SettingCard
title="Multi-rule selection"
Expand All @@ -41,7 +58,7 @@ export function MultiRuleSetting() {
<Toggle
name="multi-rule-selection"
enabled={enabled}
onChange={(enable) => execute({ enable })}
onChange={handleToggle}
disabled={isLoading}
/>
</LoadingContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function ReferralSignatureSetting() {
});
},
onError: (error) => {
mutate();
toastError({
description:
error.error.serverError ||
Expand All @@ -38,10 +39,18 @@ export function ReferralSignatureSetting() {
);

const handleToggle = useCallback(
async (enabled: boolean) => {
(enabled: boolean) => {
if (!data) return;

const optimisticData = {
...data,
includeReferralSignature: enabled,
};
mutate(optimisticData, false);

execute({ enabled });
},
[execute],
[data, mutate, execute],
);

if (env.NEXT_PUBLIC_DISABLE_REFERRAL_SIGNATURE) {
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.17.34
v2.17.35
Loading