464343f5ab
* WIP * WIP * Type and migration fixes * Adds missing default import * Fixes import * Fixes tRPC imports in App Store * Migrate stripe helpers * WIP * Type fixes * Type fix? * WIP * WIP * Update index.ts * Fixes * Update workflow.tsx * Moved queries to lib * Moves QueryCell * Migrates MultiSelectCheckboxes * WIP * CryptoSection type fixes * WIP * Import fixes * Build fixes * Update app-providers.tsx * Build fixes * Upgrades hookform zod resolvers * Build fixes * Cleanup * Build fixes * Relocates QueryCell to ui * Moved List and SkeletonLoader * Revert QueryCell migration * Can't use QueryCell here * oops * CryptoSection cleanup * Update app-providers.tsx * Moved ee to features * ee to features/ee * Removes @calcom/ee * Adds possible feature locations * Build fixes * Migrates stripe to app-store lib * Colocates stripe imports * Update subscription.ts * Submodule sync Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import showToast from "@calcom/lib/notification";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import Badge from "@calcom/ui/Badge";
|
|
import Button from "@calcom/ui/Button";
|
|
|
|
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;
|