/** * @file Quest toast notification component for completed and failed quests. * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ /* eslint-disable react/no-multi-comp -- Sub-components are tightly coupled to their containers */ import { type JSX, useEffect } from "react"; import { useGame } from "../../context/gameContext.js"; import type { Quest } from "@elysium/types"; interface QuestToastItemProperties { readonly quest: Quest; readonly onDismiss: (id: string)=> void; // eslint-disable-next-line react/require-default-props -- Default value set in destructuring readonly isFailure?: boolean; } /** * Renders a single quest toast notification. * @param props - The toast item properties. * @param props.quest - The quest to display. * @param props.onDismiss - Callback to dismiss the toast. * @param props.isFailure - Whether this is a failure toast. * @returns The JSX element. */ const QuestToastItem = ({ quest, onDismiss, isFailure = false, }: QuestToastItemProperties): JSX.Element => { useEffect(() => { const timer = setTimeout(() => { onDismiss(quest.id); }, 4000); return (): void => { clearTimeout(timer); }; }, [ quest.id, onDismiss ]); function handleClick(): void { onDismiss(quest.id); } return (