@@ -55,13 +55,17 @@ export function TableFilters({ filters, onFilterChange }: TableFiltersProps) {
5555 async function fetchProjects ( ) {
5656 const { data, error } = await supabase
5757 . from ( "projects" )
58- . select ( "id, name, start_date" ) ;
58+ . select ( "id, name, start_date" )
59+ . order ( "name" ) ;
5960
6061 if ( error ) {
6162 console . error ( "Failed to fetch projects:" , error ) ;
6263 } else if ( data ) {
64+ const sortedProjects = [ ...data ] . sort ( ( a : any , b : any ) =>
65+ ( a . name || "" ) . localeCompare ( b . name || "" ) ,
66+ ) ;
6367 setProjects (
64- data . map ( ( proj : any ) => ( {
68+ sortedProjects . map ( ( proj : any ) => ( {
6569 ...proj ,
6670 start_date : proj . start_date || "" ,
6771 } ) ) as Project [ ] ,
@@ -84,16 +88,23 @@ export function TableFilters({ filters, onFilterChange }: TableFiltersProps) {
8488 . filter ( ( pos : any ) => pos !== null && pos !== "" ) ,
8589 ) ,
8690 ) as string [ ] ;
91+ distinctPositions . sort ( ( a , b ) => a . localeCompare ( b ) ) ;
8792 setDisplayPositions ( distinctPositions ) ;
8893 }
8994 }
9095
9196 async function fetchRoles ( ) {
92- const { data, error } = await supabase . from ( "roles" ) . select ( "id, name" ) ;
97+ const { data, error } = await supabase
98+ . from ( "roles" )
99+ . select ( "id, name" )
100+ . order ( "name" ) ;
93101 if ( error ) {
94102 console . error ( "Failed to fetch roles:" , error ) ;
95103 } else if ( data ) {
96- setRoles ( data as Role [ ] ) ;
104+ const sortedRoles = [ ...data ] . sort ( ( a : any , b : any ) =>
105+ ( a . name || "" ) . localeCompare ( b . name || "" ) ,
106+ ) ;
107+ setRoles ( sortedRoles as Role [ ] ) ;
97108 }
98109 }
99110
0 commit comments