-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21fb8bf
commit 3f396be
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mutation BanAccount($id: ID!) { | ||
banAccount(id: $id) { | ||
success | ||
account { | ||
id | ||
banned | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from "react"; | ||
|
||
import FormGroup from "@mui/material/FormGroup"; | ||
import FormControlLabel from "@mui/material/FormControlLabel"; | ||
import Switch from "@mui/material/Switch"; | ||
|
||
import { | ||
useBanAccountMutation, | ||
useUnbanAccountMutation, | ||
BaseAccount, | ||
} from "src/generated/graphql"; | ||
|
||
export function BanToggle({ | ||
account, | ||
}: { | ||
account: Omit<BaseAccount, "password">; | ||
}): JSX.Element { | ||
const [banAccount] = useBanAccountMutation(); | ||
const [unbanAccount] = useUnbanAccountMutation(); | ||
|
||
function toggleBan() { | ||
if (account.banned) { | ||
unbanAccount({ variables: { id: account.id } }); | ||
} else { | ||
banAccount({ variables: { id: account.id } }); | ||
} | ||
} | ||
|
||
return ( | ||
<FormGroup> | ||
<FormControlLabel | ||
control={<Switch checked={account.banned} onChange={toggleBan} />} | ||
label={account.banned ? "Currently Banned" : "Not Banned"} | ||
/> | ||
</FormGroup> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mutation DeleteAccount($id: ID!) { | ||
deleteAccount(id: $id) { | ||
success | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useState } from "react"; | ||
|
||
import Box from "@mui/material/Box"; | ||
import Button from "@mui/material/Button"; | ||
import FormGroup from "@mui/material/FormGroup"; | ||
import FormControlLabel from "@mui/material/FormControlLabel"; | ||
import Switch from "@mui/material/Switch"; | ||
|
||
import { useDeleteAccountMutation, BaseAccount } from "src/generated/graphql"; | ||
|
||
export function DeleteAccount({ | ||
account, | ||
}: { | ||
account: Omit<BaseAccount, "password">; | ||
}): JSX.Element { | ||
const [deleteAccountMutation] = useDeleteAccountMutation(); | ||
const [isArmed, setIsArmed] = useState<boolean>(false); | ||
|
||
function deleteAccount() { | ||
deleteAccountMutation({ variables: { id: account.id } }); | ||
} | ||
|
||
return ( | ||
<Box> | ||
<br /> | ||
<FormGroup> | ||
<FormControlLabel | ||
disabled={!account.banned} | ||
control={ | ||
<Switch checked={isArmed} onChange={() => setIsArmed(!isArmed)} /> | ||
} | ||
label={ | ||
account.banned | ||
? "Allow Account Deletion" | ||
: "Must Be Banned to Delete" | ||
} | ||
/> | ||
</FormGroup> | ||
<Button disabled={!isArmed} onClick={deleteAccount}> | ||
Delete This Account | ||
</Button> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mutation UnbanAccount($id: ID!) { | ||
unbanAccount(id: $id) { | ||
success | ||
account { | ||
id | ||
banned | ||
} | ||
} | ||
} |