From 7d21ab0048a0b667fb0687a529f0042d79e9481a Mon Sep 17 00:00:00 2001 From: Patrick Hulin Date: Sat, 31 Aug 2024 12:42:31 -0400 Subject: [PATCH] Fix course certificate linting. --- .../resources/2023/SITCourseCertificate.tsx | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/client/src/sections/resources/2023/SITCourseCertificate.tsx b/client/src/sections/resources/2023/SITCourseCertificate.tsx index 45528c65..8debf507 100644 --- a/client/src/sections/resources/2023/SITCourseCertificate.tsx +++ b/client/src/sections/resources/2023/SITCourseCertificate.tsx @@ -1,24 +1,23 @@ -import { Box, Text, VStack } from "@chakra-ui/react"; -import { $item, $skill, get, have } from "libram"; -import { useEffect } from "react"; +import { Text } from "@chakra-ui/react"; +import { myHash } from "kolmafia"; +import { $skill, get, have } from "libram"; +import { ReactNode, useMemo } from "react"; import Line from "../../../components/Line"; import Tile from "../../../components/Tile"; import { NagPriority } from "../../../contexts/NagContext"; import useNag from "../../../hooks/useNag"; -import { haveUnrestricted } from "../../../util/available"; const SITCertificate = () => { - const sitCertificate = $item`S.I.T. Course Completion Certificate`; - const completedSITToday = get("_sitCourseCompleted"); const inRun = get("kingLiberated") === false; + const hash = myHash(); - const psychogeologist = $skill`Psychogeologist`; - const insectologist = $skill`Insectologist`; - const cryptobotanist = $skill`Cryptobotanist`; + const havePsychogeologist = have($skill`Psychogeologist`); + const haveInsectologist = have($skill`Insectologist`); + const haveCryptobotanist = have($skill`Cryptobotanist`); const hasAnySkill = - have(psychogeologist) || have(insectologist) || have(cryptobotanist); + havePsychogeologist || haveInsectologist || haveCryptobotanist; const miscPhrases = [ "Don't play hooky!", @@ -32,16 +31,27 @@ const SITCertificate = () => { const randomPhrase = miscPhrases[Math.floor(Math.random() * miscPhrases.length)]; - let subtitle = ""; - if (have(psychogeologist)) - subtitle = - "You have ML; consider Insectology, for meat?"; - if (have(insectologist)) - subtitle = - "You have Meat; consider Psychogeology, for ML?"; - if (have(cryptobotanist)) - subtitle = - "You have Init; consider Insectology, for meat?"; + const subtitle: ReactNode = useMemo(() => { + if (havePsychogeologist) { + return ( + <> + You have ML; consider Insectology, for meat? + + ); + } else if (haveInsectologist) { + return ( + <> + You have Meat; consider Psychogeology, for ML? + + ); + } else if (haveCryptobotanist) { + return ( + <> + You have Init; consider Insectology, for meat? + + ); + } else return <>; + }, [haveCryptobotanist, haveInsectologist, havePsychogeologist]); useNag( () => ({ @@ -50,14 +60,10 @@ const SITCertificate = () => { {!hasAnySkill && ( - - - {randomPhrase} Take your S.I.T. course! - - + {randomPhrase} Take your S.I.T. course! )} {hasAnySkill && inRun && ( @@ -65,15 +71,15 @@ const SITCertificate = () => { )} {hasAnySkill && !inRun && ( - - Could change your S.I.T. skill, for new items... - {subtitle} - + <> + Could change your S.I.T. skill, for new items... + {subtitle} + )} ), }), - [hasAnySkill, inRun, subtitle], + [hasAnySkill, hash, inRun, randomPhrase, subtitle], ); return null;