feat: add setting to disable phone only sms notification (#21038)
* feat: add setting to disable phone only sms notification * Update apps/web/public/static/locales/en/common.json Co-authored-by: Syed Ali Shahbaz <[email protected]> --------- Co-authored-by: Syed Ali Shahbaz <[email protected]>
This commit is contained in:
1 parent
99dc5837f5
commit
d9b3f8657f
9 files changed
+88
-10
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
"use client"
|
||||
import { useState } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc";
|
||||
import { trpc } from "@calcom/trpc";
|
||||
import { SettingsToggle } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
interface GeneralViewProps {
|
||||
currentOrg: RouterOutputs["viewer"]["organizations"]["listCurrent"];
|
||||
isAdminOrOwner: boolean;
|
||||
}
|
||||
|
||||
export const DisablePhoneOnlySMSNotificationsSwitch = ({ currentOrg, isAdminOrOwner }: GeneralViewProps) => {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
const [disablePhoneOnlySMSNotificationsActive, setDisablePhoneOnlySMSNotificationsActive] = useState(
|
||||
!!currentOrg.organizationSettings.disablePhoneOnlySMSNotifications
|
||||
);
|
||||
|
||||
const mutation = trpc.viewer.organizations.update.useMutation({
|
||||
onSuccess: async () => {
|
||||
showToast(t("settings_updated_successfully"), "success");
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_updating_settings"), "error");
|
||||
},
|
||||
onSettled: () => {
|
||||
utils.viewer.organizations.listCurrent.invalidate();
|
||||
},
|
||||
});
|
||||
|
||||
if (!isAdminOrOwner) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsToggle
|
||||
toggleSwitchAtTheEnd={true}
|
||||
title={t("organization_disable_phone_only_sms_notifications_switch_title")}
|
||||
disabled={mutation?.isPending}
|
||||
description={t("organization_disable_phone_only_sms_notifications_switch_description")}
|
||||
checked={disablePhoneOnlySMSNotificationsActive}
|
||||
onCheckedChange={(checked) => {
|
||||
mutation.mutate({
|
||||
disablePhoneOnlySMSNotifications: checked,
|
||||
});
|
||||
setDisablePhoneOnlySMSNotificationsActive(checked);
|
||||
}}
|
||||
switchContainerClassName="mt-6"
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -21,6 +21,7 @@ import { Select } from "@calcom/ui/components/form";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { DisablePhoneOnlySMSNotificationsSwitch } from "../components/DisablePhoneOnlySMSNotificationsSwitch";
|
||||
import { LockEventTypeSwitch } from "../components/LockEventTypeSwitch";
|
||||
import { NoSlotsNotificationSwitch } from "../components/NoSlotsNotificationSwitch";
|
||||
|
||||
@@ -82,6 +83,7 @@ const OrgGeneralView = () => {
|
||||
|
||||
<LockEventTypeSwitch currentOrg={currentOrg} isAdminOrOwner={!!isAdminOrOwner} />
|
||||
<NoSlotsNotificationSwitch currentOrg={currentOrg} isAdminOrOwner={!!isAdminOrOwner} />
|
||||
<DisablePhoneOnlySMSNotificationsSwitch currentOrg={currentOrg} isAdminOrOwner={!!isAdminOrOwner} />
|
||||
</LicenseRequired>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user