Skip to content

Commit

Permalink
Merge pull request #879 from acm-ucr/shahdivyank/calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
menthy-wu authored Nov 13, 2023
2 parents 70e957a + 0c6e891 commit fb54a41
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 153 deletions.
243 changes: 138 additions & 105 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"react-icons": "^4.11.0",
"react-zxing": "^2.0.0",
"sharp": "^0.32.6",
"unique-names-generator": "^4.7.1",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion src/app/api/committees/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export async function POST(req) {

return res.json({ message: "OK" }, { status: 200 });
} catch (err) {
console.log(err.response.body.errors);
return res.json(
{ message: `Internal Server Error: ${err}` },
{ status: 500 }
Expand Down
4 changes: 3 additions & 1 deletion src/app/api/judges/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ export async function GET() {
query(collection(db, "users"), where("roles.judges", "in", [-1, 0, 1]))
);
snapshot.forEach((doc) => {
const { name, email, affiliation, roles, photo, timestamp } = doc.data();
const { name, email, affiliation, roles, photo, timestamp, title } =
doc.data();
output.push({
uid: doc.id,
name: name,
email: email,
affiliation: affiliation,
title: title,
status: roles.judges,
photo: photo,
selected: false,
Expand Down
17 changes: 14 additions & 3 deletions src/app/api/team/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { db } from "../../../../firebase";
import { doc, getDoc, updateDoc, addDoc, collection } from "firebase/firestore";
import { authenticate } from "@/utils/auth";
import { AUTH } from "@/data/dynamic/user/Team";
import {
uniqueNamesGenerator,
adjectives,
colors,
animals,
} from "unique-names-generator";

export async function POST() {
const res = NextResponse;
Expand All @@ -16,8 +22,13 @@ export async function POST() {
}

try {
const randomName = uniqueNamesGenerator({
dictionaries: [adjectives, colors, animals],
separator: " ",
});

const team = {
name: "",
name: randomName,
links: {
github: "",
devpost: "",
Expand Down Expand Up @@ -79,11 +90,11 @@ export async function PUT(req) {

export async function GET(req) {
const res = NextResponse;
const { auth } = await authenticate(AUTH.GET);
const { auth, message } = await authenticate(AUTH.GET);

if (auth !== 200) {
return res.json(
{ message: `Authentication Error: ${"MESSAGE VARIABLE SHOULD BE HERE"}` },
{ message: `Authentication Error: ${message}` },
{ status: auth }
);
}
Expand Down
12 changes: 8 additions & 4 deletions src/components/dynamic/admin/services/calendar/Events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ const CalendarEvents = () => {
rawEvents.forEach((item) => {
item.start = new Date(item.start.dateTime);
item.end = new Date(item.end.dateTime);
item.color =
LABELS[
item.description.split("\n")[1].split(": ")[1].toLowerCase()
].background;
const [category, assignee] = item.description
.split("\n")[0]
.split("#")
.map((item) => item.trim())
.filter((item) => item !== "");
item.category = category;
item.color = LABELS[item.category].background;
item.assignee = assignee;
item.hidden = false;
});

Expand Down
17 changes: 4 additions & 13 deletions src/components/dynamic/admin/services/calendar/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,8 @@ const CalendarModal = ({ event, setEvent }) => {
</div>
<div>
<Tag
text={event.description.split("\n")[1].split(": ")[1]}
color={
COLORS[
LABELS[
event.description
.split("\n")[1]
.split(": ")[1]
.toLowerCase()
].color
]
}
text={event.category}
color={COLORS[LABELS[event.category].color]}
/>
</div>
</div>
Expand All @@ -59,9 +50,9 @@ const CalendarModal = ({ event, setEvent }) => {
</div>
<div className="flex my-2 items-center">
<BsPersonFill className="mr-2" />
{event.description.split("\n")[0].replace("ASSIGNEE: ", "")}
{event.assignee}
</div>
<p className="mb-0">{event.description.split("\n")[2]}</p>
<p className="mb-0">{event.description.split("\n")[1]}</p>
</div>
</div>
);
Expand Down
31 changes: 12 additions & 19 deletions src/components/dynamic/user/Team.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ const Team = ({ user, setUser }) => {
figma: "",
members: [{ email: user.email, name: user.name }],
};

const handleCopy = () => {
navigator.clipboard.writeText(user.team);
toast("✅ Successfully copy team ID to clipboard!");
toast("✅ Successfully copied team id!");
};

const handleCopyLink = () => {
navigator.clipboard.writeText(
`${process.env.NEXT_PUBLIC_URL}users/join/${user.team}`
);
toast("✅ Successfully copy join link to clipboard!");
toast("✅ Successfully copied join link!");
};

const handleLeave = () => {
axios.delete("/api/members").then(() => {
toast("✅ Successfully left team!");
Expand Down Expand Up @@ -137,7 +140,7 @@ const Team = ({ user, setUser }) => {
<Input
name="figma"
type="text"
title="Figma (please set share permision)"
title="Figma"
value={team.figma.replace("https://", "")}
user={team}
editable={edit}
Expand Down Expand Up @@ -170,22 +173,12 @@ const Team = ({ user, setUser }) => {
</p>
</div>
<div className="flex items-center justify-end gap-4">
{edit && (
<Button
color="green"
size="xl"
text="done"
onClick={handleSave}
/>
)}
{!edit && (
<Button
color="green"
size="xl"
text="edit"
onClick={handleEdit}
/>
)}
<Button
color="green"
size="xl"
text={edit ? "done" : "edit"}
onClick={edit ? handleSave : handleEdit}
/>
<Button color="red" text="leave" onClick={handleLeave} />
</div>
</>
Expand Down
14 changes: 9 additions & 5 deletions src/data/dynamic/admin/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ export const LABELS = {
color: "lightgreen",
background: "!bg-hackathon-tags-lightgreen-text",
},
workshop: {
color: "grayblue",
background: "!bg-hackathon-tags-grayblue-text",
},
leads: {
color: "red",
background: "!bg-hackathon-tags-red-text",
},
hackathon: {
workshop: {
color: "grayblue",
background: "!bg-hackathon-tags-grayblue-text",
},
general: {
color: "pink",
background: "!bg-hackathon-tags-pink-text",
},
food: {
color: "yellow",
background: "!bg-hackathon-tags-yellow-text",
},
};
5 changes: 3 additions & 2 deletions src/data/dynamic/admin/Judges.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export const TAGS = [
];

export const HEADERS = [
{ text: "name", size: "w-3/12", icon: true, sort: "off" },
{ text: "name", size: "w-2/12", icon: true, sort: "off" },
{ text: "email", size: "w-3/12", icon: true, sort: "off" },
{ text: "title", size: "w-2/12", icon: true, sort: "off" },
{
text: "affiliation",
size: "w-2/12",
Expand All @@ -36,7 +37,7 @@ export const HEADERS = [
},
{
text: "status",
size: "w-2/12",
size: "w-1/12",
icon: true,
sort: "off",
hasTag: true,
Expand Down

0 comments on commit fb54a41

Please sign in to comment.