chore: remove openid field from user

This commit is contained in:
Steven
2023-09-14 22:57:27 +08:00
parent 42bd9b194b
commit 33d9c13b7e
31 changed files with 298 additions and 819 deletions

View File

@ -1,37 +1,13 @@
import { Button, Input, Textarea } from "@mui/joy";
import { Button } from "@mui/joy";
import useCurrentUser from "@/hooks/useCurrentUser";
import { useUserV1Store } from "@/store/v1";
import { useTranslate } from "@/utils/i18n";
import showChangePasswordDialog from "../ChangePasswordDialog";
import { showCommonDialog } from "../Dialog/CommonDialog";
import Icon from "../Icon";
import showUpdateAccountDialog from "../UpdateAccountDialog";
import UserAvatar from "../UserAvatar";
const MyAccountSection = () => {
const t = useTranslate();
const userV1Store = useUserV1Store();
const user = useCurrentUser();
const openAPIRoute = `${window.location.origin}/api/v1/memo?openId=${user.openId}`;
const handleResetOpenIdBtnClick = async () => {
showCommonDialog({
title: t("setting.account-section.openapi-reset"),
content: t("setting.account-section.openapi-reset-warning"),
style: "warning",
dialogName: "reset-openid-dialog",
onConfirm: async () => {
await userV1Store.updateUser(
{
username: user.username,
},
["reset_open_id"]
);
},
});
};
const exampleWithCurl = `curl '${openAPIRoute}' -H 'Content-Type: application/json' --data-raw '{"content":"Hello world!"}'`;
return (
<>
@ -52,17 +28,6 @@ const MyAccountSection = () => {
</Button>
</div>
</div>
<div className="section-container openapi-section-container mt-6">
<p className="title-text">Open ID</p>
<div className="w-full flex flex-row justify-start items-center">
<Input className="grow mr-2" value={user.openId} readOnly />
<Button className="shrink-0" color="neutral" variant="outlined" onClick={handleResetOpenIdBtnClick}>
<Icon.RefreshCw className="h-4 w-4" />
</Button>
</div>
<p className="title-text">Open API Example with cURL</p>
<Textarea className="w-full !font-mono !text-sm whitespace-pre" value={exampleWithCurl} readOnly />
</div>
</>
);
};