diff --git a/src/pages/admin/admin.js b/src/pages/admin/admin.js index 2590c44b0302e7f32d212d26a89166aa828096b0..5d2dd1a63f353bd111c42648b8101de459dc91cb 100644 --- a/src/pages/admin/admin.js +++ b/src/pages/admin/admin.js @@ -33,12 +33,17 @@ const AdminPage = () => { const navigate = useNavigate(); const [isLoading, setLoading] = useState(true); - const isAdmin = async () => { - const response = await fetch(`${baseUrl}/auth/admin`); - + const isAdmin = async () => { + const response = await fetch(`${baseUrl}/auth/admin`, { + method: 'DELETE', + headers: { + Authorization: `Bearer ${localStorage.getItem("token")}`, + }, + }); + setLoading(false); if (!response.ok) { - navigate('/'); + navigate('/'); } } @@ -194,9 +199,9 @@ const AdminPageView = () => { </Box> <Box minW={"50vw"}> {locations.map((location) => ( - <Box - key={`parent${location._id}`} - py={1}> + <Box + key={`parent${location._id}`} + py={1}> <Box key={location._id} p={4} @@ -225,7 +230,7 @@ const AdminPageView = () => { </Text> </div> <Button - key={`delete:${location._id}`} + key={`delete:${location._id}`} rightIcon={<CloseIcon />} aria-label="Delete location" onClick={() => deleteLocation(location._id)}