2022-08-09 09:21:15 +00:00
|
|
|
import { signIn } from "next-auth/react";
|
|
|
|
import { useRef } from "react";
|
|
|
|
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-09-08 15:35:31 +00:00
|
|
|
import { TextField, Button } from "@calcom/ui/v2";
|
2022-08-30 19:46:52 +00:00
|
|
|
import Meta from "@calcom/ui/v2/core/Meta";
|
2022-08-24 20:18:42 +00:00
|
|
|
import { getLayout } from "@calcom/ui/v2/core/layouts/AdminLayout";
|
2022-08-09 09:21:15 +00:00
|
|
|
|
|
|
|
function AdminView() {
|
|
|
|
const { t } = useLocale();
|
|
|
|
const usernameRef = useRef<HTMLInputElement>(null);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-09-14 09:42:48 +00:00
|
|
|
<Meta title="Admin" description="Impersonation" />
|
2022-08-09 09:21:15 +00:00
|
|
|
<form
|
|
|
|
className="mb-6 w-full sm:w-1/2"
|
|
|
|
onSubmit={(e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
const enteredUsername = usernameRef.current?.value.toLowerCase();
|
|
|
|
signIn("impersonation-auth", { username: enteredUsername }).then((res) => {
|
|
|
|
console.log(res);
|
|
|
|
});
|
|
|
|
}}>
|
2022-09-08 15:35:31 +00:00
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
<TextField
|
|
|
|
containerClassName="w-full"
|
|
|
|
name="Impersonate User"
|
|
|
|
addOnLeading={<>{process.env.NEXT_PUBLIC_WEBSITE_URL}/</>}
|
|
|
|
ref={usernameRef}
|
|
|
|
hint={t("impersonate_user_tip")}
|
|
|
|
defaultValue={undefined}
|
|
|
|
/>
|
2022-08-09 09:21:15 +00:00
|
|
|
<Button type="submit">{t("impersonate")}</Button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
AdminView.getLayout = getLayout;
|
|
|
|
|
|
|
|
export default AdminView;
|