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

Commit

Permalink
Merge pull request #23 from Programming-Club-Ahmedabad-University/all…
Browse files Browse the repository at this point in the history
…/leaderboards-carousel

all progress so far and chakra activated!!!
  • Loading branch information
JeelRajodiya authored Oct 11, 2023
2 parents 8882016 + 20a3633 commit 3204889
Show file tree
Hide file tree
Showing 21 changed files with 3,310 additions and 4,669 deletions.
7,374 changes: 2,924 additions & 4,450 deletions client/package-lock.json

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
"lint": "next lint"
},
"dependencies": {
"@nextui-org/react": "^2.0.24",
"@chakra-ui/next-js": "^2.1.5",
"@chakra-ui/react": "^2.8.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@types/node": "20.5.0",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"eslint": "8.47.0",
"eslint-config-next": "13.4.16",
"framer-motion": "^10.16.0",
"framer-motion": "^10.16.4",
"mongodb": "^6.1.0",
"next": "^13.5.4",
"next-auth": "^4.23.1",
Expand All @@ -25,10 +28,5 @@
"redis": "^4.6.10",
"swr": "^2.2.2",
"typescript": "5.1.6"
},
"devDependencies": {
"autoprefixer": "^10.4.15",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3"
}
}
48 changes: 31 additions & 17 deletions client/pages/Admin/LeaderboardConfig.module.css
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
.main {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
height: 100%;
gap: 1em;
}

.addWrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 1em;
width: 100%;
max-width: 30em;
height: max-content;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 1em;
width: 100%;
max-width: 30em;
height: max-content;
}
.addBtn {
display: flex;
flex: 1;
display: flex;
flex: 1;

font-size: 1.5em;
font-size: 1.5em;
}
.addInput {
flex: 10;
flex: 10;
}

.listContent {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
gap: 1em;
width: 100%;
height: 100%;
overflow-y: auto;
padding: 0 1em;
}
14 changes: 9 additions & 5 deletions client/pages/Admin/LeaderboardConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fetcher, myToast } from "@/util/functions";
import RootLayout from "../Layout";
import styles from "./LeaderboardConfig.module.css";
import useSWR from "swr";

function useContests() {
const { data, error, isLoading, mutate } = useSWR(
`/api/admin/contestConfig`,
Expand Down Expand Up @@ -38,15 +39,17 @@ async function postContest(
}

import toast, { Toaster } from "react-hot-toast";
import { Button, Input } from "@nextui-org/react";
import { Box, Button, Input } from "@chakra-ui/react";
import React from "react";

export default function LeaderboardConfig() {
const { contests, isLoading, isError, mutate } = useContests();
const [contest, setContest] = React.useState("");
const [isLoadingPost, setIsLoadingPost] = React.useState(false);
const [isErrorPost, setIsErrorPost] = React.useState(false);

let listOfContests;

if (isLoading) {
listOfContests = <div>Loading...</div>;
} else if (isError) {
Expand All @@ -57,6 +60,7 @@ export default function LeaderboardConfig() {
return <div key={contest}>{contest}</div>;
});
}

return (
<RootLayout>
<main className={styles.main}>
Expand All @@ -66,12 +70,11 @@ export default function LeaderboardConfig() {
placeholder="Enter contest number"
className={styles.addInput}
value={contest}
onChange={(e) => setContest(e.target.value)}
onChange={(e: any) => setContest(e.target.value)}
/>

<Button
variant="ghost"
color="primary"
variant={"primary"}
className={styles.addBtn}
onClick={() => {
postContest(
Expand All @@ -92,8 +95,9 @@ export default function LeaderboardConfig() {
+
</Button>
</div>

<Toaster position="bottom-right" reverseOrder={false} />
<div>{listOfContests}</div>
<div className={styles.listConent}>{listOfContests}</div>
</main>
</RootLayout>
);
Expand Down
8 changes: 0 additions & 8 deletions client/pages/Layout.module.css

This file was deleted.

2 changes: 1 addition & 1 deletion client/pages/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import "./globals.css";

import type { Metadata } from "next";
import styles from "./Layout.module.css";
import styles from "./styles/Layout.module.css";
import NavBar from "./components/NavBar/NavBar";

// for the fonts:
Expand Down
7 changes: 4 additions & 3 deletions client/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { AppProps } from "next/app";
import type { Session } from "next-auth";
import "./styles/globals.css";

import { NextUIProvider } from "@nextui-org/react";
import { ChakraProvider } from "@chakra-ui/react";
import theme from "@/util/theme";

export default function App({
Component,
Expand All @@ -13,9 +14,9 @@ export default function App({
return (
<main className="dark text-foreground bg-background">
<SessionProvider session={session}>
<NextUIProvider>
<ChakraProvider theme={theme}>
<Component {...pageProps} />
</NextUIProvider>
</ChakraProvider>
</SessionProvider>
</main>
);
Expand Down
93 changes: 44 additions & 49 deletions client/pages/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import styles from "./Navbar.module.css";

import {
Avatar,
Navbar,
NavbarBrand,
NavbarContent,
NavbarItem,
} from "@nextui-org/react";
import {
Dropdown,
DropdownTrigger,
DropdownMenu,
DropdownItem,
PopoverTrigger,
Button,
} from "@nextui-org/react";
PopoverContent,
Menu,
MenuButton,
MenuList,
} from "@chakra-ui/react";

import Link from "next/link";
import { signIn, signOut, useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { useState } from "react";

export default function NavBar() {
const { data: session } = useSession();
const [loading, setLoading] = useState(false);
Expand All @@ -28,6 +27,7 @@ export default function NavBar() {
link: "/",
},
];

if (session && session.user) {
if (session.user.role === "Admin") {
navItems.push({
Expand All @@ -36,22 +36,28 @@ export default function NavBar() {
});
}
authBtn = (
<>
<Dropdown className="dark text-foreground ">
<DropdownTrigger>
<Avatar src={session.user.image!} />
</DropdownTrigger>
<DropdownMenu aria-label="Static Actions">
<DropdownItem
key="new"
color="danger"
onClick={() => signOut()}
<div className={styles.navMenu}>
<Menu>
<MenuButton>
<Avatar
className={styles.avatarButton}
src={session.user.image!}
/>
</MenuButton>
<MenuList className={styles.menuList} minWidth='100x'>
<Button
variant={"secondary"}
onClick={() =>
signOut({
callbackUrl: "/",
})
}
>
Sign out
</DropdownItem>
</DropdownMenu>
</Dropdown>
</>
</Button>
</MenuList>
</Menu>
</div>
);
} else {
authBtn = (
Expand All @@ -70,38 +76,27 @@ export default function NavBar() {
}

return (
<Navbar>
<NavbarBrand>
<p className="font-bold text-inherit">COC </p>
</NavbarBrand>
<NavbarContent className="hidden sm:flex gap-4" justify="center">
<div className={styles.mainNav}>
<div className={styles.navItem}>
{navItems.map((item) => (
<NavbarItem key={item.name}>
<div key={item.name}>
<Link href={item.link}>
<div
className={
item.link != router.pathname
? "text-foreground"
: "text-primary"
}
>
{item.name}
</div>
<div>{item.name}</div>
</Link>
</NavbarItem>
</div>
))}
</NavbarContent>
<NavbarContent justify="end">
</div>
<div className={styles.mainNavSide}>
{session && session.user && (
<>
<div>
{session.user.name}
<small>{session.user.role}</small>
<div className={styles.sideItems}>
<div>{session.user.name}</div>
<div>{session.user.role}</div>
</div>
</>
)}
<NavbarItem>{authBtn}</NavbarItem>
</NavbarContent>
</Navbar>
<div>{authBtn}</div>
</div>
</div>
);
}
49 changes: 49 additions & 0 deletions client/pages/components/NavBar/Navbar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.mainNav {
margin: 0.5em;
padding: 0.5em;
display: flex;
flex-direction: row;
justify-content: space-between;
background-color: rgb(60, 60, 60);
border-radius: 0.5em;
}

.mainNavSide {
display: flex;
flex-direction: row;
justify-content: space-between;
gap: 1em;
color: white;
}

.sideItems {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
}
.sideItems > :nth-child(2) {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: flex-end;
gap: 1em;
width: 100%;
}

.navItem {
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.5em;
}

.avatarButton {
cursor: pointer;
}
.menuList {
min-width: 100px;
padding: 0.3em;
}
23 changes: 23 additions & 0 deletions client/pages/components/ScoreCard/ScoreCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.tableHeader {
display: flex;
flex-direction: row;
align-items: center;
padding: 0 1rem;
/* margin-bottom: 1rem; */
gap:20px;
}

.tableEntry{
display: flex;
flex-direction: row;
width: 100%;
justify-content: space-between;
align-items: center;
padding: 0 1rem;
/* margin-bottom: 1rem; */
}
.tableWrapper{
display: flex;
flex-direction: column;
width: max-content;
}
Loading

0 comments on commit 3204889

Please sign in to comment.