import React from "react"; import ReactMarkdown from "react-markdown"; import { MapSummary } from "@customTypes/Map"; 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); const _select_run = React.useCallback( (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) { idx += data.summary.routes.filter( e => e.category.id < category_id ).length; // lethimcook setSelectedRun(idx); } }, [data, setSelectedRun] ); 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]; } const _category_change = React.useCallback(() => { const btn = document.querySelectorAll("#section3 #category span button"); btn.forEach(e => { (e as HTMLElement).style.backgroundColor = "#2b2e46"; }); // heavenly father forgive me for i have sinned. TODO: fix this bullshit with dynamic categories const idx = selectedCategory === 1 ? 0 : data.map.is_coop ? selectedCategory - 3 : selectedCategory - 1; (btn[idx] as HTMLElement).style.backgroundColor = "#202232"; }, [selectedCategory, data.map.is_coop]); const _history_change = React.useCallback(() => { 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"; }, [historySelected]); React.useEffect(() => { _history_change(); }, [historySelected, _history_change]); React.useEffect(() => { _category_change(); _select_run(0, selectedCategory); }, [selectedCategory, _category_change, _select_run]); React.useEffect(() => { _select_run(0, selectedCategory); }, [_select_run, selectedCategory]); return ( <>

{data.summary.routes[selectedRun].history.score_count} {data.summary.routes[selectedRun].history.score_count === 1 ? ` portal` : ` portals`}

{data.map.is_coop ? ( // TODO: make this part dynamic ) : ( )}
{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 .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.map.difficulty <= 2 && ( Very Easy )} {data.map.difficulty > 2 && data.map.difficulty <= 4 && ( Easy )} {data.map.difficulty > 4 && data.map.difficulty <= 6 && ( Medium )} {data.map.difficulty > 6 && data.map.difficulty <= 8 && ( Hard )} {data.map.difficulty > 8 && data.map.difficulty <= 10 && ( Very Hard )}
{data.map.difficulty <= 2 && ? (
) : (
)} {data.map.difficulty > 2 && data.map.difficulty <= 4 && ? (
) : (
)} {data.map.difficulty > 4 && data.map.difficulty <= 6 && ? (
) : (
)} {data.map.difficulty > 6 && data.map.difficulty <= 8 && ? (
) : (
)} {data.map.difficulty > 8 && data.map.difficulty <= 10 && ? (
) : (
)}
Completion Count
{data.summary.routes[selectedRun].completion_count}
{data.summary.routes[selectedRun].showcase !== "" ? ( ) : ( "" )}

Route Description

{data.summary.routes[selectedRun].description}
); }; export default Summary;