@@ -56,8 +56,8 @@ export default function MatchDetailsList() {
5656 honorPoint : item . honor_point ,
5757 point : item . point ,
5858 completedTime : item . completed_time_second ,
59- p1_postion : item . p1_position ,
60- p2_postion : item . p2_position ,
59+ p1_position : item . p1_position ,
60+ p2_position : item . p2_position ,
6161 whitePins : item . white_pins ,
6262 penaltyPins : item . penalty_pins ,
6363 yellowCard : item . yellow_cards ,
@@ -157,43 +157,57 @@ export default function MatchDetailsList() {
157157 </ p >
158158 ) : (
159159 < div className = "space-y-10 px-4 pb-8 pt-4" >
160- { sortedMatchData . map ( ( match , idx ) => (
161- < div key = { idx } >
162- < h2 className = "subtitle mb-4 font-semibold text-primary" >
163- { match [ 0 ] ?. matchName ?? `Match ${ idx + 1 } ` }
164- </ h2 >
165- < table className = "min-w-full bg-white shadow" >
166- < thead >
167- < tr className = "bg-primary text-center text-xs font-bold text-white sm:text-sm md:text-base" >
168- { header . map ( ( col , i ) => (
169- < th key = { i } className = "whitespace-nowrap px-2 py-2" >
170- { col }
171- </ th >
172- ) ) }
173- </ tr >
174- </ thead >
175- < tbody className = "body-sm text-center" >
176- { match . map ( ( row , index ) => (
177- < tr
178- key = { index }
179- className = "border-b border-gray-200 bg-green-50 hover:bg-gray-100"
180- >
181- < td className = "px-4 py-2" > { row . teamName } </ td >
182- < td className = "px-4 py-2" > { row . whitePins } </ td >
183- < td className = "px-4 py-2" > { row . penaltyPins } </ td >
184- < td className = "px-4 py-2" > { row . yellowCard } </ td >
185- < td className = "px-4 py-2" > { row . redCard } </ td >
186- < td className = "px-4 py-2" > { row . p1_postion } </ td >
187- < td className = "px-4 py-2" > { row . p2_postion } </ td >
188- < td className = "px-4 py-2" > { row . honorPoint } </ td >
189- < td className = "px-4 py-2" > { row . point } </ td >
190- < td className = "px-4 py-2" > { row . completedTime } </ td >
160+ { sortedMatchData . map ( ( match , idx ) => {
161+ // Sort teams within each match
162+ const sortedTeams = [ ...match ] . sort ( ( a , b ) => {
163+ // Sort by: honor point DESC, point DESC, completed time ASC
164+ if ( b . honorPoint !== a . honorPoint ) {
165+ return b . honorPoint - a . honorPoint ;
166+ } else if ( b . point !== a . point ) {
167+ return b . point - a . point ;
168+ } else {
169+ return a . completedTime - b . completedTime ;
170+ }
171+ } ) ;
172+
173+ return (
174+ < div key = { idx } >
175+ < h2 className = "subtitle mb-4 font-semibold text-primary" >
176+ { match [ 0 ] ?. matchName ?? `Match ${ idx + 1 } ` }
177+ </ h2 >
178+ < table className = "min-w-full bg-white shadow" >
179+ < thead >
180+ < tr className = "bg-primary text-center text-xs font-bold text-white sm:text-sm md:text-base" >
181+ { header . map ( ( col , i ) => (
182+ < th key = { i } className = "whitespace-nowrap px-2 py-2" >
183+ { col }
184+ </ th >
185+ ) ) }
191186 </ tr >
192- ) ) }
193- </ tbody >
194- </ table >
195- </ div >
196- ) ) }
187+ </ thead >
188+ < tbody className = "body-sm text-center" >
189+ { sortedTeams . map ( ( row , index ) => (
190+ < tr
191+ key = { index }
192+ className = "border-b border-gray-200 bg-green-50 hover:bg-gray-100"
193+ >
194+ < td className = "px-4 py-2" > { row . teamName } </ td >
195+ < td className = "px-4 py-2" > { row . whitePins } </ td >
196+ < td className = "px-4 py-2" > { row . penaltyPins } </ td >
197+ < td className = "px-4 py-2" > { row . yellowCard } </ td >
198+ < td className = "px-4 py-2" > { row . redCard } </ td >
199+ < td className = "px-4 py-2" > { row . p1_position } </ td >
200+ < td className = "px-4 py-2" > { row . p2_position } </ td >
201+ < td className = "px-4 py-2" > { row . honorPoint } </ td >
202+ < td className = "px-4 py-2" > { row . point } </ td >
203+ < td className = "px-4 py-2" > { row . completedTime } </ td >
204+ </ tr >
205+ ) ) }
206+ </ tbody >
207+ </ table >
208+ </ div >
209+ ) ;
210+ } ) }
197211 </ div >
198212 )
199213 ) : (
0 commit comments