import React from 'react'; import ReactMarkdown from 'react-markdown'; import { MapSummary } from '../types/Map'; import "../css/Maps.css" interface SummaryProps { selectedRun: number setSelectedRun: (x: number) => void; data: MapSummary; } const Summary: React.FC = ({ selectedRun, setSelectedRun, data }) => { const [selectedCategory, setSelectedCategory] = React.useState(1); const [historySelected, setHistorySelected] = React.useState(false); function _select_run(idx: number, category_id: number) { let r = document.querySelectorAll("button.record"); r.forEach(e => (e as HTMLElement).style.backgroundColor = "#2b2e46"); (r[idx] as HTMLElement).style.backgroundColor = "#161723" if (data && data.summary.routes.length !== 0 && data.summary.routes.length !== 0) { if (category_id === 2) { idx += data.summary.routes.filter(e => e.category.id < 2).length } if (category_id === 3) { idx += data.summary.routes.filter(e => e.category.id < 3).length } if (category_id === 4) { idx += data.summary.routes.filter(e => e.category.id < 4).length } setSelectedRun(idx); } } function _get_youtube_id(url: string): string { const urlArray = url.split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); return (urlArray[2] !== undefined) ? urlArray[2].split(/[^0-9a-z_]/i)[0] : urlArray[0]; }; function _category_change() { const btn = document.querySelectorAll("#section3 #category span button"); btn.forEach((e) => { (e as HTMLElement).style.backgroundColor = "#2b2e46" }); (btn[selectedCategory - 1] as HTMLElement).style.backgroundColor = "#202232"; }; function _history_change() { const btn = document.querySelectorAll("#section3 #history span button"); btn.forEach((e) => { (e as HTMLElement).style.backgroundColor = "#2b2e46" }); (historySelected ? btn[1] as HTMLElement : btn[0] as HTMLElement).style.backgroundColor = "#202232"; }; React.useEffect(() => { _history_change(); }, [historySelected]); React.useEffect(() => { _category_change(); _select_run(0, selectedCategory); }, [selectedCategory]); React.useEffect(() => { _select_run(0, selectedCategory); }, []); return ( <>

{data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].history.score_count} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].history.score_count === 1 ? ` portal` : ` portals`}

{data.map.is_coop ? : }
{data.summary.routes.filter(e => e.category.id === selectedCategory).length === 0 ?
There are no records for this map.
: <>
Date Record First Completion

{data.summary.routes .sort((a, b) => a.history.score_count - b.history.score_count) .filter(e => e.category.id === selectedCategory) .map((r, index) => ( ))}
}
{data.summary.routes.filter(e => e.category.id === selectedCategory).length === 0 ?
There are no records for this map.
:
{/*
{graph(1)}
{graph(2)}
{graph(3)}
*/}
}
Difficulty {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 0 ? (N/A) : null} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 1 ? (Very easy) : null} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 2 ? (Easy) : null} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 3 ? (Medium) : null} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 4 ? (Hard) : null} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 5 ? (Very hard) : null}
{data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 1 ? (
) : (
)} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 2 ? (
) : (
)} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 3 ? (
) : (
)} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 4 ? (
) : (
)} {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].rating === 5 ? (
) : (
)}
Completion Count
{data.summary.routes[selectedRun].completion_count}
{data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].showcase !== "" ? : ""}

Route Description

{data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].description}
); }; export default Summary;