Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/keystone/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import LoginPage from "./Pages/LoginPage/Login";
import Landing from "./Pages/LandingPage/Landing";
import { MantineProvider } from "@mantine/core";
import "@mantine/core/styles.css";
// export const UserLink = " :5000";
export const UserLink = " http://localhost:5000";
//
function App() {
return (
<MantineProvider>
Expand Down
6 changes: 3 additions & 3 deletions client/keystone/src/Components/ActiveVenues.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import axios from "axios";

import { UserLink } from "../App";
function ActiveVenues() {
const [venueData, setVenueData] = useState([]);
const [currentPage, setCurrentPage] = useState(1);
Expand All @@ -20,7 +20,7 @@ function ActiveVenues() {

const fetchVenues = () => {
axios
.get("http://localhost:5000/venues")
.get(`${UserLink}/venues`)
.then((res) => {
if (Array.isArray(res.data)) {
setVenueData(res.data);
Expand All @@ -33,7 +33,7 @@ function ActiveVenues() {

const handleDelete = (venue_id) => {
axios
.post(`http://localhost:5000/delete_venu/${venue_id}`)
.post(`${UserLink}/delete_venu/${venue_id}`)
.then((res) => {
console.log(res.data);
fetchVenues(); // Re-fetch the venues after deleting
Expand Down
246 changes: 200 additions & 46 deletions client/keystone/src/Components/AdminList.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { Avatar } from "@mantine/core";
import axios from "axios";
import UserFormControllerAdmin from "../utils/UserFormControllerAdmin";
import "../Transition.css";
import { UserLink } from "../App";
// import UserFormControllerAdmin from "../utils/UserFormControllerAdmin";
function AdminList() {
const [isApproved, setIsApproved] = useState([]);
const [deleted, setDeleted] = useState(true);
const [currentPage, setCurrentPage] = useState(1);
const itemsPerPage = 5;
// Logic to slice data based on current page
const indexOfLastItem = currentPage * itemsPerPage;
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
const currentItems = isApproved.slice(indexOfFirstItem, indexOfLastItem);
const user_picture_base_url =
"https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/avatars/";
// Function to handle page change
const handlePageChange = (pageNumber) => {
setCurrentPage(pageNumber);
};
useEffect(() => {
axios
.get("http://localhost:5000/admin_users")
.get(`${UserLink}/admin_users`)
.then((res) => {
if (Array.isArray(res.data)) {
setIsApproved(res.data);
Expand All @@ -16,60 +29,201 @@ function AdminList() {
}
})
.catch((err) => console.log(err));
}, [deleted]);
}, []);
function handleDelete(user_id) {
axios
.post(`http://localhost:5000/delete_user/${user_id}`)
.post(`${UserLink}/delete_user/${user_id}`)
.then((res) => {
console.log(res.data);
// Toggle the 'deleted' state to trigger a re-fetch of the data
setDeleted((prevDeleted) => !prevDeleted);
// setDeleted((prevDeleted) => !prevDeleted);
window.location.reload();
})
.catch((err) => console.log(err));
}

// <UserFormControllerAdmin />;
return (
<div className="bg-info-subtle p-3 justify-content-around ">
<div className="d-flex flex-row">
<h3>Admin List</h3>
<UserFormControllerAdmin />
</div>
<div>
{" "}
{isApproved.map((admin) => (
<tr
className="justify-content-evenly align-content-center bg-body-tertiary d-flex w-100 flex-row"
key={admin.user_id}
>
<div className=" h-auto w-100 ms-2 me-2 align-content-center ">
{admin.user_id}
</div>
<div className=" w-100 ms-2 me-2 align-content-center">
{admin.email}
</div>
<div className=" w-100 ms-2 me-2 align-content-center">
{admin.password}
</div>
<div className=" w-100 ms-2 me-2 align-content-center">
{admin.username}
</div>
<div className=" w-100 ms-2 me-2 align-content-center">
{admin.club}
</div>
{/*

*/}
<div className="bg-white rounded">
{" "}
<hr className="bg-white opacity-0" />
<div
className="white border-light shadow-lg border-top-0 border rounded-2 p-3"
// style={{ marginLeft: "20px", marginTop: "20px" }}
>
{/* MAIN WRAPPER TO DESGIN */}
<h4
className="text.small rounded align-middle ps-3 shadow-light text-white"
style={{
backgroundColor: "#31375A",

<div className="justify-content-around align-items-center bg-body-tertiary d-flex w-100 flex-row">
<Link to={`/read/${admin.user_id}`}>Read</Link>
<Link to={`/edit/${admin.user_id}`}>Edit</Link>
<button onClick={() => handleDelete(admin.user_id)}>
Delete
</button>
alignContent: "center",
height: "60px",
width: "70%",
// position: "absolute",
// opacity: "20%",
}}
>
Admin Users
</h4>
<div>
<div className="accordion mt-5" id="accordionExample">
{/* <div className="my-4">Headers</div> */}
<div className="flex-grow-1 ps-3 d-flex">
<div className="d-flex flex-grow-1 ">
<div className="w-auto ms-2 me-3 align-content-center fst-italic fw-bold">
UserID
</div>
<div className="w-50 ms-5 me-2 align-content-center fst-italic fw-bold">
Profile
</div>
<div className="w-75 ms-2 me-2 align-content-center fst-italic fw-bold">
UserName
</div>
<div className="w-75 ms-2 me-2 align-content-center fst-italic fw-bold">
Email
</div>
<div className="w-75 ms-5 me-2 align-content-center fst-italic fw-bold">
College
</div>
<div className="w-75 ms-3 align-content-center fst-italic fw-bold">
Club
</div>
</div>
<div className="d-flex">
<div className="pe-4 justify-content-around d-flex">
{/* <IconTrash
onClick={console.log("it works")}
size={20}
className="me-3"
/>
<IconEdit size={20} /> */}
</div>
</div>
</div>
</tr>
))}
{/* <div className="d-flex flex-grow-1 ms-4">
<div className="w-25 ms-2 me-2 align-content-center">User</div>
<div className="w-25 ms-2 me-2 align-content-center">wew</div>
<div className="w-50 ms-2 me-2 align-content-center">wew</div>
<div className="w-75 ms-2 me-2 align-content-center">wew</div>
<div className="w-50 ms-2 me-2 align-content-center">wew</div>
<div className="w-50 ms-2 me-2 align-content-center">wew</div>
</div> */}
{currentItems.map((venue, index) => (
<div key={venue.venue_id} className="accordion-item">
<h2 className="accordion-header" id={`headingApproved${index}`}>
<button
className="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target={`#collapedAdmins${index}`}
aria-expanded="false"
aria-controls={`collapedAdmins${index}`}
>
<div className="flex-grow-1 d-flex">
<div className="d-flex flex-grow-1 ">
<div className=" ms-2 me-2 align-content-center">
{venue.user_id}
</div>
<div className="w-25 ms-3 me-5 align-content-center">
<Avatar
src={user_picture_base_url + venue.user_profile_pic}
size={35}
radius={35}
mx="auto"
/>
</div>
<div className="w-50 ms-4 me-2 align-content-center">
{venue.username}
</div>
<div className="w-75 ms-2 me-2 align-content-center">
{venue.email}
</div>
<div className="w-50 ms-2 me-2 align-content-center">
{venue.college_affiliation}
</div>
<div className="w-50 ms-2 me-2 align-content-center">
{venue.club}
</div>
</div>
</div>
</button>
</h2>
<div
id={`collapedAdmins${index}`} // Ensure unique IDs for approved bookings
className="accordion-collapse collapse"
aria-labelledby={`headingApproved${index}`}
data-bs-parent="#accordionExample"
>
<div className="d-flex justify-content-between px-5 ">
<div className="d-flex text-center align-items-center justify-content-center">
<div className="me-2 fw-bold text-dark text-opacity-25 ">
Password:
</div>
<div className="accordion-body">{venue.password}</div>
</div>
<div className="d-flex text-center align-items-center justify-content-center">
<div className="me-2 fw-bold text-dark text-opacity-25 ">
Position:
</div>
<div className="accordion-body">{venue.position}</div>
</div>
<div className="d-flex text-center align-items-center justify-content-center">
<div className="me-2 fw-bold text-dark text-opacity-25 ">
Account Type:
</div>
<div className="accordion-body">{venue.account_type}</div>
</div>

<div className="d-flex text-center align-items-center justify-content-center">
{" "}
<button
className="btn me-2 text-dark fw-semibold"
style={{ backgroundColor: "#FF8F8F" }}
onClick={() => handleDelete(venue.user_id)}
>
Delete
</button>
</div>
<div className="d-flex text-center align-items-center justify-content-center">
{" "}
{/* <IconTrash
// onClick={() => handleDelete(venue.booking_id)}
size={22}
className="me-3"
/>
<IconEdit size={22} /> */}
</div>
</div>
</div>
</div>
))}
</div>
</div>
{/* Pagination */}
<div className="d-flex justify-content-center mt-3">
<nav aria-label="Page navigation example">
<ul className="pagination">
{Array.from(
{ length: Math.ceil(isApproved.length / itemsPerPage) },
(_, i) => (
<li
key={i}
className={`page-item ${
currentPage === i + 1 ? "active" : ""
}`}
>
<button
className="page-link"
onClick={() => handlePageChange(i + 1)}
>
{i + 1}
</button>
</li>
)
)}
</ul>
</nav>
</div>
</div>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions client/keystone/src/Components/ArchivedVenues.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import axios from "axios";

import { UserLink } from "../App";
function ArchivedVenues() {
const [archivedVenue, setArchivedVenue] = useState([]);
const [currentPage, setCurrentPage] = useState(1);
Expand All @@ -25,7 +25,7 @@ function ArchivedVenues() {
const fetchVenues = () => {
// ARCHIVED VENUES
axios
.get("http://localhost:5000/booking_archived")
.get(`${UserLink}/booking_archived`)
.then((res) => {
if (Array.isArray(res.data)) {
setArchivedVenue(res.data);
Expand All @@ -37,7 +37,7 @@ function ArchivedVenues() {
};
const handleRestore = (venue_id) => {
axios
.post(`http://localhost:5000/restore_venue/${venue_id}`)
.post(`${UserLink}/restore_venue/${venue_id}`)
.then((res) => {
console.log(res.data);
fetchVenues(); // Re-fetch the venues after deleting
Expand Down
9 changes: 5 additions & 4 deletions client/keystone/src/Components/Archives/Admins.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { useEffect, useState } from "react";
// import { Link } from "react-router-dom";
import axios from "axios";

import { UserLink } from "../../App";
function Admins() {
const [isPending, setIsPending] = useState([]);
const [restore, setRestored] = useState(true);
const [dropped, setDropped] = useState([]);

useEffect(() => {
axios
.get("http://localhost:5000/deleted_admins")
.get(`${UserLink}/deleted_admins`)
.then((res) => {
if (Array.isArray(res.data)) {
setIsPending(res.data);
Expand All @@ -20,7 +21,7 @@ function Admins() {
}, [restore, dropped]);
function handleRestore(user_id) {
axios
.post(`http://localhost:5000/restore_user/${user_id}`)
.post(`${UserLink}/restore_user/${user_id}`)
.then((res) => {
console.log(res.data);
// Toggle the 'deleted' state to trigger a re-fetch of the data
Expand All @@ -31,7 +32,7 @@ function Admins() {
}
function handleDrop(user_id) {
axios
.post(`http://localhost:5000/drop_users/${user_id}`)
.post(`${UserLink}/drop_users/${user_id}`)
.then((res) => {
console.log(res.data);
setDropped((prevDropped) => !prevDropped);
Expand Down
6 changes: 3 additions & 3 deletions client/keystone/src/Components/Archives/Bookings.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useEffect, useState } from "react";
// import { Link } from "react-router-dom";
import axios from "axios";

import { UserLink } from "../../App";
function Bookings() {
const [isPending, setIsPending] = useState([]);
const [restore, setRestored] = useState([]);

useEffect(() => {
axios
.get("http://localhost:5000/deleted_bookings")
.get(`${UserLink}/deleted_bookings`)
.then((res) => {
if (Array.isArray(res.data)) {
setIsPending(res.data);
Expand All @@ -20,7 +20,7 @@ function Bookings() {
}, [restore]);
function handleRestore(user_id) {
axios
.post(`http://localhost:5000/restore_user/${user_id}`)
.post(`${UserLink}/restore_user/${user_id}`)
.then((res) => {
console.log(res.data);
// Toggle the 'deleted' state to trigger a re-fetch of the data
Expand Down
Loading