+9








e044f963f8
Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: MuriloAmarals <muralha2000@gmail.com> Co-authored-by: Murilo Amaral <87545137+MuriloAmarals@users.noreply.github.com> Co-authored-by: Rubens Rafael <70234898+RubensRafael@users.noreply.github.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: Rafael Toledo <87545086+Toledodev@users.noreply.github.com> Co-authored-by: gitstart <gitstart@gitstart.com> Co-authored-by: Rafael <rafael.toledo@engenharia.ufjf.br> Co-authored-by: Grace Nshokano <grace.devolop@gmail.com> Co-authored-by: Matheus Muniz <matheusmuniz100@hotmail.com> Co-authored-by: Júlio Piubello da Silva Cabral <julio.piubello@gitstart.dev> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Co-authored-by: Matheus Benini Ferreira <88898100+MatheusBeniniF@users.noreply.github.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: C000Ldude <coolmagnas@gmail.com> Co-authored-by: Klinger Matheus <50892465+KlingerMatheus@users.noreply.github.com> Co-authored-by: Eman <emmanuelgatwech@gmail.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import Badge from "@calcom/ui/Badge";
|
|
import Button from "@calcom/ui/Button";
|
|
import showToast from "@calcom/ui/v2/core/notifications";
|
|
|
|
const DisableUserImpersonation = ({ disableImpersonation }: { disableImpersonation: boolean }) => {
|
|
const utils = trpc.useContext();
|
|
|
|
const { t } = useLocale();
|
|
|
|
const mutation = trpc.useMutation("viewer.updateProfile", {
|
|
onSuccess: async () => {
|
|
showToast(t("your_user_profile_updated_successfully"), "success");
|
|
await utils.invalidateQueries(["viewer.me"]);
|
|
},
|
|
async onSettled() {
|
|
await utils.invalidateQueries(["viewer.public.i18n"]);
|
|
},
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<div className="flex flex-col justify-between pt-9 pl-2 sm:flex-row">
|
|
<div>
|
|
<div className="flex flex-row items-center">
|
|
<h2 className="font-cal text-lg font-medium leading-6 text-gray-900">
|
|
{t("user_impersonation_heading")}
|
|
</h2>
|
|
<Badge className="ml-2 text-xs" variant={!disableImpersonation ? "success" : "gray"}>
|
|
{!disableImpersonation ? t("enabled") : t("disabled")}
|
|
</Badge>
|
|
</div>
|
|
<p className="mt-1 text-sm text-gray-500">{t("user_impersonation_description")}</p>
|
|
</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;
|