diff --git a/src/container/signup/index.tsx b/src/container/signup/index.tsx index f2aead8..953c604 100644 --- a/src/container/signup/index.tsx +++ b/src/container/signup/index.tsx @@ -1,12 +1,8 @@ import * as React from 'react'; -import Avatar from '@mui/material/Avatar'; -import Button from '@mui/material/Button'; -import CssBaseline from '@mui/material/CssBaseline'; -import TextField from '@mui/material/TextField'; -import Grid from '@mui/material/Grid'; -import Box from '@mui/material/Box'; -import Typography from '@mui/material/Typography'; -import Container from '@mui/material/Container'; +import {Button, TextField, Grid, Box, + Typography, Container +} from '@mui/material'; +import Photo from './photo/photo'; import { createTheme, ThemeProvider } from '@mui/material/styles'; import axios from 'axios'; import student_icon from './student-icon.png'; @@ -22,7 +18,7 @@ const theme = createTheme(); const SingUpPage = (): React.ReactElement => { - const [avatarUrl, setAvatarUrl] = useState(null); + const [selectedPhoto, setSelectedPhoto] = useState(null); const [selectedOption, setSelectedOption] = useState(null); const handleChange = (selectedOption) => { setSelectedOption(selectedOption); @@ -48,28 +44,14 @@ const SingUpPage = (): React.ReactElement => { onClose(); }; */ - const handleAvatarClick = () => { - const fileInput = document.getElementById('avatar-input') as HTMLInputElement; - fileInput.click(); + + const handlePhotoChange = (photo) => { + setSelectedPhoto(photo); // Сохраняем выбранное изображение }; - const handleAvatarChange = (event: React.ChangeEvent) => { - const file = event.target.files[0]; - const reader = new FileReader(); - - reader.onload = () => { - setAvatarUrl(reader.result as string); - }; - - reader.readAsDataURL(file); - }; - - - return ( - { justifyContent="center" sx={{ paddingTop: 7, paddingLeft: 3 }} > - - + { + const file = event.target.files[0]; + if (file) { + const reader = new FileReader(); + + reader.onload = (e) => { + const newPhoto = e.target.result; + setPhoto(newPhoto); + if (onPhotoChange) onPhotoChange(newPhoto); + }; + + reader.readAsDataURL(file); + } + }; + + const handleAvatarClick = () => { + const fileInput = document.getElementById('fileInput') as HTMLInputElement; + fileInput.click(); + } + + + return ( + + + + + ); + +} + +export default Photo; diff --git a/src/container/signup/photo/types.ts b/src/container/signup/photo/types.ts new file mode 100644 index 0000000..e69de29