diff --git a/code/frontend/src/App.tsx b/code/frontend/src/App.tsx index dc57287..d79e8a9 100644 --- a/code/frontend/src/App.tsx +++ b/code/frontend/src/App.tsx @@ -4,8 +4,8 @@ import "./styles/fonts.css"; import LoginAndSignUpPage from "./pages/LoginAndSignUpPage"; import Footer from "./components/Footer"; import Header from "./components/header"; -import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; import Profile from "./pages/Profile"; +import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; function App() { return ( diff --git a/code/frontend/src/components/ChagneAvatarDialog.tsx b/code/frontend/src/components/ChangeAvatarDialog.tsx similarity index 86% rename from code/frontend/src/components/ChagneAvatarDialog.tsx rename to code/frontend/src/components/ChangeAvatarDialog.tsx index 9034df1..0a1e6f4 100644 --- a/code/frontend/src/components/ChagneAvatarDialog.tsx +++ b/code/frontend/src/components/ChangeAvatarDialog.tsx @@ -27,32 +27,45 @@ const BootstrapDialog = styled(Dialog)(({ theme }) => ({ })); export default function CustomizedDialogs() { - const [open, setOpen] = React.useState(false); - - const handleClickOpen = () => { - setOpen(true); - }; - const handleClose = () => { - setOpen(false); - }; - + const inputFile = useRef(null); - + const openFileExplorer = () => { // `current` points to the mounted file input element if (inputFile.current) { inputFile.current.click(); } }; - + const [selectedImage, setSelectedImage] = useState(null); + const setImageURL = (selectedImage: File | null) => { + if (selectedImage !== null) { + return URL.createObjectURL(selectedImage); + } + //TODO: If no image is selected, return the image already in the database or undefined + return undefined; + } + + const [open, setOpen] = React.useState(false); + + const handleClickOpen = () => { + setOpen(true); + }; + const handleClose = () => { + setSelectedImage(null); // Reset the selected image when closing + setOpen(false); + }; + const handleSaveChanges = () => { + setOpen(false); + } + return ( diff --git a/code/frontend/src/pages/Profile.tsx b/code/frontend/src/pages/Profile.tsx index 419b586..d64ad76 100644 --- a/code/frontend/src/pages/Profile.tsx +++ b/code/frontend/src/pages/Profile.tsx @@ -2,7 +2,6 @@ import "./profile.css"; import "../components/bio.css"; import "./loginAndSignUpPage.css"; import "../styles/sizes.css"; -import "../styles/colors.css"; import "../styles/fonts.css"; import { useState } from "react"; import QuiltedImageList from "../components/QuiltedImageList"; @@ -15,7 +14,7 @@ import { Typography, TextField } from "@mui/material"; -import ChangeAvatarDialog from "../components/ChagneAvatarDialog"; +import ChangeAvatarDialog from "../components/ChangeAvatarDialog"; function Profile() { const toggleEditMode = () => { diff --git a/code/frontend/src/test.tsx b/code/frontend/src/test.tsx deleted file mode 100644 index 1b619b6..0000000 --- a/code/frontend/src/test.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import * as React from "react"; -import './components/header.css'; -import Box from "@mui/material/Box"; -import Drawer from "@mui/material/Drawer"; -import IconButton from "@mui/material/IconButton"; -import List from "@mui/material/List"; -import Divider from "@mui/material/Divider"; -import ListItem from "@mui/material/ListItem"; -import ListItemButton from "@mui/material/ListItemButton"; -import ListItemIcon from "@mui/material/ListItemIcon"; -import ListItemText from "@mui/material/ListItemText"; -import InboxIcon from "@mui/icons-material/MoveToInbox"; -import MailIcon from "@mui/icons-material/Mail"; - -export default function TemporaryDrawer() { - const [open, setOpen] = React.useState(false); - - const toggleDrawer = (newOpen: boolean) => () => { - setOpen(newOpen); - }; - - const DrawerList = ( - - - {["Inbox", "Starred", "Send email", "Drafts"].map((text, index) => ( - - - - {index % 2 === 0 ? : } - - - - - ))} - - - - {["All mail", "Trash", "Spam"].map((text, index) => ( - - - - {index % 2 === 0 ? : } - - - - - ))} - - - ); - - return ( -
-
-
- featherIcon -
-

Feather Feed

- - - - -
- - {DrawerList} - -
- ); -}