Skip to content

Commit 3d281c4

Browse files
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents 72f37d3 + d7cc17c commit 3d281c4

4 files changed

Lines changed: 113 additions & 73 deletions

File tree

src/app/idea/ModalTeamIdea.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"use client";
2+
import { type ideaType } from "@/api/fetchIdeas";
3+
import { Button } from "@/components/ui/button";
4+
import {
5+
Dialog,
6+
DialogClose,
7+
DialogContent,
8+
DialogDescription,
9+
DialogHeader,
10+
DialogTitle,
11+
DialogTrigger,
12+
} from "@/components/ui/dialog";
13+
import { Lightbulb } from "lucide-react";
14+
15+
export const ModalTeamIdea = ({
16+
children,
17+
row,
18+
}: {
19+
children: React.ReactNode;
20+
row: ideaType;
21+
}) => {
22+
return (
23+
<Dialog>
24+
<DialogTrigger asChild>{children}</DialogTrigger>
25+
<DialogContent className="max-w-[600px]">
26+
<DialogHeader>
27+
<DialogTitle className="flex items-center gap-2 text-xl font-bold">
28+
<Lightbulb className="h-6 w-6 text-yellow-500" /> Idea Details
29+
</DialogTitle>
30+
<DialogDescription className="text-gray-400">
31+
Here are details about the selected idea.
32+
</DialogDescription>
33+
</DialogHeader>
34+
<div className="grid w-full gap-6 py-4">
35+
<div className="flex items-center gap-2 text-lg">
36+
Idea Title: {row.Title}
37+
</div>
38+
<div>
39+
<div className="break-words text-base">Description:</div>
40+
<div className="break-all text-base">{row.Description}</div>
41+
</div>
42+
</div>
43+
<div className="flex justify-end">
44+
<DialogClose asChild>
45+
<Button variant="outline">Close</Button>
46+
</DialogClose>
47+
</div>
48+
</DialogContent>
49+
</Dialog>
50+
);
51+
};

src/app/idea/page.tsx

Lines changed: 50 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
"use client";
2-
import { fetchIdeas, ideaType } from "@/api/fetchIdeas";
3-
import { fetchTeams } from "@/api/teams";
2+
import { fetchIdeas, type ideaType } from "@/api/fetchIdeas";
3+
import loading from "@/assets/images/loading.gif";
44
import { DataTable } from "@/components/table/data-table";
55
import { DataTableColumnHeader } from "@/components/table/data-table-column-header";
6-
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
76
import {
87
Select,
98
SelectContent,
109
SelectItem,
1110
SelectTrigger,
1211
SelectValue,
1312
} from "@/components/ui/select";
14-
import loading from "@/assets/images/loading.gif";
1513
import Image from "next/image";
1614

17-
import { type Team } from "@/data/schema";
15+
import { Button } from "@/components/ui/button";
1816
import { useQuery, useQueryClient } from "@tanstack/react-query";
1917
import { type ColumnDef } from "@tanstack/react-table";
2018
import { useEffect, useState } from "react";
19+
import { ModalTeamIdea } from "./ModalTeamIdea";
2120

2221
export default function TeamsIdeasTable() {
2322
const queryClient = useQueryClient();
@@ -62,6 +61,7 @@ export default function TeamsIdeasTable() {
6261
queryKey: ["idea"],
6362
});
6463
}, [selectedTrack]);
64+
6565
const handlePrevPage = () => {
6666
if (cursorHistory.length > 0) {
6767
const prevCursor = cursorHistory[cursorHistory.length - 1]; // Get last cursor
@@ -76,7 +76,9 @@ export default function TeamsIdeasTable() {
7676
<DataTableColumnHeader column={column} title="Team ID" />
7777
),
7878
cell: ({ row }) => (
79-
<div className="text-center">{row.original.TeamID}</div>
79+
<span className="relative block max-w-[100px] cursor-pointer truncate text-ellipsis whitespace-nowrap text-white">
80+
{row.original.TeamID}
81+
</span>
8082
),
8183
},
8284
{
@@ -98,9 +100,9 @@ export default function TeamsIdeasTable() {
98100
<DataTableColumnHeader column={column} title="Description" />
99101
),
100102
cell: ({ row }) => (
101-
<div className="max-w-[300px] truncate">
102-
{row.original.Description ?? "No description"}
103-
</div>
103+
<ModalTeamIdea row={row.original}>
104+
<Button>View</Button>
105+
</ModalTeamIdea>
104106
),
105107
},
106108
{
@@ -142,51 +144,44 @@ export default function TeamsIdeasTable() {
142144
}
143145

144146
return (
145-
<Card className="w-full">
146-
<CardHeader>
147-
<CardTitle>Ideas </CardTitle>
148-
</CardHeader>
149-
<CardContent>
150-
<div className="mb-6 flex flex-wrap gap-4">
151-
<input
152-
type="text"
153-
placeholder="Search teams or submissions..."
154-
className="w-64 rounded-md border border-gray-300 p-2"
155-
value={searchTerm}
156-
onChange={(e) => setSearchTerm(e.target.value)}
157-
/>
158-
<Select
159-
value={selectedTrack ?? ""}
160-
onValueChange={(value) => {
161-
setSelectedTrack(
162-
value === "all" ? "" : String(Number(value) ),
163-
);
164-
}}
165-
>
166-
<SelectTrigger className="w-48 p-6">
167-
<SelectValue placeholder="Filter by track" />
168-
</SelectTrigger>
169-
<SelectContent>
170-
<SelectItem value="all">All Tracks</SelectItem>
171-
{tracks.map((track, index) => (
172-
<SelectItem key={track} value={String(index + 1)}>
173-
{track}
174-
</SelectItem>
175-
))}
176-
</SelectContent>
177-
</Select>
178-
</div>
179-
{ (
180-
<DataTable
181-
columns={columns}
182-
data={ideasData?.idea.ideas ?? []}
183-
handleNextPage={handleNextPage}
184-
handlePrevPage={handlePrevPage}
185-
setPageLimit={setPageLimit}
186-
pageLimit={pageLimit}
187-
/>
188-
)}
189-
</CardContent>
190-
</Card>
147+
<>
148+
<div className="mb-6 flex flex-wrap gap-4">
149+
<input
150+
type="text"
151+
placeholder="Search teams or submissions..."
152+
className="w-64 rounded-md border border-gray-300 p-2"
153+
value={searchTerm}
154+
onChange={(e) => setSearchTerm(e.target.value)}
155+
/>
156+
<Select
157+
value={selectedTrack ?? ""}
158+
onValueChange={(value) => {
159+
setSelectedTrack(value === "all" ? "" : String(Number(value)));
160+
}}
161+
>
162+
<SelectTrigger className="w-48 p-6">
163+
<SelectValue placeholder="Filter by track" />
164+
</SelectTrigger>
165+
<SelectContent>
166+
<SelectItem value="all">All Tracks</SelectItem>
167+
{tracks.map((track, index) => (
168+
<SelectItem key={track} value={String(index + 1)}>
169+
{track}
170+
</SelectItem>
171+
))}
172+
</SelectContent>
173+
</Select>
174+
</div>
175+
{
176+
<DataTable
177+
columns={columns}
178+
data={ideasData?.idea.ideas ?? []}
179+
handleNextPage={handleNextPage}
180+
handlePrevPage={handlePrevPage}
181+
setPageLimit={setPageLimit}
182+
pageLimit={pageLimit}
183+
/>
184+
}
185+
</>
191186
);
192187
}

src/components/changeRound.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
import { useQueryClient, useMutation } from "@tanstack/react-query";
1+
import { setTeamRound } from "@/api/teams";
22
import {
33
Select,
4-
SelectTrigger,
5-
SelectValue,
64
SelectContent,
75
SelectGroup,
86
SelectItem,
97
SelectLabel,
8+
SelectTrigger,
9+
SelectValue,
1010
} from "@/components/ui/select";
11-
import { type Row } from "@tanstack/react-table"; // Adjust the import based on your setup
11+
import { useMutation, useQueryClient } from "@tanstack/react-query";
1212
import { useState } from "react";
13-
import { type Leaderboard } from "@/api/leaderboard";
14-
import { setTeamRound } from "@/api/teams";
15-
1613

17-
18-
function ChangeRound({ id }: {id:string}) {
14+
function ChangeRound({ id }: { id: string }) {
1915
const queryClient = useQueryClient();
2016

2117
const [selectedValue, setSelectedValue] = useState<string>("");
22-
18+
2319
const mutation = useMutation({
2420
mutationFn: (data: { id: string; round: string }) => {
2521
return setTeamRound(data.id, Number(data.round));
@@ -37,13 +33,13 @@ function ChangeRound({ id }: {id:string}) {
3733
};
3834

3935
return (
40-
<div className="flex items-center justify-center">
36+
<div className="flex items-center">
4137
<Select
4238
value={selectedValue}
4339
disabled={mutation.isPending}
4440
onValueChange={handleValueChange}
4541
>
46-
<SelectTrigger className="m-2 rounded-md border bg-[#121212] p-2">
42+
<SelectTrigger className="m-2 w-min rounded-md border bg-[#121212] p-2">
4743
<SelectValue placeholder={`Select Round`} />
4844
</SelectTrigger>
4945
<SelectContent>

src/components/navbar.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ export function Navbar() {
4646
<div className="flex items-center space-x-4">
4747
<DropdownMenu>
4848
<DropdownMenuTrigger asChild>
49-
<Button variant="ghost" className="relative">
50-
<Avatar>
51-
<AvatarImage src="https://github.com/shadcn.png" />
52-
<AvatarFallback>CN</AvatarFallback>
53-
</Avatar>
54-
</Button>
49+
<Avatar className="hover:cursor-pointer">
50+
<AvatarImage src="https://github.com/shadcn.png" />
51+
<AvatarFallback>CN</AvatarFallback>
52+
</Avatar>
5553
</DropdownMenuTrigger>
5654
<DropdownMenuContent align="end">
5755
<DropdownMenuItem

0 commit comments

Comments
 (0)