/** * @file Offline modal component showing gold earned while away. * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { useGame } from "../../context/gameContext.js"; import type { JSX } from "react"; /** * Renders the offline earnings modal if the player earned resources offline. * @returns The JSX element or null if no offline earnings. */ const OfflineModal = (): JSX.Element | null => { const { offlineGold, offlineEssence, dismissOfflineGold, formatNumber } = useGame(); if (offlineGold <= 0 && offlineEssence <= 0) { return null; } return (

{"Welcome back!"}

{"Your adventurers kept working whilst you were away and earned:"}

{offlineGold > 0 &&

{"🪙 "} {formatNumber(offlineGold)} {" gold"}

} {offlineEssence > 0 &&

{"✨ "} {formatNumber(offlineEssence)} {" essence"}

}

{"Offline progress is calculated up to 8 hours."}

); }; export { OfflineModal };