Skip to content

Commit

Permalink
Merge pull request #77 from acm-ucr/shahdivyank/judging
Browse files Browse the repository at this point in the history
Judging
  • Loading branch information
shahdivyank authored Jul 14, 2023
2 parents 9edc2db + 7a3f205 commit 9c78ce9
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/admin/judging/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Judging from "@/components/Judging";
import React from "react";

const Page = () => {
return (
<div>
<Judging />
</div>
);
};

export default Page;
63 changes: 63 additions & 0 deletions src/components/Judging.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"use client";
import React, { useState } from "react";
import Radio from "../components/Radio";

const Judging = () => {
const [input, setInput] = useState("");
const [judges, setJudges] = useState({
professors: [],
industry: [],
students: [],
current: "",
});

const handleInput = (e) => {
setInput(e.target.value);
};

const handleSubmit = () => {
const judgesFormatted = input.split(",").map((judge) => judge.trim());
setJudges({ ...judges, [judges.current]: judgesFormatted });
};

const removeJudge = (judge, index) => {
console.log(judge, index);
setJudges({
...judges,
[judge]: judges[judge].filter((a, i) => i !== index),
});
};

return (
<div>
<Radio
options={Object.keys(judges).filter(
(a) => typeof judges[a] === "object"
)}
field="current"
user={judges}
setUser={setJudges}
/>
<textarea onChange={handleInput} />
<button onClick={handleSubmit}>ADD JUDGES</button>

{Object.keys(judges)
.filter((a) => typeof judges[a] === "object")
.map((judge) => (
<>
<p>{judge} Judges</p>
{judges[judge].map((name, index) => (
<div key={index}>
{name}
<button onClick={() => removeJudge(judge, index)}>
REMOVE
</button>
</div>
))}
</>
))}
</div>
);
};

export default Judging;
6 changes: 6 additions & 0 deletions src/data/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BsGlobe2,
BsBoxArrowInRight,
} from "react-icons/bs";
import { FaGavel } from "react-icons/fa";

const iconStyle = "text-2xl mr-2 mt-2 mb-2";

Expand All @@ -19,6 +20,11 @@ export const AdminTabs = [
link: "/admin/teams",
icon: <BsPeopleFill className={iconStyle} />,
},
{
name: "judging",
link: "/admin/judging",
icon: <FaGavel className={iconStyle} />,
},
{
name: "statistics",
link: "/admin/statistics",
Expand Down

0 comments on commit 9c78ce9

Please sign in to comment.