@@ -9,23 +9,20 @@ import {
99 SelectLabel ,
1010} from "@/components/ui/select" ;
1111import { 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" ;
1514import { 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 > ( "" ) ;
2522
2623 const mutation = useMutation ( {
2724 mutationFn : ( data : { id : string ; round : string } ) => {
28- return setTeamRound ( data . id , data . round ) ;
25+ return setTeamRound ( data . id , Number ( data . round ) ) ;
2926 } ,
3027 onSuccess : async ( ) => {
3128 await queryClient . invalidateQueries ( {
@@ -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 }
0 commit comments