import {Component, type JSX} from "preact"; import {createToursCompleted} from "../../storage/common.js"; import {TourId} from "../../tours/exports.js"; import {Tour} from "./tour.js"; type Props = Record; type State = { toursCompleted: Awaited>["value"]; }; export class Tours extends Component { constructor(props: Props) { super(props); this.state = { toursCompleted: new Set(), }; } async componentDidMount(): Promise { const toursCompleted = await createToursCompleted(); this.setState({toursCompleted: toursCompleted.value}); } render(): JSX.Element { const {toursCompleted} = this.state; const createTour = (tourId: TourId, name: string): Tour["props"] => { return { hasBeenCompleted: toursCompleted.has(tourId), name, tourId, }; }; const tourProps: Array = [ createTour(TourId.Introduction, "Introduction"), createTour(TourId.InterfaceHomepage, "The Homepage"), ]; return (

Tours

{tourProps.map((props) => ( ))}
); } }