-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add and modify user information
- Loading branch information
nu_link
committed
Jul 22, 2023
1 parent
83cc1b5
commit 1e5b4eb
Showing
9 changed files
with
449 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { Avatar, Image } from "antd"; | ||
import defaultAvatar from "@/assets/img/avatar.png"; | ||
import { useState } from "react"; | ||
|
||
type ProfilePictureProps = { | ||
className?: string | undefined; | ||
onSuccess: (...args: any[]) => any; | ||
newAvatar?: string | ''; //The image from the parent compontent | ||
}; | ||
|
||
export const ProfilePicture = ({ onSuccess, newAvatar, className }: ProfilePictureProps) => { | ||
const { t } = useTranslation(); | ||
const [avatar, setAvatar] = useState(defaultAvatar); | ||
const changeAvatar = (event) => { | ||
const file = event.target.files[0]; | ||
const reader = new FileReader() | ||
reader.readAsDataURL(file) | ||
reader.onload = function(e) { | ||
const url = e.target?.result as string; | ||
setAvatar(url); //url and avatar are all base64 strings of image | ||
onSuccess(url); | ||
}; | ||
}; | ||
|
||
const inputStyle = { | ||
opacity: 0, | ||
}; | ||
return ( | ||
<> | ||
<div className={`${className} relative`}> | ||
<span className="block absolute avater-text pointer"> | ||
{t<string>("member-center-modify-data-change-avatar")} | ||
<input className="absolute avater-text" type="file" accept="image/*" style={inputStyle} onChange={changeAvatar} /> | ||
</span> | ||
<Avatar size={100} src={newAvatar || avatar} /> | ||
</div> | ||
</> | ||
) | ||
}; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./memberCenter"; | ||
export * from "./memberCenter"; | ||
export * from "./modifyData"; |
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
Oops, something went wrong.