@@ -34,10 +34,8 @@ export default function EmployeeTable({
3434} ) {
3535 const handleSort = ( field ) => {
3636 if ( sortField === field ) {
37- // toggle sort order if same field clicked
3837 setSortOrder ( ( prev ) => ( prev === "asc" ? "desc" : "asc" ) ) ;
3938 } else {
40- // set new field to sort by
4139 setSortField ( field ) ;
4240 setSortOrder ( "asc" ) ;
4341 }
@@ -54,32 +52,46 @@ export default function EmployeeTable({
5452 } ;
5553
5654 return (
57- < div className = "bg-white rounded-lg shadow p-6" >
55+ < div className = "bg-white rounded-lg shadow p-4 sm:p- 6" >
5856 { /* Header */ }
59- < div className = "flex items-center justify-between mb-4" >
60- < h3 className = "text-lg font-semibold" > { title } </ h3 >
61- < div className = "flex gap-3" >
57+ < div className = "flex flex-col sm:flex-row sm:items-center sm:justify-between mb-4 gap-3" >
58+ < h3 className = "text-base sm:text-lg font-semibold text-center sm:text-left" >
59+ { title }
60+ </ h3 >
61+
62+ { /* Controls */ }
63+ < div className = "flex flex-col sm:flex-row gap-3 w-full sm:w-auto" >
6264 { /* Sort Select */ }
6365 < Select value = { sortOrder } onValueChange = { setSortOrder } >
64- < SelectTrigger className = "w-[160px] text-sm" >
66+ < SelectTrigger className = "w-full sm:w- [160px] text-sm cursor-pointer " >
6567 < SelectValue placeholder = "Sort by Projects" />
6668 </ SelectTrigger >
6769 < SelectContent >
68- < SelectItem value = "desc" > Most Projects</ SelectItem >
69- < SelectItem value = "asc" > Least Projects</ SelectItem >
70+ < SelectItem value = "desc" className = "cursor-pointer" >
71+ Most Projects
72+ </ SelectItem >
73+ < SelectItem value = "asc" className = "cursor-pointer" >
74+ Least Projects
75+ </ SelectItem >
7076 </ SelectContent >
7177 </ Select >
7278
7379 { /* Position Filter */ }
7480 < Select value = { positionFilter } onValueChange = { setPositionFilter } >
75- < SelectTrigger className = "w-[160px] text-sm" >
81+ < SelectTrigger className = "w-full sm:w- [160px] text-sm cursor-pointer " >
7682 < SelectValue placeholder = "Filter by Position" />
7783 </ SelectTrigger >
7884 < SelectContent >
79- < SelectItem value = "all" > All Positions</ SelectItem >
85+ < SelectItem value = "all" className = "cursor-pointer" >
86+ All Positions
87+ </ SelectItem >
8088 { Array . isArray ( positionsList ) &&
8189 positionsList . map ( ( p ) => (
82- < SelectItem key = { p . _id || p . id } value = { p . _id || p . id } >
90+ < SelectItem
91+ key = { p . _id || p . id }
92+ value = { p . _id || p . id }
93+ className = "cursor-pointer"
94+ >
8395 { p . name }
8496 </ SelectItem >
8597 ) ) }
@@ -94,8 +106,8 @@ export default function EmployeeTable({
94106 No employee data available
95107 </ p >
96108 ) : (
97- < div className = "rounded-md border" >
98- < Table >
109+ < div className = "rounded-md border overflow-x-auto " >
110+ < Table className = "min-w-[600px]" >
99111 < TableHeader >
100112 < TableRow >
101113 < TableHead
@@ -125,14 +137,16 @@ export default function EmployeeTable({
125137 { employees . map ( ( emp , i ) => (
126138 < TableRow key = { i } className = "hover:bg-muted/50" >
127139 < TableCell className = "flex items-center gap-3 py-3" >
128- < div className = "w-10 h-10 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white text-sm font-semibold" >
140+ < div className = "w-8 h-8 sm:w- 10 sm: h-10 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white text-xs sm: text-sm font-semibold" >
129141 { emp . name
130142 . split ( " " )
131143 . map ( ( n ) => n [ 0 ] )
132144 . join ( "" )
133145 . toUpperCase ( ) }
134146 </ div >
135- < span className = "text-sm font-medium" > { emp . name } </ span >
147+ < span className = "text-sm font-medium truncate max-w-[120px] sm:max-w-none" >
148+ { emp . name }
149+ </ span >
136150 </ TableCell >
137151 < TableCell className = "text-sm" > { emp . position } </ TableCell >
138152 < TableCell className = "text-sm" > { emp . manager } </ TableCell >
@@ -154,17 +168,17 @@ export default function EmployeeTable({
154168
155169 { /* Pagination */ }
156170 { total > 0 && (
157- < div className = "flex items-center justify-between mt-4 pt-4 border-t" >
158- < p className = "text-sm text-muted-foreground" >
171+ < div className = "flex flex-col sm:flex-row items-center justify-between mt-4 pt-4 border-t gap-3 " >
172+ < p className = "text-xs sm:text- sm text-muted-foreground" >
159173 Page { pageIndex + 1 } of { Math . ceil ( total / pageSize ) }
160174 </ p >
161- < div className = "flex gap-2" >
175+ < div className = "flex gap-2 w-full sm:w-auto justify-center sm:justify-end " >
162176 < Button
163177 variant = "outline"
164178 size = "sm"
165179 onClick = { ( ) => setPageIndex ( ( p ) => Math . max ( p - 1 , 0 ) ) }
166180 disabled = { pageIndex === 0 }
167- className = "cursor-pointer"
181+ className = "cursor-pointer w-1/2 sm:w-auto "
168182 >
169183 Previous
170184 </ Button >
@@ -177,7 +191,7 @@ export default function EmployeeTable({
177191 )
178192 }
179193 disabled = { pageIndex + 1 >= Math . ceil ( total / pageSize ) }
180- className = "cursor-pointer"
194+ className = "cursor-pointer w-1/2 sm:w-auto "
181195 >
182196 Next
183197 </ Button >
0 commit comments