From c614f86fbfd5253a67923d8eb0b0d788fff4645c Mon Sep 17 00:00:00 2001 From: Gizmotronn Date: Thu, 17 Oct 2024 17:53:51 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=90=F0=9F=AA=B1=20=E2=86=9D=20[SSM-27]?= =?UTF-8?q?:=20Mission=20pathway=20component=20now=20shows=20helper=20comp?= =?UTF-8?q?onents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Missions/CompletedMissions.tsx | 109 +++++++++++++--------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/components/Missions/CompletedMissions.tsx b/components/Missions/CompletedMissions.tsx index 49ec265a..0a442b8d 100644 --- a/components/Missions/CompletedMissions.tsx +++ b/components/Missions/CompletedMissions.tsx @@ -8,6 +8,8 @@ import { UnownedSurfaceStructures } from "../Structures/Build/EditMode"; import LaunchpadStatus from "../Structures/Launchpad/LaunchpadStatus"; import SwitchPlanet from "../(scenes)/travel/SolarSystem"; import { DataSourcesModal } from "../Data/unlockNewDataSources"; +import Link from "next/link"; +import { Button } from "../ui/button"; type Planet = "Earth" | "Mars" | "Mercury" | "New Planet"; type Mission = { @@ -207,55 +209,76 @@ export default function CompletedMissions() { fetchCompletedMissions(); }, [session]); - const getMissionStatus = (mission: MissionRoute) => { - const isCompleted = completedMissions.includes(parseInt(mission.mission)); - return { - title: mission.title, - isCompleted, - missionId: mission.id, - }; - }; - - const renderMission = (mission: MissionRoute, planet: Planet) => { - const missionStatus = getMissionStatus(mission); - return ( -
  • - {missionStatus.isCompleted ? ( - - ) : ( - - )} - {missionStatus.title} -
  • - ); - }; - + const isMissionCompleted = (missionRoute: MissionRoute): boolean => { + if (!missionRoute.mission) return false; + return completedMissions.includes(Number(missionRoute.mission)); + }; + + const [showComponent, setShowComponent] = useState(false); + return (
    - {Object.keys(missionsData).map((playStyleKey) => ( -
    -

    {playStyleKey.toUpperCase()}

    - {Object.keys(missionsData[playStyleKey as PlayStyle] ?? {}).map((planetKey) => ( -
    -

    - {planetKey} -

    -
      - {missionsData[playStyleKey as PlayStyle][planetKey as Planet]?.map((mission) => - renderMission(mission, planetKey as Planet) - )} + {Object.entries(missionsData).map(([playStyle, planets]) => ( +
      +

      {playStyle}

      + + {Object.entries(planets || {}).map(([planet, missions]) => ( +
      +

      {planet}

      +
        + {missions?.map((missionRoute) => { + const [showInfo, setShowInfo] = useState(false); + + return ( +
      • +
        + {missionRoute.title} + {isMissionCompleted(missionRoute) ? ( + + ) : ( + Incomplete + )} +
        + {missionRoute.infoText && ( + <> + + {showInfo &&

        {missionRoute.infoText}

        } + + )} + {missionRoute.route && ( + + + + )} + {missionRoute.component && ( + <> + + {showComponent && ( +
        + {missionRoute.component} +
        + )} + + )} +
      • + ); + })}
      ))}
      ))}
    - ); + ); }; \ No newline at end of file