Skip to content

Commit 480773b

Browse files
set round on teams
1 parent b26421e commit 480773b

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/components/changeRound.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ import {
99
SelectLabel,
1010
} from "@/components/ui/select";
1111
import { type Row } from "@tanstack/react-table"; // Adjust the import based on your setup
12-
import { useEffect, useState } from "react";
13-
import toast from "react-hot-toast";
14-
import { Leaderboard } from "@/api/leaderboard";
12+
import { useState } from "react";
13+
import { type Leaderboard } from "@/api/leaderboard";
1514
import { setTeamRound } from "@/api/teams";
1615

17-
interface SelectCellProps {
18-
row: Row<Leaderboard>;
19-
}
2016

21-
function ChangeRound({ row }: SelectCellProps) {
17+
18+
function ChangeRound({ id }: {id:string}) {
2219
const queryClient = useQueryClient();
2320

2421
const [selectedValue, setSelectedValue] = useState<string>("");
@@ -35,12 +32,12 @@ function ChangeRound({ row }: SelectCellProps) {
3532
});
3633
//So, even if mutation.mutate fails its gonna set to new value. Fix should be ez
3734
const handleValueChange = (round: string) => {
38-
mutation.mutate({ id: row.original.team_id, round: round });
35+
mutation.mutate({ id: id, round: round });
3936
setSelectedValue(round); // Update local state immediately
4037
};
4138

4239
return (
43-
<div className="w-full">
40+
<div className="flex items-center justify-center">
4441
<Select
4542
value={selectedValue}
4643
disabled={mutation.isPending}

src/components/columns/LeaderBoardCol.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const columns: ColumnDef<z.infer<typeof leaderboardUserSchema>>[] = [
2323
{
2424
accessorKey: "ID",
2525
header: "Set Round",
26-
cell: ({ row }) => <ChangeRound row={row} />,
26+
cell: ({ row }) => <ChangeRound id={row.original.team_id} />,
2727
},
2828
];
2929

src/components/columns/TeamCol.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { type Team } from "@/data/schema";
88
import { Button } from "@/components/ui/button";
99
import { useRouter } from "next/navigation";
1010
import { ArrowRight } from "lucide-react";
11+
import ChangeRound from "../changeRound";
1112

1213
const TeamActions = ({ teamId }: { teamId: string | null }) => {
1314
const router = useRouter();
@@ -59,6 +60,11 @@ const columns: ColumnDef<Team>[] = [
5960
);
6061
},
6162
},
63+
{
64+
accessorKey: "ID",
65+
header: "Set Round",
66+
cell: ({ row }) => <ChangeRound id={row.original.ID} />,
67+
},
6268
];
6369

6470
export default columns;

src/data/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const usersResponseSchema = z.object({
4646

4747

4848
export const teamSchema = z.object({
49-
ID: z.string().nullable(),
49+
ID: z.string(),
5050
Name: z.string().nullable(),
5151
NumberOfPeople: z.number(),
5252
RoundQualified: z.number(),

0 commit comments

Comments
 (0)