From 1d85cd467cee8ed43ddfa72678dce9cd768869fe Mon Sep 17 00:00:00 2001 From: Aaron Kable Date: Mon, 30 Dec 2024 16:38:44 +0800 Subject: [PATCH] update skill queue --- .../src/Components/Cards/PortraitCard.tsx | 4 +- .../frontend/src/Pages/Char/SkillQueue.tsx | 178 ++++++++++++++---- 2 files changed, 141 insertions(+), 41 deletions(-) diff --git a/frontend/frontend/src/Components/Cards/PortraitCard.tsx b/frontend/frontend/src/Components/Cards/PortraitCard.tsx index 7a56d2c0..96ac6bcd 100644 --- a/frontend/frontend/src/Components/Cards/PortraitCard.tsx +++ b/frontend/frontend/src/Components/Cards/PortraitCard.tsx @@ -14,6 +14,7 @@ export declare interface PortraitCardProps { headerIcon?: string; roundedImages?: string; character: any; //todo type from api? + portaitSize?: number; } export function PortraitCard({ @@ -26,6 +27,7 @@ export function PortraitCard({ headerIcon, heading, roundedImages, + portaitSize = 350, }: PortraitCardProps) { return ( diff --git a/frontend/frontend/src/Pages/Char/SkillQueue.tsx b/frontend/frontend/src/Pages/Char/SkillQueue.tsx index 611795fe..5c6c52b9 100644 --- a/frontend/frontend/src/Pages/Char/SkillQueue.tsx +++ b/frontend/frontend/src/Pages/Char/SkillQueue.tsx @@ -2,9 +2,11 @@ import { PortraitCard } from "../../Components/Cards/PortraitCard"; import { ErrorLoader, PanelLoader } from "../../Components/Loaders/loaders"; import { SkillLevelBlock } from "../../Components/Skills/SkillLevelBlock"; import { getCharacterSkillQueues } from "../../api/character"; -import { Table } from "react-bootstrap"; +import { useState } from "react"; +import { Form, FormGroup, Table } from "react-bootstrap"; import { useQuery } from "react-query"; import { useParams } from "react-router-dom"; +import ReactTimeAgo from "react-time-ago"; const CharacterSkillQueues = () => { const { characterID } = useParams(); @@ -14,53 +16,149 @@ const CharacterSkillQueues = () => { { refetchOnWindowFocus: false } ); + const [activeFilter, setActive] = useState(true); + const [pausedFilter, setPaused] = useState(true); + const [emptyFilter, setEmpty] = useState(false); + + if (isLoading) return ; + + if (error) return ; + + const handleActive = (e) => { + setActive(e.currentTarget.checked); + }; + + const handlePaused = (e) => { + setPaused(e.currentTarget.checked); + }; + + const handleEmpty = (e) => { + setEmpty(e.currentTarget.checked); + }; + + let filtered_data = data.filter((char: any) => { + let active = false; + let paused = false; + let empty = false; + if (char.queue) { + if (char.queue.length && char.queue[0].end) { + active = true; + } else if (char.queue.length) { + paused = true; + } else { + empty = true; + } + } else { + empty = true; + } + return (activeFilter && active) || (emptyFilter && empty) || (pausedFilter && paused); + }); + if (isLoading) return ; if (error) return ; return ( -
- {data?.map((char: any) => { - return ( - -
-
- - - - - - - -
SkillLevel
-
- - - {char.queue?.map((s: any) => { - return ( - - - - - ); - })} - + <> +
Filters
+ + + + + + +
+ {filtered_data?.map((char: any) => { + let char_status = char.queue.length ? { border: "success" } : { border: "warning" }; + if (char.queue.length > 0 && !char.queue[0].end) { + char_status = { border: "info" }; + } + + return ( + +
+ {char.character.corporation_name} + {char.character.alliance_name && ` (${char.character.alliance_name})`} +
+
+
+
{s.skill} - -
+ + + + + +
SkillLevel
+
+ + + {char.queue?.map((s: any) => { + return ( + + + + ); + })} + +
+
+

{s.skill}

+ +
+
+ {s.end ? ( + <> + +

+ {(s.end_sp - s.start_sp).toLocaleString()}/ + {s.end_sp.toLocaleString()} SP +

+ + ) : ( + <> + +

+ {(s.end_sp - s.start_sp).toLocaleString()}/ + {s.end_sp.toLocaleString()} SP +

+ + )} +
+
+
-
-
- ); - })} -
+ + ); + })} + + ); };