From a77479260a1831787f82da60469ae6e761e7a93f Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:16:21 +0300 Subject: frontend: fix coop map categories --- frontend/src/components/Summary.tsx | 73 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 31 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/Summary.tsx b/frontend/src/components/Summary.tsx index 23da82c..79e989f 100644 --- a/frontend/src/components/Summary.tsx +++ b/frontend/src/components/Summary.tsx @@ -21,13 +21,11 @@ const Summary: React.FC = ({ selectedRun, setSelectedRun, data }) (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 } + if (data && data.summary.routes.length !== 0) { + idx += data.summary.routes.filter(e => e.category.id < category_id).length // lethimcook setSelectedRun(idx); } - } + }; function _get_youtube_id(url: string): string { const urlArray = url.split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); @@ -37,7 +35,9 @@ const Summary: React.FC = ({ selectedRun, setSelectedRun, data }) 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"; + // 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"; }; function _history_change() { @@ -47,7 +47,7 @@ const Summary: React.FC = ({ selectedRun, setSelectedRun, data }) }; React.useEffect(() => { - _history_change(); + _history_change(); }, [historySelected]); React.useEffect(() => { @@ -65,15 +65,27 @@ const Summary: React.FC = ({ selectedRun, setSelectedRun, data })
-

{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[selectedRun].history.score_count} + {data.summary.routes[selectedRun].history.score_count === 1 ? ` portal` : ` portals`}

+ {data.map.is_coop ? // TODO: make this part dynamic + ( + + + + + + ) + : + ( + + + + + + + + ) + }
@@ -91,7 +103,6 @@ const Summary: React.FC = ({ selectedRun, setSelectedRun, data })
{data.summary.routes - .sort((a, b) => a.history.score_count - b.history.score_count) .filter(e => e.category.id === selectedCategory) .map((r, index) => (
- +
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[selectedRun].rating === 0 && (N/A)} + {data.summary.routes[selectedRun].rating === 1 && (Very easy)} + {data.summary.routes[selectedRun].rating === 2 && (Easy)} + {data.summary.routes[selectedRun].rating === 3 && (Medium)} + {data.summary.routes[selectedRun].rating === 4 && (Hard)} + {data.summary.routes[selectedRun].rating === 5 && (Very hard)}
- {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 ? (
) : (
)} + {data.summary.routes[selectedRun].rating === 1 ? (
) : (
)} + {data.summary.routes[selectedRun].rating === 2 ? (
) : (
)} + {data.summary.routes[selectedRun].rating === 3 ? (
) : (
)} + {data.summary.routes[selectedRun].rating === 4 ? (
) : (
)} + {data.summary.routes[selectedRun].rating === 5 ? (
) : (
)}
@@ -151,13 +162,13 @@ const Summary: React.FC = ({ selectedRun, setSelectedRun, data })
- {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].showcase !== "" ? + {data.summary.routes[selectedRun].showcase !== "" ? : ""}

Route Description

- {data.summary.routes.sort((a, b) => a.category.id - b.category.id)[selectedRun].description} + {data.summary.routes[selectedRun].description}
-- cgit v1.2.3