From 8d43e34be47fd977fb43af15a50e0aaf723d3f3b Mon Sep 17 00:00:00 2001 From: Malo BEAUCHAMPS Date: Wed, 16 Oct 2024 14:01:33 +0200 Subject: [PATCH] feat: admin sidebar --- src/App.tsx | 2 +- src/component/Navigation/Navigation.tsx | 45 ++++++++++++++++++++----- src/pages/admin/BulkCreateUser.tsx | 5 +-- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index ec01392..5585120 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,7 +23,7 @@ function App() { } /> } /> } /> - } /> + } /> } /> } /> diff --git a/src/component/Navigation/Navigation.tsx b/src/component/Navigation/Navigation.tsx index 4b628c4..af12c19 100644 --- a/src/component/Navigation/Navigation.tsx +++ b/src/component/Navigation/Navigation.tsx @@ -77,7 +77,7 @@ const Navigation: React.FC = ({
- {user ? ( + {user.username.trim() !== "" ? (
  • = ({ ) : (
  • - Log Out + Log In
  • )} {user && user.roles.includes("root") && (
  • -
    - - - Admin - -
    +
    + Admin +
      +
    • +
      + + Admin + +
      +
    • +
    • +
      + + Create Tp + +
      +
    • +
    • +
      + + Create User + +
      +
    • +
    • +
      + + Bulk user creation + +
      +
    • +
    +
  • )} - {user && ( + {user && user.username.trim() !== "" && ( <>
  • diff --git a/src/pages/admin/BulkCreateUser.tsx b/src/pages/admin/BulkCreateUser.tsx index f5131d6..f919401 100644 --- a/src/pages/admin/BulkCreateUser.tsx +++ b/src/pages/admin/BulkCreateUser.tsx @@ -1,10 +1,12 @@ import axios from "axios"; import { useState } from "react"; +import { useNavigate } from "react-router-dom"; function BulkUsers() { const [file, setFile] = useState(null); const [userData, setUserData] = useState([]); const [practical, setPractical] = useState("0"); + const navigate = useNavigate(); const handlePracticalChange = (e) => { setPractical(e.target.value); @@ -37,8 +39,7 @@ function BulkUsers() { const handleSubmit = () => { // Handle submission logic (e.g., sending data to the backend) - console.log('Submitting data:', userData.filter(user => user.name !== "")); - axios.post("/api/users/jdmi", userData.filter(user => user.name !== "")).then(res => console.log(res)); + axios.post("/api/users/jdmi", userData.filter(user => user.name !== "")).then(res => navigate(`/tps/${res.data.id}`)); }; return (