* Icon and IconName * Button and ButtonGroup * UserAvatar * AvatarGroup * Avatar * WizardLayout * Dialogs * EmptyScreen * showToast and TextField * Editor * Skeleton * Skeleton * TopBanner and showToast * Button again * more * perf: Remove app-store reference from @calcom/ui * more * Fixing types * Icon * Fixed casing * dropdown * more * Select * more * Badge * List * more * Divider * more * fix * fix type check * refactor * fix * fix * fix * fix * fix * fix * fix * fix type check * fix * fix * fix * fix * more * more * more * more * add index file to components/command * fix * fix * fix * fix imports * fix * fix * fix * fix * fix * fix * fix * fix build errors * fix build errors * fix --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com>
85 lines
2.4 KiB
TypeScript
85 lines
2.4 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
import { trpc } from "@calcom/trpc";
|
|
import { TextField } from "@calcom/ui/components/form";
|
|
import { Button } from "@calcom/ui/components/button";
|
|
import { showToast } from "@calcom/ui/components/toast";
|
|
|
|
import UsersTable from "./components/UsersTable";
|
|
|
|
export default function LockedSMSView() {
|
|
const [username, setUsername] = useState("");
|
|
const [teamSlug, setTeamSlug] = useState("");
|
|
|
|
const utils = trpc.useContext();
|
|
|
|
const mutation = trpc.viewer.admin.setSMSLockState.useMutation({
|
|
onSuccess: (data) => {
|
|
if (data) {
|
|
showToast(`${data.name} successfully ${data.locked ? "locked" : "unlocked"}`, "success");
|
|
}
|
|
utils.viewer.admin.getSMSLockStateTeamsUsers.invalidate();
|
|
},
|
|
onError: (error) => {
|
|
showToast(`${error}`, "error");
|
|
utils.viewer.admin.getSMSLockStateTeamsUsers.invalidate();
|
|
},
|
|
});
|
|
|
|
function setSMSLockState({ userId, teamId, lock }: { userId?: number; teamId?: number; lock: boolean }) {
|
|
mutation.mutate({
|
|
userId,
|
|
teamId,
|
|
lock,
|
|
});
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<div className="mb-4 flex w-full items-center justify-between space-x-2 rtl:space-x-reverse">
|
|
<div className="flex">
|
|
<TextField
|
|
name="Lock User"
|
|
placeholder="username"
|
|
defaultValue=""
|
|
onChange={(event) => setUsername(event.target.value)}
|
|
value={username}
|
|
/>
|
|
<Button
|
|
type="submit"
|
|
className="ml-2 mt-5"
|
|
onClick={() => {
|
|
mutation.mutate({ username, lock: true });
|
|
utils.viewer.admin.getSMSLockStateTeamsUsers.invalidate();
|
|
}}>
|
|
Lock User
|
|
</Button>
|
|
</div>
|
|
<div className="flex">
|
|
<TextField
|
|
name="Lock Team"
|
|
placeholder="team slug"
|
|
defaultValue=""
|
|
onChange={(event) => {
|
|
setTeamSlug(event.target.value);
|
|
}}
|
|
value={teamSlug}
|
|
/>
|
|
<Button
|
|
type="submit"
|
|
className="ml-2 mt-5"
|
|
onClick={() => {
|
|
mutation.mutate({ teamSlug, lock: true });
|
|
utils.viewer.admin.getSMSLockStateTeamsUsers.invalidate();
|
|
}}>
|
|
Lock Team
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
<UsersTable setSMSLockState={setSMSLockState} />
|
|
</div>
|
|
);
|
|
}
|