From 8a6060942259406c51db7762dc65b4ef54cbcb5e Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 09:08:57 -0400 Subject: [PATCH 01/13] interface refactor start --- frontend/helpers/getData.tsx | 58 +--------------------- frontend/interfaces/Events.tsx | 73 ++++++++++++++++++++++++++++ frontend/interfaces/filterEvents.tsx | 15 ------ 3 files changed, 74 insertions(+), 72 deletions(-) create mode 100644 frontend/interfaces/Events.tsx delete mode 100644 frontend/interfaces/filterEvents.tsx diff --git a/frontend/helpers/getData.tsx b/frontend/helpers/getData.tsx index 5ddac85c..84fc771e 100644 --- a/frontend/helpers/getData.tsx +++ b/frontend/helpers/getData.tsx @@ -1,62 +1,6 @@ import Events from '@/data/events.json'; -interface rawEvent { - 'Game ID': string, - Group?: string, - Title: string, - 'Short Description'?: string, - 'Long Description'?: string, - 'Event Type': string, - 'Game System'?: string, - 'Rules Edition'?: string, - 'Minimum Players'?: string, - 'Maximum Players'?: string, - 'Age Required': string, - 'Experience Required': string, - 'Materials Required': string, - 'Materials Required Details'?: string, - 'Start Date & Time': string, - Duration?: string, - 'End Date & Time': string, - 'GM Names'?: string, - Website?: string, - Email?: string, - 'Tournament?': 'No', - 'Round Number'?: string, - 'Total Rounds'?: string, - 'Minimum Play Time'?: string, - 'Attendee Registration?'?: string, - 'Cost $': string, - Location?: string, - 'Room Name'?: string, - 'Table Number'?: '', - 'Special Category'?: string, - 'Tickets Available'?: string, - 'Last Modified': string -} - -export interface NewEvent { - id: number, - gameId: string, - group?: string, - title: string, - shortDescription?: string, - longDescription?: string, - eventType: string, - gameSystem?: string, - ageRequirement: string, - experienceRequirement: string, - startDate: string, - startTime: string, - endDate: string, - endTime: string, - duration: number, - tournament: boolean, - cost: number, - location?: string, - ticketsAvailable?: number, - maxTickets?: number -} +import { NewEvent, rawEvent } from '@/interfaces/Events'; export interface UniqueFilter { [index: string]: Array diff --git a/frontend/interfaces/Events.tsx b/frontend/interfaces/Events.tsx new file mode 100644 index 00000000..740b1712 --- /dev/null +++ b/frontend/interfaces/Events.tsx @@ -0,0 +1,73 @@ +export interface filterEvents { + groups: number[], + eventTypes: number[], + gameSystems: number[], + ageRequirements: number[], + experienceRequirements: number[], + startDates: number[], + startTimes: number[], + endDates: number[], + endTimes: number[], + ifTournament: number[], + costs: number[], + locations: number[], + ticketsAvailable: number[] +} + +export interface NewEvent { + id: number, + gameId: string, + group?: string, + title: string, + shortDescription?: string, + longDescription?: string, + eventType: string, + gameSystem?: string, + ageRequirement: string, + experienceRequirement: string, + startDate: string, + startTime: string, + endDate: string, + endTime: string, + duration: number, + tournament: boolean, + cost: number, + location?: string, + ticketsAvailable?: number, + maxTickets?: number +} + +export interface rawEvent { + 'Game ID': string, + Group?: string, + Title: string, + 'Short Description'?: string, + 'Long Description'?: string, + 'Event Type': string, + 'Game System'?: string, + 'Rules Edition'?: string, + 'Minimum Players'?: string, + 'Maximum Players'?: string, + 'Age Required': string, + 'Experience Required': string, + 'Materials Required': string, + 'Materials Required Details'?: string, + 'Start Date & Time': string, + Duration?: string, + 'End Date & Time': string, + 'GM Names'?: string, + Website?: string, + Email?: string, + 'Tournament?': 'No', + 'Round Number'?: string, + 'Total Rounds'?: string, + 'Minimum Play Time'?: string, + 'Attendee Registration?'?: string, + 'Cost $': string, + Location?: string, + 'Room Name'?: string, + 'Table Number'?: '', + 'Special Category'?: string, + 'Tickets Available'?: string, + 'Last Modified': string +} \ No newline at end of file diff --git a/frontend/interfaces/filterEvents.tsx b/frontend/interfaces/filterEvents.tsx deleted file mode 100644 index 5dda4fad..00000000 --- a/frontend/interfaces/filterEvents.tsx +++ /dev/null @@ -1,15 +0,0 @@ -export interface filterEvents { - groups: number[], - eventTypes: number[], - gameSystems: number[], - ageRequirements: number[], - experienceRequirements: number[], - startDates: number[], - startTimes: number[], - endDates: number[], - endTimes: number[], - ifTournament: number[], - costs: number[], - locations: number[], - ticketsAvailable: number[] -} \ No newline at end of file From 120955a0680f53e5e4df0d6df26c6e6f32c3c4f4 Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 09:50:10 -0400 Subject: [PATCH 02/13] interface refactor --- frontend/helpers/getData.tsx | 46 +++------------------------------ frontend/interfaces/Data.tsx | 7 +++++ frontend/interfaces/Events.tsx | 2 +- frontend/interfaces/Filters.tsx | 19 ++++++++++++++ 4 files changed, 31 insertions(+), 43 deletions(-) create mode 100644 frontend/interfaces/Data.tsx create mode 100644 frontend/interfaces/Filters.tsx diff --git a/frontend/helpers/getData.tsx b/frontend/helpers/getData.tsx index 84fc771e..cd17b651 100644 --- a/frontend/helpers/getData.tsx +++ b/frontend/helpers/getData.tsx @@ -1,36 +1,7 @@ import Events from '@/data/events.json'; -import { NewEvent, rawEvent } from '@/interfaces/Events'; - -export interface UniqueFilter { - [index: string]: Array -} - -interface TournamentFilter { - true: Array, - false: Array -} - -export interface FilterTypes { - groups: UniqueFilter, - eventTypes: UniqueFilter, - gameSystems: UniqueFilter, - ageRequirements: UniqueFilter, - experienceRequirements: UniqueFilter, - startDates: UniqueFilter, - startTimes: UniqueFilter, - endDates: UniqueFilter, - endTimes: UniqueFilter, - tournament: Array, - costs: UniqueFilter, - locations: UniqueFilter, - noTickets: Array -} - -interface Data { - eventData: Array, - filters: FilterTypes -} +import { NewEvent, RawEvent } from '@/interfaces/Events'; +import { Data } from '@/interfaces/Data'; const getTime = (time: Date) => { const hours = time.getHours(); @@ -50,16 +21,7 @@ const isTournament = (eventTournament: string) => { return false; } -const toTitleCase = (str: string) => { - return str.replace( - /\w\S*/g, - function(txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - } - ); -} - -const cleanData = (events: Array) => { +const cleanData = (events: Array) => { const data: Data = { eventData: [], filters: { @@ -249,7 +211,7 @@ const cleanData = (events: Array) => { }; export default function getData() { - const rawData = Events as Array; + const rawData = Events as Array; const data = cleanData(rawData); diff --git a/frontend/interfaces/Data.tsx b/frontend/interfaces/Data.tsx new file mode 100644 index 00000000..a1588562 --- /dev/null +++ b/frontend/interfaces/Data.tsx @@ -0,0 +1,7 @@ +import { FilterTypes } from "@/interfaces/Filters" +import { NewEvent } from "@/interfaces/Events" + +export interface Data { + eventData: Array, + filters: FilterTypes +} \ No newline at end of file diff --git a/frontend/interfaces/Events.tsx b/frontend/interfaces/Events.tsx index 740b1712..2cda724c 100644 --- a/frontend/interfaces/Events.tsx +++ b/frontend/interfaces/Events.tsx @@ -37,7 +37,7 @@ export interface NewEvent { maxTickets?: number } -export interface rawEvent { +export interface RawEvent { 'Game ID': string, Group?: string, Title: string, diff --git a/frontend/interfaces/Filters.tsx b/frontend/interfaces/Filters.tsx new file mode 100644 index 00000000..916cc69b --- /dev/null +++ b/frontend/interfaces/Filters.tsx @@ -0,0 +1,19 @@ +export interface UniqueFilter { + [index: string]: Array +} + +export interface FilterTypes { + groups: UniqueFilter, + eventTypes: UniqueFilter, + gameSystems: UniqueFilter, + ageRequirements: UniqueFilter, + experienceRequirements: UniqueFilter, + startDates: UniqueFilter, + startTimes: UniqueFilter, + endDates: UniqueFilter, + endTimes: UniqueFilter, + tournament: Array, + costs: UniqueFilter, + locations: UniqueFilter, + noTickets: Array +} \ No newline at end of file From 2874d1e9735a1be3066e9de0ef6ecd9733124c62 Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 10:00:33 -0400 Subject: [PATCH 03/13] update data filters --- frontend/components/DailyTabs.tsx | 2 +- frontend/helpers/getData.tsx | 17 ++++ frontend/interfaces/Events.tsx | 131 +++++++++++++++--------------- frontend/interfaces/Filters.tsx | 29 +++---- 4 files changed, 99 insertions(+), 80 deletions(-) diff --git a/frontend/components/DailyTabs.tsx b/frontend/components/DailyTabs.tsx index 2a1eb154..351d85e9 100644 --- a/frontend/components/DailyTabs.tsx +++ b/frontend/components/DailyTabs.tsx @@ -5,7 +5,7 @@ import Box from '@mui/material/Box'; import TimeComponent from './TimeComponent'; -import { UniqueFilter } from '@/helpers/getData'; +import { UniqueFilter } from '@/interfaces/Filters'; interface TabPanelProps { children?: ReactNode; diff --git a/frontend/helpers/getData.tsx b/frontend/helpers/getData.tsx index cd17b651..9412889b 100644 --- a/frontend/helpers/getData.tsx +++ b/frontend/helpers/getData.tsx @@ -21,6 +21,14 @@ const isTournament = (eventTournament: string) => { return false; } +const areMaterialsRequired = (materialsRequired: string) => { + if (materialsRequired === "Yes") { + return true; + } + + return false; +} + const cleanData = (events: Array) => { const data: Data = { eventData: [], @@ -35,6 +43,7 @@ const cleanData = (events: Array) => { endDates: {}, endTimes: {}, tournament: [], + materialsRequired: [], costs: {}, locations: {}, noTickets: [] @@ -59,6 +68,7 @@ const cleanData = (events: Array) => { endTime: '', duration: 0, tournament: false, + materialsRequired: false, cost: 0, location: '', ticketsAvailable: 0, @@ -80,6 +90,7 @@ const cleanData = (events: Array) => { const eventEndDate = rawEnd.toLocaleDateString(); const eventEndTime = getTime(rawEnd); const isTourny = isTournament(event["Tournament?"]); + const materialsRequired = areMaterialsRequired(event["Materials Required"]); const eventCost = Number(event["Cost $"]); const eventLocation = event["Location"]?.toUpperCase(); const eventTickets = Number(event["Tickets Available"]); @@ -182,6 +193,12 @@ const cleanData = (events: Array) => { }; newEvent.tournament = isTourny; + // Tournament + if (materialsRequired) { + data.filters.materialsRequired.push(index); + }; + newEvent.materialsRequired = materialsRequired; + // Costs if (!data.filters.costs[eventCost]) { data.filters.costs[eventCost] = [] diff --git a/frontend/interfaces/Events.tsx b/frontend/interfaces/Events.tsx index 2cda724c..7534c045 100644 --- a/frontend/interfaces/Events.tsx +++ b/frontend/interfaces/Events.tsx @@ -1,73 +1,74 @@ export interface filterEvents { - groups: number[], - eventTypes: number[], - gameSystems: number[], - ageRequirements: number[], - experienceRequirements: number[], - startDates: number[], - startTimes: number[], - endDates: number[], - endTimes: number[], - ifTournament: number[], - costs: number[], - locations: number[], - ticketsAvailable: number[] + groups: number[]; + eventTypes: number[]; + gameSystems: number[]; + ageRequirements: number[]; + experienceRequirements: number[]; + startDates: number[]; + startTimes: number[]; + endDates: number[]; + endTimes: number[]; + ifTournament: number[]; + costs: number[]; + locations: number[]; + ticketsAvailable: number[]; } export interface NewEvent { - id: number, - gameId: string, - group?: string, - title: string, - shortDescription?: string, - longDescription?: string, - eventType: string, - gameSystem?: string, - ageRequirement: string, - experienceRequirement: string, - startDate: string, - startTime: string, - endDate: string, - endTime: string, - duration: number, - tournament: boolean, - cost: number, - location?: string, - ticketsAvailable?: number, - maxTickets?: number + id: number; + gameId: string; + group?: string; + title: string; + shortDescription?: string; + longDescription?: string; + eventType: string; + gameSystem?: string; + ageRequirement: string; + experienceRequirement: string; + startDate: string; + startTime: string; + endDate: string; + endTime: string; + duration: number; + tournament: boolean; + materialsRequired: boolean; + cost: number; + location?: string; + ticketsAvailable?: number; + maxTickets?: number; } export interface RawEvent { - 'Game ID': string, - Group?: string, - Title: string, - 'Short Description'?: string, - 'Long Description'?: string, - 'Event Type': string, - 'Game System'?: string, - 'Rules Edition'?: string, - 'Minimum Players'?: string, - 'Maximum Players'?: string, - 'Age Required': string, - 'Experience Required': string, - 'Materials Required': string, - 'Materials Required Details'?: string, - 'Start Date & Time': string, - Duration?: string, - 'End Date & Time': string, - 'GM Names'?: string, - Website?: string, - Email?: string, - 'Tournament?': 'No', - 'Round Number'?: string, - 'Total Rounds'?: string, - 'Minimum Play Time'?: string, - 'Attendee Registration?'?: string, - 'Cost $': string, - Location?: string, - 'Room Name'?: string, - 'Table Number'?: '', - 'Special Category'?: string, - 'Tickets Available'?: string, - 'Last Modified': string + 'Game ID': string; + Group?: string; + Title: string; + 'Short Description'?: string; + 'Long Description'?: string; + 'Event Type': string; + 'Game System'?: string; + 'Rules Edition'?: string; + 'Minimum Players'?: string; + 'Maximum Players'?: string; + 'Age Required': string; + 'Experience Required': string; + 'Materials Required': string; + 'Materials Required Details'?: string; + 'Start Date & Time': string; + Duration?: string; + 'End Date & Time': string; + 'GM Names'?: string; + Website?: string; + Email?: string; + 'Tournament?': 'No'; + 'Round Number'?: string; + 'Total Rounds'?: string; + 'Minimum Play Time'?: string; + 'Attendee Registration?'?: string; + 'Cost $': string; + Location?: string; + 'Room Name'?: string; + 'Table Number'?: ''; + 'Special Category'?: string; + 'Tickets Available'?: string; + 'Last Modified': string; } \ No newline at end of file diff --git a/frontend/interfaces/Filters.tsx b/frontend/interfaces/Filters.tsx index 916cc69b..9199ce68 100644 --- a/frontend/interfaces/Filters.tsx +++ b/frontend/interfaces/Filters.tsx @@ -1,19 +1,20 @@ export interface UniqueFilter { - [index: string]: Array + [index: string]: Array; } export interface FilterTypes { - groups: UniqueFilter, - eventTypes: UniqueFilter, - gameSystems: UniqueFilter, - ageRequirements: UniqueFilter, - experienceRequirements: UniqueFilter, - startDates: UniqueFilter, - startTimes: UniqueFilter, - endDates: UniqueFilter, - endTimes: UniqueFilter, - tournament: Array, - costs: UniqueFilter, - locations: UniqueFilter, - noTickets: Array + groups: UniqueFilter; + eventTypes: UniqueFilter; + gameSystems: UniqueFilter; + ageRequirements: UniqueFilter; + experienceRequirements: UniqueFilter; + startDates: UniqueFilter; + startTimes: UniqueFilter; + endDates: UniqueFilter; + endTimes: UniqueFilter; + tournament: Array; + materialsRequired: Array; + costs: UniqueFilter; + locations: UniqueFilter; + noTickets: Array; } \ No newline at end of file From abeed5352814cf05772f6ab892804de819da4a33 Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 10:25:36 -0400 Subject: [PATCH 04/13] update tourney spelling --- frontend/components/SwitchComponent.tsx | 13 ++----- frontend/components/TournamentSwitches.tsx | 43 ++++++++++++++++++++++ frontend/helpers/getData.tsx | 6 +-- frontend/interfaces/Components.tsx | 14 +++++++ frontend/pages/index.tsx | 10 +++++ 5 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 frontend/components/TournamentSwitches.tsx create mode 100644 frontend/interfaces/Components.tsx diff --git a/frontend/components/SwitchComponent.tsx b/frontend/components/SwitchComponent.tsx index c6aa894e..4dd323b5 100644 --- a/frontend/components/SwitchComponent.tsx +++ b/frontend/components/SwitchComponent.tsx @@ -1,13 +1,7 @@ -import { Dispatch, SetStateAction } from 'react'; import Switch from '@mui/material/Switch'; +import { SwitchInterface } from '@/interfaces/Components'; -interface Switch { - switchLabel: string; - hide: boolean; - setHide: Dispatch>; -} - -export default function SwitchComponent({ switchLabel, hide, setHide }: Switch) { +export default function SwitchComponent({ switchLabel, hide, setHide }: SwitchInterface) { const aria = { inputProps: { 'aria-label': `${switchLabel} Switch` } }; const label = hide ? `Show ${switchLabel}` : `Hide ${switchLabel}`; @@ -18,7 +12,8 @@ export default function SwitchComponent({ switchLabel, hide, setHide }: Switch) return (
- {label} + {label} +
); diff --git a/frontend/components/TournamentSwitches.tsx b/frontend/components/TournamentSwitches.tsx new file mode 100644 index 00000000..70f4cd55 --- /dev/null +++ b/frontend/components/TournamentSwitches.tsx @@ -0,0 +1,43 @@ +import Switch from '@mui/material/Switch'; +import { TournamentSwitches } from '@/interfaces/Components'; + +export default function TournamentSwitches ({ + hideTourney, + setHideTourney, + tourneyOnly, + setTourneyOnly +}: TournamentSwitches) { + const hideTourneyAria = { inputProps: { 'aria-label': 'hide tournament switch' } }; + const showTourneyAria = { inputProps: { 'aria-label': 'show only tournaments switch' } }; + const hideTourneyLabel = hideTourney ? 'Include Tournaments' : 'Hide Tournaments'; + const showTourneyLabel = tourneyOnly ? 'Show All Events' : 'Show Tournaments Only'; + + const hideTourneyChange = () => { + if (tourneyOnly) { + setTourneyOnly(!tourneyOnly); + } + + setHideTourney(!hideTourney); + } + + const showTourneyChange = () => { + if (hideTourney) { + setHideTourney(!hideTourney); + } + + setTourneyOnly(!tourneyOnly) + } + + return ( + <> +
+ {showTourneyLabel} + +
+
+ {hideTourneyLabel} + +
+ + ); +} \ No newline at end of file diff --git a/frontend/helpers/getData.tsx b/frontend/helpers/getData.tsx index 9412889b..d9078aac 100644 --- a/frontend/helpers/getData.tsx +++ b/frontend/helpers/getData.tsx @@ -89,7 +89,7 @@ const cleanData = (events: Array) => { const eventStartTime = getTime(rawStart); const eventEndDate = rawEnd.toLocaleDateString(); const eventEndTime = getTime(rawEnd); - const isTourny = isTournament(event["Tournament?"]); + const isTourney = isTournament(event["Tournament?"]); const materialsRequired = areMaterialsRequired(event["Materials Required"]); const eventCost = Number(event["Cost $"]); const eventLocation = event["Location"]?.toUpperCase(); @@ -188,10 +188,10 @@ const cleanData = (events: Array) => { newEvent.endTime = eventEndTime; // Tournament - if (isTourny) { + if (isTourney) { data.filters.tournament.push(index); }; - newEvent.tournament = isTourny; + newEvent.tournament = isTourney; // Tournament if (materialsRequired) { diff --git a/frontend/interfaces/Components.tsx b/frontend/interfaces/Components.tsx new file mode 100644 index 00000000..ad4d84e2 --- /dev/null +++ b/frontend/interfaces/Components.tsx @@ -0,0 +1,14 @@ +import { Dispatch, SetStateAction } from 'react'; + +export interface SwitchInterface { + switchLabel: string; + hide: boolean; + setHide: Dispatch>; +} + +export interface TournamentSwitches { + hideTourney: boolean; + setHideTourney: Dispatch>; + tourneyOnly: boolean; + setTourneyOnly: Dispatch>; +} \ No newline at end of file diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index aa9a9ba7..ef16caed 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -7,11 +7,13 @@ import FilterAutoList from "@/components/FilterAutoList"; import FilterButtons from "@/components/FilterButtons"; import Switch from "@/components/SwitchComponent"; import TimeRange from "@/components/TimeRange"; +import TournamentSwitches from "@/components/TournamentSwitches"; export const { eventData, filters } = getData(); export default function Home() { const filterList = filters; + console.log(filterList); // Lists const ageRequirements = filterList.ageRequirements; @@ -36,6 +38,8 @@ export default function Home() { // Switches const [hideSoldOut, setHideSoldOut] = useState(false); + const [hideTourney, setHideTourney] = useState(false); + const [tourneyOnly, setTourneyOnly] = useState(false); return (
@@ -79,6 +83,12 @@ export default function Home() { hide={hideSoldOut} setHide={setHideSoldOut} /> + Date: Tue, 20 Jun 2023 10:33:07 -0400 Subject: [PATCH 05/13] filter for tournaments --- frontend/components/DailyTabs.tsx | 24 ++++++++++++------------ frontend/interfaces/Components.tsx | 15 +++++++++++++++ frontend/pages/index.tsx | 4 ++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/frontend/components/DailyTabs.tsx b/frontend/components/DailyTabs.tsx index 351d85e9..a68e4484 100644 --- a/frontend/components/DailyTabs.tsx +++ b/frontend/components/DailyTabs.tsx @@ -5,7 +5,7 @@ import Box from '@mui/material/Box'; import TimeComponent from './TimeComponent'; -import { UniqueFilter } from '@/interfaces/Filters'; +import { DailyTabs } from '@/interfaces/Components'; interface TabPanelProps { children?: ReactNode; @@ -40,23 +40,15 @@ function a11yProps(index: number) { }; } -interface DailyTabs { - allBaseFilters: number[]; - showOnly: Array; - dateList: UniqueFilter; - hideSoldOut: boolean; - soldOutEvents: number[]; - earlyStartTime: string; - lateStartTime: string; - startTimes: UniqueFilter; -} - export default function DailyTabs({ allBaseFilters, showOnly, dateList, hideSoldOut, + hideTourney, + tourneyOnly, soldOutEvents, + tourneyList, earlyStartTime, lateStartTime, startTimes @@ -77,6 +69,14 @@ export default function DailyTabs({ eventsForDay = eventsForDay.filter(val => !soldOutEvents.includes(val)); } + if (hideTourney) { + eventsForDay = eventsForDay.filter(val => !tourneyList.includes(val)); + } + + if (tourneyOnly) { + eventsForDay = eventsForDay.filter(val => tourneyList.includes(val)); + } + timeLabels.map(timeLabel => { if (timeLabel < earlyStartTime || timeLabel > lateStartTime) { var events = startTimes[timeLabel] diff --git a/frontend/interfaces/Components.tsx b/frontend/interfaces/Components.tsx index ad4d84e2..40f3702e 100644 --- a/frontend/interfaces/Components.tsx +++ b/frontend/interfaces/Components.tsx @@ -1,4 +1,19 @@ import { Dispatch, SetStateAction } from 'react'; +import { UniqueFilter } from './Filters'; + +export interface DailyTabs { + allBaseFilters: number[]; + showOnly: Array; + dateList: UniqueFilter; + hideSoldOut: boolean; + hideTourney: boolean; + tourneyOnly: boolean; + soldOutEvents: number[]; + tourneyList: number[]; + earlyStartTime: string; + lateStartTime: string; + startTimes: UniqueFilter; +} export interface SwitchInterface { switchLabel: string; diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index ef16caed..cbe6feb5 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -25,6 +25,7 @@ export default function Home() { const locations = filterList.locations; const soldOutEvents = filterList.noTickets; const startTimes = filterList.startTimes; + const tourneyList = filterList.tournament; // Filters const [ageFilters, setAgeFilters] = useState([]); @@ -109,7 +110,10 @@ export default function Home() { ]} dateList={dateList} hideSoldOut={hideSoldOut} + hideTourney={hideTourney} + tourneyOnly={tourneyOnly} soldOutEvents={soldOutEvents} + tourneyList={tourneyList} earlyStartTime={earlyStartTime} lateStartTime={lateStartTime} startTimes={startTimes} From c2c4ac8bc5bcc1aa90fa13fa3c098258bfac7fcc Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 11:59:52 -0400 Subject: [PATCH 06/13] add tournament switches --- frontend/components/DailyTabs.tsx | 6 ++++++ frontend/interfaces/Components.tsx | 2 ++ frontend/pages/index.tsx | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/frontend/components/DailyTabs.tsx b/frontend/components/DailyTabs.tsx index a68e4484..b7ee3202 100644 --- a/frontend/components/DailyTabs.tsx +++ b/frontend/components/DailyTabs.tsx @@ -44,9 +44,11 @@ export default function DailyTabs({ allBaseFilters, showOnly, dateList, + hideMaterialReq, hideSoldOut, hideTourney, tourneyOnly, + materialsRequired, soldOutEvents, tourneyList, earlyStartTime, @@ -65,6 +67,10 @@ export default function DailyTabs({ var eventsForDay = dayEvents.filter(val => !allBaseFilters.includes(val)); + if (hideMaterialReq) { + eventsForDay = eventsForDay.filter(val => !materialsRequired.includes(val)); + } + if (hideSoldOut) { eventsForDay = eventsForDay.filter(val => !soldOutEvents.includes(val)); } diff --git a/frontend/interfaces/Components.tsx b/frontend/interfaces/Components.tsx index 40f3702e..5306b1c6 100644 --- a/frontend/interfaces/Components.tsx +++ b/frontend/interfaces/Components.tsx @@ -5,9 +5,11 @@ export interface DailyTabs { allBaseFilters: number[]; showOnly: Array; dateList: UniqueFilter; + hideMaterialReq: boolean; hideSoldOut: boolean; hideTourney: boolean; tourneyOnly: boolean; + materialsRequired: number[]; soldOutEvents: number[]; tourneyList: number[]; earlyStartTime: string; diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index cbe6feb5..7fb4abaf 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -23,6 +23,7 @@ export default function Home() { const gameSystems = filterList.gameSystems; const groups = filterList.groups; const locations = filterList.locations; + const materialsRequired = filterList.materialsRequired; const soldOutEvents = filterList.noTickets; const startTimes = filterList.startTimes; const tourneyList = filterList.tournament; @@ -39,6 +40,7 @@ export default function Home() { // Switches const [hideSoldOut, setHideSoldOut] = useState(false); + const [hideMaterialsReq, setHideMaterialsReq] = useState(false); const [hideTourney, setHideTourney] = useState(false); const [tourneyOnly, setTourneyOnly] = useState(false); @@ -84,6 +86,11 @@ export default function Home() { hide={hideSoldOut} setHide={setHideSoldOut} /> + Date: Tue, 20 Jun 2023 12:07:34 -0400 Subject: [PATCH 07/13] show materials if needed on modal --- frontend/components/EventModal.tsx | 5 ++++- frontend/helpers/getData.tsx | 3 +++ frontend/interfaces/Events.tsx | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/components/EventModal.tsx b/frontend/components/EventModal.tsx index 485221ec..b59c2e46 100644 --- a/frontend/components/EventModal.tsx +++ b/frontend/components/EventModal.tsx @@ -1,5 +1,5 @@ import { Dispatch, SetStateAction } from 'react'; -import { NewEvent } from '@/helpers/getData'; +import { NewEvent } from '@/interfaces/Events'; import Box from '@mui/material/Box'; import Modal from '@mui/material/Modal'; import ConfirmationNumberIcon from '@mui/icons-material/ConfirmationNumber'; @@ -78,6 +78,9 @@ export default function BasicModal({ {event.group && } {event.location && } + {event.materialsRequired && ( + + )} diff --git a/frontend/helpers/getData.tsx b/frontend/helpers/getData.tsx index d9078aac..66bc82d8 100644 --- a/frontend/helpers/getData.tsx +++ b/frontend/helpers/getData.tsx @@ -69,6 +69,7 @@ const cleanData = (events: Array) => { duration: 0, tournament: false, materialsRequired: false, + materials: '', cost: 0, location: '', ticketsAvailable: 0, @@ -91,6 +92,7 @@ const cleanData = (events: Array) => { const eventEndTime = getTime(rawEnd); const isTourney = isTournament(event["Tournament?"]); const materialsRequired = areMaterialsRequired(event["Materials Required"]); + const materials = event["Materials Required Details"]; const eventCost = Number(event["Cost $"]); const eventLocation = event["Location"]?.toUpperCase(); const eventTickets = Number(event["Tickets Available"]); @@ -196,6 +198,7 @@ const cleanData = (events: Array) => { // Tournament if (materialsRequired) { data.filters.materialsRequired.push(index); + newEvent.materials = materials; }; newEvent.materialsRequired = materialsRequired; diff --git a/frontend/interfaces/Events.tsx b/frontend/interfaces/Events.tsx index 7534c045..d0b2f4b5 100644 --- a/frontend/interfaces/Events.tsx +++ b/frontend/interfaces/Events.tsx @@ -32,6 +32,7 @@ export interface NewEvent { duration: number; tournament: boolean; materialsRequired: boolean; + materials?: string; cost: number; location?: string; ticketsAvailable?: number; From 632fc37bf03045328068f3a130f0cd9a103f01f4 Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 12:12:26 -0400 Subject: [PATCH 08/13] tournament row in modal --- frontend/components/EventModal.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/components/EventModal.tsx b/frontend/components/EventModal.tsx index b59c2e46..27d10f09 100644 --- a/frontend/components/EventModal.tsx +++ b/frontend/components/EventModal.tsx @@ -79,8 +79,9 @@ export default function BasicModal({ {event.group && } {event.location && } {event.materialsRequired && ( - + )} + From 042736c5d6be1a9dc79e71bc2bc282d9406a2a60 Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 12:40:00 -0400 Subject: [PATCH 09/13] change tournament filter radio group --- frontend/components/DailyTabs.tsx | 10 ----- frontend/components/RadioGroup.tsx | 40 ++++++++++++++++++++ frontend/components/TournamentSwitches.tsx | 43 ---------------------- frontend/interfaces/Components.tsx | 9 ++++- frontend/pages/index.tsx | 24 +++++++----- 5 files changed, 61 insertions(+), 65 deletions(-) create mode 100644 frontend/components/RadioGroup.tsx delete mode 100644 frontend/components/TournamentSwitches.tsx diff --git a/frontend/components/DailyTabs.tsx b/frontend/components/DailyTabs.tsx index b7ee3202..c20ac732 100644 --- a/frontend/components/DailyTabs.tsx +++ b/frontend/components/DailyTabs.tsx @@ -46,8 +46,6 @@ export default function DailyTabs({ dateList, hideMaterialReq, hideSoldOut, - hideTourney, - tourneyOnly, materialsRequired, soldOutEvents, tourneyList, @@ -75,14 +73,6 @@ export default function DailyTabs({ eventsForDay = eventsForDay.filter(val => !soldOutEvents.includes(val)); } - if (hideTourney) { - eventsForDay = eventsForDay.filter(val => !tourneyList.includes(val)); - } - - if (tourneyOnly) { - eventsForDay = eventsForDay.filter(val => tourneyList.includes(val)); - } - timeLabels.map(timeLabel => { if (timeLabel < earlyStartTime || timeLabel > lateStartTime) { var events = startTimes[timeLabel] diff --git a/frontend/components/RadioGroup.tsx b/frontend/components/RadioGroup.tsx new file mode 100644 index 00000000..9764635e --- /dev/null +++ b/frontend/components/RadioGroup.tsx @@ -0,0 +1,40 @@ +import { ChangeEvent } from 'react'; +import Radio from '@mui/material/Radio'; +import RadioGroup from '@mui/material/RadioGroup'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import FormControl from '@mui/material/FormControl'; + +import { RadioGroupInterface } from '@/interfaces/Components'; + +export default function RadioButtonsGroup({ + formLabel, + options, + setValue, + value +}: RadioGroupInterface) { + + const handleChange = (event: ChangeEvent) => { + setValue((event.target as HTMLInputElement).value); + }; + + return ( + + {formLabel} + + {options.map(option => ( + } + label={option} + /> + ))} + + + ); +} diff --git a/frontend/components/TournamentSwitches.tsx b/frontend/components/TournamentSwitches.tsx deleted file mode 100644 index 70f4cd55..00000000 --- a/frontend/components/TournamentSwitches.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import Switch from '@mui/material/Switch'; -import { TournamentSwitches } from '@/interfaces/Components'; - -export default function TournamentSwitches ({ - hideTourney, - setHideTourney, - tourneyOnly, - setTourneyOnly -}: TournamentSwitches) { - const hideTourneyAria = { inputProps: { 'aria-label': 'hide tournament switch' } }; - const showTourneyAria = { inputProps: { 'aria-label': 'show only tournaments switch' } }; - const hideTourneyLabel = hideTourney ? 'Include Tournaments' : 'Hide Tournaments'; - const showTourneyLabel = tourneyOnly ? 'Show All Events' : 'Show Tournaments Only'; - - const hideTourneyChange = () => { - if (tourneyOnly) { - setTourneyOnly(!tourneyOnly); - } - - setHideTourney(!hideTourney); - } - - const showTourneyChange = () => { - if (hideTourney) { - setHideTourney(!hideTourney); - } - - setTourneyOnly(!tourneyOnly) - } - - return ( - <> -
- {showTourneyLabel} - -
-
- {hideTourneyLabel} - -
- - ); -} \ No newline at end of file diff --git a/frontend/interfaces/Components.tsx b/frontend/interfaces/Components.tsx index 5306b1c6..d4bb7100 100644 --- a/frontend/interfaces/Components.tsx +++ b/frontend/interfaces/Components.tsx @@ -7,8 +7,6 @@ export interface DailyTabs { dateList: UniqueFilter; hideMaterialReq: boolean; hideSoldOut: boolean; - hideTourney: boolean; - tourneyOnly: boolean; materialsRequired: number[]; soldOutEvents: number[]; tourneyList: number[]; @@ -17,6 +15,13 @@ export interface DailyTabs { startTimes: UniqueFilter; } +export interface RadioGroupInterface { + formLabel: string; + options: string[]; + setValue: Dispatch>; + value?: string; +} + export interface SwitchInterface { switchLabel: string; hide: boolean; diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index 7fb4abaf..f3dd1f6e 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -5,9 +5,9 @@ import getData from "@/helpers/getData"; import DailyTabs from "@/components/DailyTabs"; import FilterAutoList from "@/components/FilterAutoList"; import FilterButtons from "@/components/FilterButtons"; +import RadioGroup from "@/components/RadioGroup"; import Switch from "@/components/SwitchComponent"; import TimeRange from "@/components/TimeRange"; -import TournamentSwitches from "@/components/TournamentSwitches"; export const { eventData, filters } = getData(); @@ -38,11 +38,17 @@ export default function Home() { const [lateStartTime, setLateStartTime] = useState('23:45'); const [systemFilters, setSystemFilters] = useState([]); + // Radio Group + const tournamentFilterOptions = [ + 'Show All Events', + 'Show Tournament Events Only', + 'Hide All Tournament Events' + ] + const [tournamentFilter, setTournamentFilter] = useState(tournamentFilterOptions[0]); + // Switches const [hideSoldOut, setHideSoldOut] = useState(false); const [hideMaterialsReq, setHideMaterialsReq] = useState(false); - const [hideTourney, setHideTourney] = useState(false); - const [tourneyOnly, setTourneyOnly] = useState(false); return (
@@ -91,11 +97,11 @@ export default function Home() { hide={hideMaterialsReq} setHide={setHideMaterialsReq} /> - Date: Tue, 20 Jun 2023 12:44:09 -0400 Subject: [PATCH 10/13] apply tournament filter --- frontend/components/DailyTabs.tsx | 11 +++++++++++ frontend/interfaces/Components.tsx | 1 + frontend/pages/index.tsx | 12 +++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/components/DailyTabs.tsx b/frontend/components/DailyTabs.tsx index c20ac732..85b1fd83 100644 --- a/frontend/components/DailyTabs.tsx +++ b/frontend/components/DailyTabs.tsx @@ -7,6 +7,8 @@ import TimeComponent from './TimeComponent'; import { DailyTabs } from '@/interfaces/Components'; +import { tournamentFilterOptions } from '@/pages'; + interface TabPanelProps { children?: ReactNode; index: number; @@ -48,6 +50,7 @@ export default function DailyTabs({ hideSoldOut, materialsRequired, soldOutEvents, + tournamentFilter, tourneyList, earlyStartTime, lateStartTime, @@ -73,6 +76,14 @@ export default function DailyTabs({ eventsForDay = eventsForDay.filter(val => !soldOutEvents.includes(val)); } + if (tournamentFilter === tournamentFilterOptions[1]) { + eventsForDay = eventsForDay.filter(val => tourneyList.includes(val)) + } + + if (tournamentFilter === tournamentFilterOptions[2]) { + eventsForDay = eventsForDay.filter(val => !tourneyList.includes(val)) + } + timeLabels.map(timeLabel => { if (timeLabel < earlyStartTime || timeLabel > lateStartTime) { var events = startTimes[timeLabel] diff --git a/frontend/interfaces/Components.tsx b/frontend/interfaces/Components.tsx index d4bb7100..d912068f 100644 --- a/frontend/interfaces/Components.tsx +++ b/frontend/interfaces/Components.tsx @@ -9,6 +9,7 @@ export interface DailyTabs { hideSoldOut: boolean; materialsRequired: number[]; soldOutEvents: number[]; + tournamentFilter: string; tourneyList: number[]; earlyStartTime: string; lateStartTime: string; diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index f3dd1f6e..f46702c4 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -11,6 +11,12 @@ import TimeRange from "@/components/TimeRange"; export const { eventData, filters } = getData(); +export const tournamentFilterOptions = [ + 'Show All Events', + 'Show Tournament Events Only', + 'Hide All Tournament Events' +] + export default function Home() { const filterList = filters; console.log(filterList); @@ -39,11 +45,6 @@ export default function Home() { const [systemFilters, setSystemFilters] = useState([]); // Radio Group - const tournamentFilterOptions = [ - 'Show All Events', - 'Show Tournament Events Only', - 'Hide All Tournament Events' - ] const [tournamentFilter, setTournamentFilter] = useState(tournamentFilterOptions[0]); // Switches @@ -126,6 +127,7 @@ export default function Home() { hideSoldOut={hideSoldOut} materialsRequired={materialsRequired} soldOutEvents={soldOutEvents} + tournamentFilter={tournamentFilter} tourneyList={tourneyList} earlyStartTime={earlyStartTime} lateStartTime={lateStartTime} From afe55e887098e79163b9d8f82cbf67c7943c324e Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 12:50:42 -0400 Subject: [PATCH 11/13] container styling --- frontend/components/RadioGroup.tsx | 38 ++++++++++++++++-------------- frontend/components/TimeRange.tsx | 2 +- frontend/styles/styles.css | 6 ++++- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/frontend/components/RadioGroup.tsx b/frontend/components/RadioGroup.tsx index 9764635e..59f9dfe0 100644 --- a/frontend/components/RadioGroup.tsx +++ b/frontend/components/RadioGroup.tsx @@ -18,23 +18,25 @@ export default function RadioButtonsGroup({ }; return ( - - {formLabel} - - {options.map(option => ( - } - label={option} - /> - ))} - - +
+ + {formLabel} + + {options.map(option => ( + } + label={option} + /> + ))} + + +
); } diff --git a/frontend/components/TimeRange.tsx b/frontend/components/TimeRange.tsx index 8a9913f0..bb5048e8 100644 --- a/frontend/components/TimeRange.tsx +++ b/frontend/components/TimeRange.tsx @@ -30,7 +30,7 @@ export default function TimeRange({ return (
- Start Time Range: {earlyStartTime} - {lateStartTime} + Start Time Range:
Date: Tue, 20 Jun 2023 12:52:00 -0400 Subject: [PATCH 12/13] fix unique filter import --- frontend/components/FilterAutoList.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/components/FilterAutoList.tsx b/frontend/components/FilterAutoList.tsx index 6e1d5cbd..8cdf2504 100644 --- a/frontend/components/FilterAutoList.tsx +++ b/frontend/components/FilterAutoList.tsx @@ -1,8 +1,7 @@ import { Dispatch, SetStateAction } from 'react'; import Autocomplete from '@mui/material/Autocomplete'; import TextField from '@mui/material/TextField'; - -import { UniqueFilter } from '@/helpers/getData'; +import { UniqueFilter } from '@/interfaces/Filters'; interface FilterAutoList { filter: UniqueFilter, From 85869477ba426e9d64769d6d6eb0e1bb08b06090 Mon Sep 17 00:00:00 2001 From: Nicole Zonnenberg Date: Tue, 20 Jun 2023 12:53:05 -0400 Subject: [PATCH 13/13] fix import --- frontend/components/FilterButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/FilterButtons.tsx b/frontend/components/FilterButtons.tsx index 958e5f8c..8858d80c 100644 --- a/frontend/components/FilterButtons.tsx +++ b/frontend/components/FilterButtons.tsx @@ -1,6 +1,6 @@ import { Dispatch, SetStateAction, useState } from 'react'; -import { UniqueFilter } from '@/helpers/getData'; +import { UniqueFilter } from '@/interfaces/Filters'; export default function FilterButtons({ filter,