profil mit bild

This commit is contained in:
Peter Hoppe
2023-01-04 16:23:43 +01:00
parent 8a42c3a506
commit 50c129bf5a
2 changed files with 26 additions and 1 deletions

View File

@ -1,10 +1,29 @@
import React, { useState } from 'react';
import React, { useContext, useState } from 'react';
import { Axios, ResponseT, UserCtx, UserCtxT } from '../context/UserContext';
function PreviewUpload({chgFile}:{chgFile: any}) {
const [file, setFile] = useState<string | undefined >(undefined);
const [dimensionWidth, setDimensionWidth] = useState(0);
const [dimensionHeight, setDimensionHeight] = useState(0);
const { user } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
const [dog, setDog] = useState<ResponseT | any>({}); // local dog not the dog in UserContext
if(user && (dog === undefined || dog.success === undefined))
{
Axios.post<ResponseT>('getDog.php',
{
qr_id: user.qr_id
})
.then((resDog) =>
{
setDog(resDog.data);
setFile("./uploads"+resDog.data.data.picture);
})
.catch((err) => console.error(err));
}
const handleChange = async (
event: React.ChangeEvent<HTMLInputElement>
): Promise<any> => {