From c3c05e8af4a21a6f1f15c624544c475bca789ebc Mon Sep 17 00:00:00 2001 From: eddy Date: Fri, 17 Apr 2026 09:57:01 +0200 Subject: [PATCH] . --- src/App.jsx | 9 + src/components/Layout.jsx | 8 +- src/pages/Auth/ProfilePage.jsx | 156 ++++++++++++++++++ src/pages/Company/EditCompanyPage.jsx | 3 + .../Organization/EditOrganizationPage.jsx | 3 + 5 files changed, 176 insertions(+), 3 deletions(-) create mode 100644 src/pages/Auth/ProfilePage.jsx diff --git a/src/App.jsx b/src/App.jsx index 8ef80fc..de83358 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -17,6 +17,7 @@ import EditOrganizationPage from "./pages/Organization/EditOrganizationPage.jsx" import CompanyPage from "./pages/Company/CompanyPage.jsx"; import EditCompanyPage from "./pages/Company/EditCompanyPage.jsx"; import CalenderPostPage from "./pages/Calender/CalenderPostPage.jsx"; +import ProfilePage from "./pages/Auth/ProfilePage.jsx"; const theme = createTheme({ palette: { @@ -76,6 +77,14 @@ export default function App() { } /> + + + + } + /> {getActiveLabel(location.pathname)} - - A + + navigate('/profile')} sx={{ p: 0 }}> + A + diff --git a/src/pages/Auth/ProfilePage.jsx b/src/pages/Auth/ProfilePage.jsx new file mode 100644 index 0000000..2967826 --- /dev/null +++ b/src/pages/Auth/ProfilePage.jsx @@ -0,0 +1,156 @@ +import { useState } from 'react'; +import { + Box, Card, CardContent, TextField, Button, Typography, + Alert, CircularProgress, Divider, +} from '@mui/material'; +import AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined'; +import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; +import axiosInstance from '../../api/axiosInstance'; + +export default function ProfilePage() { + + const [nickname, setNickname] = useState(''); + const [nicknameLoading, setNicknameLoading] = useState(false); + const [nicknameError, setNicknameError] = useState(''); + const [nicknameSuccess, setNicknameSuccess] = useState(''); + + const [currentPassword, setCurrentPassword] = useState(''); + const [newPassword, setNewPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [passwordLoading, setPasswordLoading] = useState(false); + const [passwordError, setPasswordError] = useState(''); + const [passwordSuccess, setPasswordSuccess] = useState(''); + + const handleNicknameSave = async (e) => { + e.preventDefault(); + setNicknameError(''); + setNicknameSuccess(''); + if (!nickname.trim()) { + setNicknameError('Bitte einen Nickname eingeben.'); + return; + } + setNicknameLoading(true); + try { + await axiosInstance.patch('/users/nickname', { nickname }); + setNicknameSuccess('Nickname erfolgreich gespeichert.'); + } catch (err) { + setNicknameError(err.response?.data?.error ?? 'Fehler beim Speichern.'); + } finally { + setNicknameLoading(false); + } + }; + + const handlePasswordSave = async (e) => { + e.preventDefault(); + setPasswordError(''); + setPasswordSuccess(''); + if (!currentPassword || !newPassword || !confirmPassword) { + setPasswordError('Bitte alle Felder ausfüllen.'); + return; + } + if (newPassword !== confirmPassword) { + setPasswordError('Neue Passwörter stimmen nicht überein.'); + return; + } + if (newPassword.length < 8) { + setPasswordError('Neues Passwort muss mindestens 8 Zeichen haben.'); + return; + } + setPasswordLoading(true); + try { + await axiosInstance.patch('/users/password', { currentPassword, newPassword }); + setPasswordSuccess('Passwort erfolgreich geändert.'); + setCurrentPassword(''); + setNewPassword(''); + setConfirmPassword(''); + } catch (err) { + setPasswordError(err.response?.data?.error ?? 'Fehler beim Ändern des Passworts.'); + } finally { + setPasswordLoading(false); + } + }; + + return ( + + + {/* ── Karte: Nickname ── */} + + + + + Nickname ändern + + + {nicknameError && {nicknameError}} + {nicknameSuccess && {nicknameSuccess}} + + + setNickname(e.target.value)} + fullWidth + autoComplete="off" + /> + + + + + + {/* ── Karte: Passwort ── */} + + + + + Passwort ändern + + + {passwordError && {passwordError}} + {passwordSuccess && {passwordSuccess}} + + + setCurrentPassword(e.target.value)} + fullWidth + /> + + setNewPassword(e.target.value)} + fullWidth + helperText="Mindestens 8 Zeichen" + /> + setConfirmPassword(e.target.value)} + fullWidth + /> + + + + + + + ); +} \ No newline at end of file diff --git a/src/pages/Company/EditCompanyPage.jsx b/src/pages/Company/EditCompanyPage.jsx index cbf6b7b..6f8bfd8 100644 --- a/src/pages/Company/EditCompanyPage.jsx +++ b/src/pages/Company/EditCompanyPage.jsx @@ -183,6 +183,9 @@ export default function EditCompanyPage() { + + Website muss mit "https://" anfangen + + + Website muss mit "https://" anfangen +