Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Admin client dev (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
amarnath-dev authored Mar 9, 2024
2 parents 25975a4 + ab589e9 commit 4cd2369
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 15 deletions.
29 changes: 29 additions & 0 deletions client/src/Services/userService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import thaliaAPI from "../API/thaliaAPI";

export const getUsers = async () => {
try {
const response = await thaliaAPI.get("/admin/users", { withCredentials: true });
return response.data;
} catch (error) {
return error;
}
}

export const blockUser = async (userId) => {
try {
const response = await thaliaAPI.put(`/admin/users/block/${userId}`, { withCredentials: true });
return response.data;
} catch (error) {
return error;
}
}

export const unBlockUser = async (userId) => {
try {
const response = await thaliaAPI.put(`/admin/users/unblock/${userId}`, { withCredentials: true });
return response.data;
} catch (error) {
return error;
}
}

6 changes: 3 additions & 3 deletions client/src/components/AddBody/AddBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function AddBody({ openModal, setOpenModal }) {
<h1 className="text-white py-2">Name of the Topic</h1>
<input
type="text"
className="w-full rounded-md bg-gray-700 text-text"
className="w-full rounded-md bg-gray-800 text-text focus:ring-0"
value={formData.name}
onChange={handleChange}
name="name"
Expand All @@ -56,12 +56,12 @@ function AddBody({ openModal, setOpenModal }) {
onChange={handleChange}
id=""
rows={8}
className="w-full rounded-md bg-gray-700 text-white"
className="w-full rounded-md bg-gray-800 text-white focus:ring-0"
></textarea>
</label>
</div>
<button
className="text-primary border-2 px-2 py-2 rounded-md float-end"
className="text-primary border px-5 py-1 rounded-md float-end hover:bg-primary hover:text-background"
onClick={handleAdd}
>
Add Topic
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/AddRight/AddRight.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function AddRight({ setOpenModal, openModal }) {
</label>
</div>
<button
className="text-primary border-2 px-2 py-2 rounded-md float-end"
className="text-primary border-2 px-5 py-1 hover:bg-primary hover:text-black rounded-md float-end"
onClick={handleCreate}
>
Add Right
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/EditBody/EditBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function EditBody({ setOpenModal, openModal, bodyDetails }) {
</label>
</div>
<button
className="text-primary border-2 px-2 py-2 rounded-md float-end"
className="text-primary border-2 px-5 py-1 hover:bg-primary hover:text-black rounded-md float-end"
onClick={handleEdit}
>
Update
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/EditRight/EditRight.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function EditRight({ setOpenModal, openModal, rightDetails }) {
</label>
</div>
<button
className="text-primary border-2 px-2 py-2 rounded-md float-end"
className="text-primary border-2 px-5 py-1 hover:bg-primary hover:text-black rounded-md float-end"
onClick={handleEdit}
>
Update
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Nabar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function Navbar() {
title: "Are you sure!",
showCancelButton: true,
confirmButtonText: "Logout",
confirmButtonColor:"#951947",
confirmButtonColor: "#951947",
}).then((result) => {
if (result.isConfirmed) {
setIsLogout(true);
Expand All @@ -32,7 +32,7 @@ export default function Navbar() {

return (
<>
<div className="flex items-center justify-between fixed z-40 top-0 w-full px-10 py-1 bg-gradient-to-r from-[#2d1525] to-background">
<div className="flex items-center justify-between sticky z-40 top-0 w-full px-10 py-1 bg-gradient-to-r from-[#2d1525] to-background">
<Link to={"/"}>
<img src={Logo} className="w-24" alt="" />
</Link>
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ function Sidebar() {
<>
<div className="w-72 h-screen shadow-lg rounded-lg bg-gray-900 fixed">
<div className="flex justify-start items-start flex-col mx-3 my-3">
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8">
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8 hover:bg-gray-800">
<MdDashboard className="text-primary" />
<Link className="ml-4 font-bold text-gray-500" to={"/admin"}>
Dash Board
</Link>
</button>
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8">
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8 hover:bg-gray-800">
<FaUsers className="text-primary" />
<Link
className="ml-4 font-bold text-gray-500"
Expand All @@ -23,13 +23,13 @@ function Sidebar() {
User Managment
</Link>
</button>
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8">
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8 hover:bg-gray-800">
<TbFileReport className="text-primary" />
<Link className="ml-4 font-bold text-gray-500" to={"/admin/rights"}>
Rights Management
</Link>
</button>
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8">
<button className="flex items-center px-4 py-2 rounded-md w-full mt-8 hover:bg-gray-800">
<IoBody className="text-primary" />
<Link className="ml-4 font-bold text-gray-500" to={"/admin/body"}>
My Body
Expand Down
30 changes: 28 additions & 2 deletions client/src/pages/AdminPages/Managment/Managment.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import CheckReport from "../../../components/CheckReport/CheckReport";
import { getUsers } from "../../../Services/userService";
import { blockUser } from "../../../Services/userService";
import { toast } from "react-toastify";

function Managment() {
const [openModal, setOpenModal] = useState(false);
const [reportObject, setReportObject] = useState();

const [users, setUsers] = useState([]);

const handleModal = () => {
setOpenModal(true);
};
useEffect(() => {
const fetchUsers = async () => {
const response = await getUsers();
if (response.success === true) {
setUsers(response.users);
}
};
fetchUsers();
}, []);

const handleBlock = async (userId) => {
const response = await blockUser(userId);
if (response.success === true) {
toast(response.message);
}
};

return (
<>
<CheckReport
Expand Down Expand Up @@ -56,7 +79,10 @@ function Managment() {
</button>
</td>
<td className="px-6 py-4">
<button className="border py-1 px-6 rounded hover:bg-red-700">
<button
className="border py-1 px-6 rounded hover:bg-red-700"
onClick={() => handleBlock(user?._id)}
>
Block
</button>
</td>
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/AdminPages/MyBody/MyBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function MyBody() {
bodyDetails={editBody ? editBody : null}
/>
<AddBody setOpenModal={setOpenModal} openModal={openModal} />
<div className=" h-screen bg-background">
<div className="min-h-screen bg-background">
<div className="col-span-9">
{/* Text Components */}
<div className="text-text flex justify-between">
Expand Down

0 comments on commit 4cd2369

Please sign in to comment.