From 8af93bba3a75e9bc1680533f1f3d9c613a1339ad Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Fri, 5 Apr 2024 22:20:35 -0700 Subject: [PATCH 1/2] support - and / for dates --- app/components/MatchTiles.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/components/MatchTiles.js b/app/components/MatchTiles.js index 36ab223..05b2753 100644 --- a/app/components/MatchTiles.js +++ b/app/components/MatchTiles.js @@ -46,27 +46,32 @@ const isWomensTeam = (match) => { //Retrieve Match Date const extractDateFromString = (inputString) => { - const regex = /\b(\d{1,2}\/\d{1,2}\/\d{2,4})\b/g; + const regexSlash = /\b(\d{1,2}\/\d{1,2}\/\d{2,4})\b/g; + const regexDash = /\b(\d{1,2}-\d{1,2}-?\d{0,4})\b/g; + const regex = new RegExp(`${regexSlash.source}|${regexDash.source}`, "g"); const matches = inputString.match(regex); if (matches) { // Assuming there might be multiple date patterns in the string, return an array of matches const firstMatch = matches[0]; // Assuming you want to pick the first matched date - const dateParts = firstMatch.split("/"); + const dateParts = firstMatch.includes('/') ? firstMatch.split('/') : firstMatch.split('-'); const month = parseInt(dateParts[0]); const day = parseInt(dateParts[1]); const year = parseInt(dateParts[2]); + console.log(month, day, year) // Create a new Date object with the extracted components const dateObject = new Date(year + 2000, month - 1, day); - const formattedDate = dateObject.toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric", }); + console.log(formattedDate) return formattedDate; } else { + console.log(inputString.match(regexDash)) + console.log('unmatched') return null; } }; From cd9c29386f103808b215d9f437093f5757f374dc Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Fri, 5 Apr 2024 22:29:03 -0700 Subject: [PATCH 2/2] linting errs --- app/components/FilterList.js | 2 +- app/components/MatchTiles.js | 2 +- app/services/getLogos.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/FilterList.js b/app/components/FilterList.js index 0a02af6..9bb2f3a 100644 --- a/app/components/FilterList.js +++ b/app/components/FilterList.js @@ -48,7 +48,7 @@ const FilterList = ({ pointsData, filterList, setFilterList, showPercent, showCo return pointsData.filter(point => point[key] === value).length; }; - const countFilteredPointsTotal = (key, value) => { + const countFilteredPointsTotal = (key) => { return pointsData.reduce((total, point) => { // Check if the value attribute is not an empty string if (point[key] !== '') { diff --git a/app/components/MatchTiles.js b/app/components/MatchTiles.js index 05b2753..6e1e2e8 100644 --- a/app/components/MatchTiles.js +++ b/app/components/MatchTiles.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState } from "react"; import styles from "../styles/MatchTiles.module.css"; const extractSetScore = (setObject) => { diff --git a/app/services/getLogos.js b/app/services/getLogos.js index 3a85613..d406631 100644 --- a/app/services/getLogos.js +++ b/app/services/getLogos.js @@ -1,4 +1,4 @@ -import { db, storage } from '../services/initializeFirebase.js'; // Ensure storage is exported from initializeFirebase.js +import { storage } from '../services/initializeFirebase.js'; // Ensure storage is exported from initializeFirebase.js import { ref, listAll, getDownloadURL } from "firebase/storage"; // Import storage functions const logosRef = ref(storage, 'logos');