-
Notifications
You must be signed in to change notification settings - Fork 91
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
0ba5d97
commit 3067dfe
Showing
8 changed files
with
93 additions
and
3 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
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
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
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,42 @@ | ||
import { Button, Text } from "@chakra-ui/react"; | ||
import useShowToast from "../hooks/useShowToast"; | ||
import useLogout from "../hooks/useLogout"; | ||
|
||
export const SettingsPage = () => { | ||
const showToast = useShowToast(); | ||
const logout = useLogout(); | ||
|
||
const freezeAccount = async () => { | ||
if (!window.confirm("Are you sure you want to freeze your account?")) return; | ||
|
||
try { | ||
const res = await fetch("/api/users/freeze", { | ||
method: "PUT", | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
const data = await res.json(); | ||
|
||
if (data.error) { | ||
return showToast("Error", data.error, "error"); | ||
} | ||
if (data.success) { | ||
await logout(); | ||
showToast("Success", "Your account has been frozen", "success"); | ||
} | ||
} catch (error) { | ||
showToast("Error", error.message, "error"); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Text my={1} fontWeight={"bold"}> | ||
Freeze Your Account | ||
</Text> | ||
<Text my={1}>You can unfreeze your account anytime by logging in.</Text> | ||
<Button size={"sm"} colorScheme='red' onClick={freezeAccount}> | ||
Freeze | ||
</Button> | ||
</> | ||
); | ||
}; |
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