Skip to content

Commit

Permalink
Add Onboarding avatar picture
Browse files Browse the repository at this point in the history
  • Loading branch information
jannickheisch committed Oct 29, 2023
1 parent c2ed874 commit da57f8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions DineDevineUI/src/pages/OnboardingPage.tsx
Expand Up @@ -11,7 +11,7 @@ import {
} from '@ionic/react';
import './pages.css'
import {RouteComponentProps} from "react-router";
import {usePhotoGallery} from "../hooks/usePhotoGallery";
import {base64FromPath, usePhotoGallery} from "../hooks/usePhotoGallery";


const OnboardingPage: React.FC<RouteComponentProps> = (props: RouteComponentProps) => {
Expand All @@ -27,6 +27,7 @@ const OnboardingPage: React.FC<RouteComponentProps> = (props: RouteComponentProp

const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [photo, setPhoto] = useState(localStorage.getItem('email') ?? "")
const { photos, takePhoto } = usePhotoGallery();

const onSubmit = (e) => {
Expand All @@ -47,9 +48,24 @@ const OnboardingPage: React.FC<RouteComponentProps> = (props: RouteComponentProp
setName(e.target.value)
}

const addImage = async (e) => {
const addImage = async () => {
console.log("addImage")
await takePhoto()
if(photos.length != 1)
return
const b64 = await base64FromPath(photos[0].webviewPath)
console.log(b64)
localStorage.setItem("photo", b64 )
setPhoto(b64)

}

function getAvatar() {
if (photo == "") {
return "/public/test.png"
}
return photo

}

return (
Expand All @@ -64,8 +80,8 @@ const OnboardingPage: React.FC<RouteComponentProps> = (props: RouteComponentProp
<div></div>
<div className={"content-container"}>
<div>
<IonAvatar onClick={(e) => addImage(e)} className={"image"} class={"avatar"}>
<img className={"image"} src={"/test.png"}/>
<IonAvatar onClick={async() => await addImage()} className={"image"} class={"avatar"}>
<img className={"image"} src={getAvatar()}/>
</IonAvatar>
</div>
<IonItem>
Expand Down
2 changes: 1 addition & 1 deletion DineDevineUI/src/pages/ProfilePage.tsx
Expand Up @@ -123,7 +123,7 @@ const ProfilePage: React.FC<Profile> = (props: Profile) => {

<IonCol class={"ion-margin-start"}>
<h1 className="no-text-wrap profileHeadline">{name}</h1>
E-Mail: {email}
{email}
</IonCol>
</IonRow>
<IonRow>
Expand Down

0 comments on commit da57f8b

Please sign in to comment.