2022-05-25 15:21:18 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-07-22 17:27:06 +00:00
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2022-11-23 02:55:25 +00:00
|
|
|
import { Badge, Button, showToast } from "@calcom/ui";
|
2022-05-25 15:21:18 +00:00
|
|
|
|
|
|
|
const DisableUserImpersonation = ({ disableImpersonation }: { disableImpersonation: boolean }) => {
|
|
|
|
const utils = trpc.useContext();
|
|
|
|
|
|
|
|
const { t } = useLocale();
|
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const mutation = trpc.viewer.updateProfile.useMutation({
|
2022-05-25 15:21:18 +00:00
|
|
|
onSuccess: async () => {
|
|
|
|
showToast(t("your_user_profile_updated_successfully"), "success");
|
2022-11-10 23:40:01 +00:00
|
|
|
await utils.viewer.me.invalidate();
|
2022-05-25 15:21:18 +00:00
|
|
|
},
|
|
|
|
async onSettled() {
|
2022-11-10 23:40:01 +00:00
|
|
|
await utils.viewer.public.i18n.invalidate();
|
2022-05-25 15:21:18 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="flex flex-col justify-between pt-9 pl-2 sm:flex-row">
|
|
|
|
<div>
|
|
|
|
<div className="flex flex-row items-center">
|
2023-04-05 18:14:46 +00:00
|
|
|
<h2 className="font-cal text-emphasis text-lg font-medium leading-6">
|
2022-05-25 15:21:18 +00:00
|
|
|
{t("user_impersonation_heading")}
|
|
|
|
</h2>
|
|
|
|
<Badge className="ml-2 text-xs" variant={!disableImpersonation ? "success" : "gray"}>
|
|
|
|
{!disableImpersonation ? t("enabled") : t("disabled")}
|
|
|
|
</Badge>
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<p className="text-subtle mt-1 text-sm">{t("user_impersonation_description")}</p>
|
2022-05-25 15:21:18 +00:00
|
|
|
</div>
|
|
|
|
<div className="mt-5 sm:mt-0 sm:self-center">
|
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
color="secondary"
|
|
|
|
onClick={() =>
|
|
|
|
!disableImpersonation
|
|
|
|
? mutation.mutate({ disableImpersonation: true })
|
|
|
|
: mutation.mutate({ disableImpersonation: false })
|
|
|
|
}>
|
|
|
|
{!disableImpersonation ? t("disable") : t("enable")}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DisableUserImpersonation;
|