Skip to content

Commit

Permalink
Fix preview upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Jun 18, 2023
1 parent acfe4f2 commit 0e3d560
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apps/app/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function Settings() {
const { user, edit_user, isLoading } = useAuth();
const [formPersonal] = Form.useForm();
const [formPassword] = Form.useForm();
const [avatar, setAvatar] = useState<undefined| string >();
const [avatar, setAvatar] = useState<void | string>();

const [userSkills, setUserSkills] = useState<any[]>([]);
const [skills, setSkills] = useState<any[]>([]);
Expand Down Expand Up @@ -182,6 +182,12 @@ function Settings() {
}
};

const base64 = (file: any) => {
getBase64(file, (result: string) => {
setAvatar(result);
});
};

const changeSkills = () => {
const deleted = userSkills
.map((skill: any) => skill.id)
Expand Down Expand Up @@ -273,11 +279,10 @@ function Settings() {
accept="image/*"
maxCount={1}
beforeUpload={(file) => {
console.log(file);
setAvatar(file.name);
base64(file);
return false;
}}
onRemove={() => setAvatar(user?.photo as File | undefi)}
onRemove={() => setAvatar(user?.photo)}
>
<Button icon={<UploadOutlined />}>Upload</Button>
</Upload>
Expand Down

0 comments on commit 0e3d560

Please sign in to comment.