From 4c1ba48e5cd54b5d9679f4aa553b9712f11de2db Mon Sep 17 00:00:00 2001 From: Sam Bao Date: Tue, 19 Nov 2024 22:45:57 -0700 Subject: [PATCH] holy fuck unexpected win from AI once more, we are no longer limited to 5 concerts! --- src/TaleSetup/BaseInput.js | 23 +++++++++++------------ src/TaleSetup/ConcertList.js | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/TaleSetup/BaseInput.js b/src/TaleSetup/BaseInput.js index f4d7f0d..56b0f3c 100644 --- a/src/TaleSetup/BaseInput.js +++ b/src/TaleSetup/BaseInput.js @@ -48,13 +48,9 @@ function generateCombinations(dictionary) { const keys = Object.keys(dictionary); const result = []; - function backtrack(combination, index) { + function backtrack(combination, index, lastDate, lastLocation, lastTitle) { if (index === keys.length) { - const dates = combination.map(concert => concert.date); - const sortedDates = [...dates].sort(); - if (JSON.stringify(dates) === (JSON.stringify(sortedDates))) { - result.push([...combination]); - } + result.push([...combination]); return; } @@ -62,13 +58,16 @@ function generateCombinations(dictionary) { const values = dictionary[key]; for (const value of values) { - combination.push(value); - backtrack(combination, index + 1); - combination.pop(); + const concertDate = new Date(value.date); + if (concertDate >= lastDate && (concertDate !== lastDate || (value.location.name === lastLocation.name && value.location.address === lastLocation.address && value.title === lastTitle))) { + combination.push(value); + backtrack(combination, index + 1, concertDate, value.location, value.title); + combination.pop(); + } } } - backtrack([], 0); + backtrack([], 0, new Date(0), { name: null, address: null }, null); return result; } @@ -139,10 +138,10 @@ const BaseInput = forwardRef(({ setConcerts, const [artistName, setArtistName] = useState("Taylor Swift"); const submitArtistInfo = async (incomingArtistInfo) => { - if (artistWishlist.length >= 5) { + /*if (artistWishlist.length >= 5) { alert(`You can have only 5 artists at a time.`) return - } + }*/ let incomingArtistName = incomingArtistInfo.name; let incomingArtistId = incomingArtistInfo.id try { diff --git a/src/TaleSetup/ConcertList.js b/src/TaleSetup/ConcertList.js index 94b6e1c..59bdff8 100644 --- a/src/TaleSetup/ConcertList.js +++ b/src/TaleSetup/ConcertList.js @@ -145,7 +145,7 @@ class ConcertList extends React.Component {
{hasConcerts && ( - Upcoming Concerts
({this.state.concerts.length} / 5): + Upcoming Concerts ({this.state.concerts.length}) :
)} {hasConcerts && (