11import { useQuery } from "@tanstack/react-query" ;
22import { createFileRoute } from "@tanstack/react-router" ;
3- import { countBy } from "es-toolkit/compat" ;
3+ import { countBy , sample } from "es-toolkit/compat" ;
44import { useCallback , useState } from "react" ;
55import GridIcon from "@/components/icons/GridIcon" ;
66import { MISSION_GUIDE_COMPLETED_KEY } from "@/constants/mission" ;
@@ -69,13 +69,13 @@ const createMissionCardProps = (
6969 return {
7070 ...baseProps ,
7171 completedAt : mission . attempts ?. [ 0 ] ?. createdAt ,
72- holdImageUrl : mission . imageUrl ,
72+ holdImageUrl : sample ( mission . gymLevel ?. imageUrls ?? [ ] ) ,
7373 } ;
7474 case "failed" :
7575 return {
7676 ...baseProps ,
7777 removedAt : mission . removedAt ,
78- holdImageUrl : mission . imageUrl ,
78+ holdImageUrl : sample ( mission . gymLevel ?. imageUrls ?? [ ] ) ,
7979 } ;
8080 default :
8181 return baseProps ;
@@ -97,10 +97,15 @@ function Mission() {
9797 getRouteMissionRecommendations ( { headers : getHeaderToken ( ) } ) ,
9898 select : ( data ) => {
9999 const missions = data . data ?? [ ] ;
100- return missions . map ( ( mission ) => ( {
101- ...mission ,
102- status : calculateMissionStatus ( mission . attempts ) ,
103- } ) ) ;
100+ return missions
101+ . map ( ( mission ) => ( {
102+ ...mission ,
103+ status : calculateMissionStatus ( mission . attempts ) ,
104+ } ) )
105+ . sort ( ( a , b ) => {
106+ const statusOrder = { not_tried : 0 , failed : 1 , success : 2 } ;
107+ return statusOrder [ a . status ] - statusOrder [ b . status ] ;
108+ } ) ;
104109 } ,
105110 enabled : isSessionStarted ,
106111 } ) ;
0 commit comments