Skip to content

Commit e449e3d

Browse files
committed
Fix remaining type issues
1 parent 1262f7b commit e449e3d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

site/src/pages/DeploySettingsPage/NotificationsPage/NotificationsPage.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
systemNotificationTemplatesByGroup,
1616
updateNotificationTemplateMethod,
1717
} from "api/queries/notifications";
18+
import type { NotificationTemplateMethod } from "api/typesGenerated";
1819
import { Alert } from "components/Alert/Alert";
1920
import { displaySuccess } from "components/GlobalSnackbar/utils";
2021
import { Loader } from "components/Loader/Loader";
@@ -26,8 +27,8 @@ import { useDeploySettings } from "../DeploySettingsLayout";
2627
type MethodToggleGroupProps = {
2728
templateId: string;
2829
value: string;
29-
available: readonly string[];
30-
defaultMethod: string;
30+
available: readonly NotificationTemplateMethod[];
31+
defaultMethod: NotificationTemplateMethod;
3132
};
3233

3334
const MethodToggleGroup: FC<MethodToggleGroupProps> = ({
@@ -39,7 +40,7 @@ const MethodToggleGroup: FC<MethodToggleGroupProps> = ({
3940
const updateMethodMutation = useMutation(
4041
updateNotificationTemplateMethod(templateId),
4142
);
42-
const options = ["", ...available];
43+
const options: NotificationTemplateMethod[] = ["", ...available];
4344

4445
return (
4546
<ToggleButtonGroup
@@ -49,6 +50,12 @@ const MethodToggleGroup: FC<MethodToggleGroupProps> = ({
4950
aria-label="Notification method"
5051
css={styles.toggleGroup}
5152
onChange={async (_, method) => {
53+
// Retain the value if the user clicks the same button, ensuring
54+
// at least one value remains selected.
55+
if (method === value) {
56+
return;
57+
}
58+
5259
await updateMethodMutation.mutateAsync({
5360
method,
5461
});

0 commit comments

Comments
 (0)