From 3a4369b40d49635e7a409b46054f2e4a61122a2b Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 1 Aug 2023 22:34:58 +0200 Subject: [PATCH] Created the Name.jsx settings component --- .../Settings/components/Name/Name.jsx | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/states/Dashboard/pages/Info/components/Settings/components/Name/Name.jsx diff --git a/src/states/Dashboard/pages/Info/components/Settings/components/Name/Name.jsx b/src/states/Dashboard/pages/Info/components/Settings/components/Name/Name.jsx new file mode 100644 index 0000000..479c99b --- /dev/null +++ b/src/states/Dashboard/pages/Info/components/Settings/components/Name/Name.jsx @@ -0,0 +1,48 @@ +import {Box, Button, IconButton, TextField, Typography} from "@mui/material"; +import {CopyAll, Save} from "@mui/icons-material"; +import {useContext, useState} from "react"; +import {ProjectContext} from "@/states/Dashboard/contexts/Project"; +import {patchRequest} from "@/common/utils/RequestUtil.js"; + +export const Name = () => { + const {currentProject, updateProjects} = useContext(ProjectContext); + + const [name, setName] = useState(currentProject.name); + const [nameChanged, setNameChanged] = useState(false); + + const updateName = (event) => { + setName(event.target.value); + setNameChanged(true); + } + + const copyName = () => { + navigator.clipboard.writeText(name); + } + + const saveName = async () => { + try { + await patchRequest(`/project/${currentProject.id}`, {name}); + await updateProjects(); + setNameChanged(false); + } catch (e) { + console.error(e); + } + } + + return ( + + Projektname + + Dies ist der Projektname. Du findest diesen über + das Dashboard verteilt überall und er hilft dir, dein + Projekt zu identifizieren + + + } : {}}/> + + + + ) +} \ No newline at end of file