From 15c1127b34c819260d3b565b2daabd07b9a9dbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoni=20Nu=C3=B1ez=20Romeu?= Date: Thu, 2 Jul 2026 11:23:57 +0200 Subject: [PATCH] Add admin access button in profile menu for admin users - Add onAdminClick prop to ProfileView component - Add conditional admin button visible only for is_admin users - Add handleAdminClick function in App.jsx to navigate to admin view - Button styled consistently with existing menu items --- frontend/src/App.jsx | 5 +++++ frontend/src/views/ProfileView.jsx | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index a5d80be..06a8054 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -41,6 +41,10 @@ function App() { setCurrentUser(prev => ({ ...prev, ...updated })); } + function handleAdminClick() { + setScreen('admin'); + } + const isLoggedIn = Boolean(currentUser); function handleNavChange(tab) { @@ -75,6 +79,7 @@ function App() { onProfileSaved={handleProfileSaved} onShowSaved={() => setShowSaved(true)} onLogout={handleLogout} + onAdminClick={handleAdminClick} /> ); showBack = true; diff --git a/frontend/src/views/ProfileView.jsx b/frontend/src/views/ProfileView.jsx index 99ffe89..a12e27d 100644 --- a/frontend/src/views/ProfileView.jsx +++ b/frontend/src/views/ProfileView.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import './ProfileView.css'; import { getUserPosition } from '../utils/geo'; -function ProfileView({ currentUser, onProfileSaved, onShowSaved, onLogout }) { +function ProfileView({ currentUser, onProfileSaved, onShowSaved, onLogout, onAdminClick }) { const [address, setAddress] = useState(currentUser?.address || ''); const [latitude, setLatitude] = useState( currentUser?.latitude != null ? String(currentUser.latitude) : '' @@ -158,6 +158,20 @@ function ProfileView({ currentUser, onProfileSaved, onShowSaved, onLogout }) { + + {currentUser?.is_admin && ( + + )}