2023-06-15 13:06:41 +00:00
|
|
|
import {Component, type JSX} from "preact";
|
|
|
|
import {createToursCompleted} from "../../storage/common.js";
|
2023-07-01 10:41:54 +00:00
|
|
|
import {TourId} from "../../tours/exports.js";
|
2023-06-15 13:06:41 +00:00
|
|
|
import {Tour} from "./tour.js";
|
|
|
|
|
|
|
|
type Props = Record<string, unknown>;
|
|
|
|
|
|
|
|
type State = {
|
|
|
|
toursCompleted: Awaited<ReturnType<typeof createToursCompleted>>["value"];
|
|
|
|
};
|
|
|
|
|
|
|
|
export class Tours extends Component<Props, State> {
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
toursCompleted: new Set(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount(): Promise<void> {
|
|
|
|
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<Tour["props"]> = [
|
2023-07-01 10:41:54 +00:00
|
|
|
createTour(TourId.Introduction, "Introduction"),
|
|
|
|
createTour(TourId.InterfaceHomepage, "The Homepage"),
|
2023-06-15 13:06:41 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<main>
|
|
|
|
<h2>Tours</h2>
|
|
|
|
<div class="tours">
|
|
|
|
{tourProps.map((props) => (
|
|
|
|
<Tour {...props} />
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|