From 90e627bbc70b9f959d8de61114aee871a997f328 Mon Sep 17 00:00:00 2001 From: Serena Li Date: Tue, 20 Feb 2024 23:32:01 -0500 Subject: [PATCH] Style requestscrimmodal --- frontend2/src/components/EpisodeSwitcher.tsx | 2 +- .../src/components/elements/Checkbox.tsx | 44 ++++++ frontend2/src/components/elements/Pill.tsx | 8 +- .../src/components/elements/SelectMenu.tsx | 2 +- .../elements/SelectMultipleMenu.tsx | 4 +- .../tables/scrimmaging/RequestScrimModal.tsx | 146 ++++++++++-------- 6 files changed, 131 insertions(+), 75 deletions(-) create mode 100644 frontend2/src/components/elements/Checkbox.tsx diff --git a/frontend2/src/components/EpisodeSwitcher.tsx b/frontend2/src/components/EpisodeSwitcher.tsx index 05c1375ba..486f52190 100644 --- a/frontend2/src/components/EpisodeSwitcher.tsx +++ b/frontend2/src/components/EpisodeSwitcher.tsx @@ -36,7 +36,7 @@ const EpisodeSwitcher: React.FC = () => { queryFn: async () => await getEpisodeInfo({ id: newEpisodeId }), }))().catch((e) => toast.error((e as Error).message)); setEpisodeId(newEpisodeId); - navigate(`${newEpisodeId}/home`); + navigate(`/${newEpisodeId}/home`); }} >
diff --git a/frontend2/src/components/elements/Checkbox.tsx b/frontend2/src/components/elements/Checkbox.tsx new file mode 100644 index 000000000..e8c93ed67 --- /dev/null +++ b/frontend2/src/components/elements/Checkbox.tsx @@ -0,0 +1,44 @@ +import React from "react"; +import Icon from "./Icon"; +import { Switch } from "@headlessui/react"; +import FormLabel from "./FormLabel"; + +interface CheckboxProps { + disabled?: boolean; + checked?: boolean; + onChange: (checked: boolean) => void; + label?: string; +} + +const Checkbox: React.FC = ({ + disabled = false, + checked = false, + onChange, + label, +}) => { + return ( + + {label !== undefined && ( + + + + )} + + + + + ); +}; + +export default Checkbox; diff --git a/frontend2/src/components/elements/Pill.tsx b/frontend2/src/components/elements/Pill.tsx index 3b372e4cd..f7ddcc2ab 100644 --- a/frontend2/src/components/elements/Pill.tsx +++ b/frontend2/src/components/elements/Pill.tsx @@ -4,7 +4,7 @@ import Icon from "./Icon"; interface PillProps { text: string; deletable?: boolean; - onDelete?: (ev?: React.MouseEvent) => void; + onDelete?: (ev?: React.MouseEvent) => void; className?: string; } @@ -20,15 +20,15 @@ const Pill: React.FC = ({ > {text} {deletable && ( - +
)} ); diff --git a/frontend2/src/components/elements/SelectMenu.tsx b/frontend2/src/components/elements/SelectMenu.tsx index 2a6aa303c..3ce90a26e 100644 --- a/frontend2/src/components/elements/SelectMenu.tsx +++ b/frontend2/src/components/elements/SelectMenu.tsx @@ -62,7 +62,7 @@ function SelectMenu({
diff --git a/frontend2/src/components/elements/SelectMultipleMenu.tsx b/frontend2/src/components/elements/SelectMultipleMenu.tsx index 0f108f0d5..674efc4a2 100644 --- a/frontend2/src/components/elements/SelectMultipleMenu.tsx +++ b/frontend2/src/components/elements/SelectMultipleMenu.tsx @@ -78,7 +78,7 @@ function SelectMultipleMenu({
@@ -101,7 +101,7 @@ function SelectMultipleMenu({ value={option.value} >
{option.label}
- + diff --git a/frontend2/src/components/tables/scrimmaging/RequestScrimModal.tsx b/frontend2/src/components/tables/scrimmaging/RequestScrimModal.tsx index 2d00b35ad..006765eb5 100644 --- a/frontend2/src/components/tables/scrimmaging/RequestScrimModal.tsx +++ b/frontend2/src/components/tables/scrimmaging/RequestScrimModal.tsx @@ -13,9 +13,7 @@ import { clone } from "lodash"; import SelectMenu from "components/elements/SelectMenu"; import SelectMultipleMenu from "components/elements/SelectMultipleMenu"; import Button from "components/elements/Button"; -import DescriptiveCheckbox, { - CheckboxState, -} from "components/elements/DescriptiveCheckbox"; +import Checkbox from "components/elements/Checkbox"; interface RequestScrimModalProps { teamToRequest: TeamPublic; @@ -24,7 +22,7 @@ interface RequestScrimModalProps { closeModal: () => void; } -// Team statuses that allow for ranked scrims. +// Only allow ranked scrims against "Regular" teams. const ALLOWS_RANKED = Status526Enum.R; const MAX_MAPS_PER_SCRIM = 10; const ORDER_OPTIONS = [ @@ -73,82 +71,96 @@ const RequestScrimModal: React.FC = ({ title={`Request scrimmage with ${teamToRequest.name}`} > { -
- { - setSelectedOrder(newOrder); - }} - /> - - errorMessage={mapErrorMessage} - disabled={ranked} - label="Select Maps" - placeholder={ranked ? "Random 3 maps!" : "Select up to 10 maps..."} - options={ - maps.map((map) => ({ - value: map.name, - label: map.name, - })) ?? [] - } - value={selectedMapNames} - onChange={(newMapNames) => { - if (newMapNames.length > MAX_MAPS_PER_SCRIM) { - setMapErrorMessage("You can only select up to 10 maps."); - return; - } - setMapErrorMessage(undefined); - setSelectedMapNames(newMapNames); - }} - /> -
}