@@ -16,105 +16,83 @@ import { useQuery } from "@tanstack/react-query";
1616import { type ColumnDef } from "@tanstack/react-table" ;
1717import { useEffect , useState } from "react" ;
1818
19- interface TeamData {
20- id : string ;
21- name : string | null ;
22- numberOfPeople : number ;
23- roundQualified : number ;
24- submission : ideaType | null ;
25- }
26-
2719export default function TeamsIdeasTable ( ) {
2820 const [ pageLimit , setPageLimit ] = useState ( 10 ) ;
2921 const [ searchTerm , setSearchTerm ] = useState ( "" ) ;
3022 const [ currentPage , setCurrentPage ] = useState ( 0 ) ;
3123 const [ selectedTrack , setSelectedTrack ] = useState < string > ( "" ) ;
32- const [ filteredData , setFilteredData ] = useState < TeamData [ ] > ( [ ] ) ;
3324 const [ availableTracks , setAvailableTracks ] = useState < string [ ] > ( [ ] ) ;
3425
3526 const {
36- data : teamsData ,
37- isLoading : teamsLoading ,
38- isError : teamsError ,
27+ data : ideasData ,
28+ isLoading : ideasLoading ,
29+ isError : ideasError ,
3930 } = useQuery ( {
4031 queryKey : [ "idea" , currentPage , pageLimit ] ,
4132 queryFn : ( ) =>
42- fetchTeams ( {
33+ fetchIdeas ( {
4334 limit : pageLimit ,
4435 cursorId : undefined ,
4536 } ) ,
4637 } ) ;
4738
48-
49-
50- const columns : ColumnDef < TeamData , unknown > [ ] = [
51- {
52- accessorKey : "name" ,
53- header : ( { column } ) => (
54- < DataTableColumnHeader column = { column } title = "Team Name" />
55- ) ,
56- cell : ( { row } ) => (
57- < div className = "max-w-[200px] truncate font-medium" >
58- { row . getValue ( "name" ) ?? "Unnamed Team" }
59- </ div >
60- ) ,
61- } ,
39+ const columns : ColumnDef < ideaType , unknown > [ ] = [
6240 {
6341 accessorKey : "numberOfPeople" ,
6442 header : ( { column } ) => (
6543 < DataTableColumnHeader column = { column } title = "Team Size" />
6644 ) ,
6745 cell : ( { row } ) => (
68- < div className = "text-center" > { row . getValue ( "numberOfPeople" ) } </ div >
46+ < div className = "text-center" > { row . original . TeamID } </ div >
6947 ) ,
7048 } ,
7149 {
7250 id : "submissionTitle" ,
73- accessorFn : ( row ) => row . submission ?. Title ,
51+ accessorFn : ( row ) => row . Title ,
7452 header : ( { column } ) => (
7553 < DataTableColumnHeader column = { column } title = "Submission Title" />
7654 ) ,
7755 cell : ( { row } ) => (
7856 < div className = "max-w-[200px] truncate" >
79- { row . original . submission ?. Title ?? "No submission" }
57+ { row . original . Title ?? "No submission" }
8058 </ div >
8159 ) ,
8260 } ,
8361 {
8462 id : "submissionDescription" ,
85- accessorFn : ( row ) => row . submission ?. Description ,
63+ accessorFn : ( row ) => row . Description ,
8664 header : ( { column } ) => (
8765 < DataTableColumnHeader column = { column } title = "Description" />
8866 ) ,
8967 cell : ( { row } ) => (
9068 < div className = "max-w-[300px] truncate" >
91- { row . original . submission ?. Description ?? "No description" }
69+ { row . original . Description ?? "No description" }
9270 </ div >
9371 ) ,
9472 } ,
9573 {
9674 id : "track" ,
97- accessorFn : ( row ) => row . submission ?. Track ,
75+ accessorFn : ( row ) => row . Track ,
9876 header : ( { column } ) => (
9977 < DataTableColumnHeader column = { column } title = "Track" />
10078 ) ,
10179 cell : ( { row } ) => (
10280 < div className = "max-w-[200px] truncate" >
103- { row . original . submission ?. Track ?? "Unassigned" }
81+ { row . original . Track ?? "Unassigned" }
10482 </ div >
10583 ) ,
10684 } ,
10785 ] ;
10886
109- if ( teamsLoading || submissionsLoading ) {
87+ if ( ideasLoading ) {
11088 return (
11189 < div className = "flex justify-center p-8" >
11290 < div className = "text-lg" > Loading teams and submissions...</ div >
11391 </ div >
11492 ) ;
11593 }
11694
117- if ( teamsError ) {
95+ if ( ideasError ) {
11896 return (
11997 < div className = "flex justify-center p-8" >
12098 < div className = "text-lg text-red-500" > Error loading teams data</ div >
@@ -125,7 +103,7 @@ export default function TeamsIdeasTable() {
125103 return (
126104 < Card className = "w-full" >
127105 < CardHeader >
128- < CardTitle > Teams & Submissions Dashboard </ CardTitle >
106+ < CardTitle > Ideas </ CardTitle >
129107 </ CardHeader >
130108 < CardContent >
131109 < div className = "mb-6 flex flex-wrap gap-4" >
@@ -155,14 +133,16 @@ export default function TeamsIdeasTable() {
155133 </ SelectContent >
156134 </ Select >
157135 </ div >
158- < DataTable
159- columns = { columns }
160- data = { filteredData }
161- handleNextPage = { ( ) => setCurrentPage ( ( prev ) => prev + 1 ) }
162- handlePrevPage = { ( ) => setCurrentPage ( ( prev ) => prev - 1 ) }
163- setPageLimit = { setPageLimit }
164- pageLimit = { pageLimit }
165- />
136+ { ideasData ?. idea && (
137+ < DataTable
138+ columns = { columns }
139+ data = { ideasData ?. idea }
140+ handleNextPage = { ( ) => setCurrentPage ( ( prev ) => prev + 1 ) }
141+ handlePrevPage = { ( ) => setCurrentPage ( ( prev ) => prev - 1 ) }
142+ setPageLimit = { setPageLimit }
143+ pageLimit = { pageLimit }
144+ />
145+ ) }
166146 </ CardContent >
167147 </ Card >
168148 ) ;
0 commit comments