From 7e6fb90453676132b0deab049386ac1de64887cb Mon Sep 17 00:00:00 2001 From: Leo Cardozo Date: Sun, 24 Nov 2024 22:36:14 -0800 Subject: [PATCH 01/10] added unforcedError and server and returner start location --- app/services/taggerButtonData.js | 397 ++++++++++++++++++++----------- 1 file changed, 253 insertions(+), 144 deletions(-) diff --git a/app/services/taggerButtonData.js b/app/services/taggerButtonData.js index 6bc1b4b..177c46c 100644 --- a/app/services/taggerButtonData.js +++ b/app/services/taggerButtonData.js @@ -222,7 +222,7 @@ export const getTaggerButtonData = ( updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -230,19 +230,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '0-15') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -250,19 +255,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '15-0') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -270,19 +280,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '15-15') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -290,19 +305,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '30-0') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -310,19 +330,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '0-30') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -330,19 +355,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '30-15') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -350,19 +380,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '0-40') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -370,19 +405,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '40-0') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -390,19 +430,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '15-30') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -410,19 +455,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '30-30') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -430,19 +480,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '40-15') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -450,20 +505,25 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '15-40') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('isBreakPoint', 1) updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -471,20 +531,25 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '30-40') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('isBreakPoint', 1) updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -492,19 +557,24 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '40-30') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -512,20 +582,25 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '40-40') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Ad') updateActiveRow('isBreakPoint', 1) updateActiveRow('pointStartTime', data.videoTimestamp) - setCurrentPage('FirstServe') + setCurrentPage('ServerLocation') } }, { @@ -533,19 +608,44 @@ export const getTaggerButtonData = ( action: (data) => { addNewRow() updateActiveRow('pointScore', '40-40') - updateActiveRow( - 'gameScore', - data.table[data.activeRowIndex - 1].gameScore - ) - updateActiveRow( - 'setScore', - data.table[data.activeRowIndex - 1].setScore - ) + if (data.activeRowIndex > 1) { + updateActiveRow( + 'gameScore', + data.table[data.activeRowIndex - 1].gameScore + ) + updateActiveRow( + 'setScore', + data.table[data.activeRowIndex - 1].setScore + ) + } else { + updateActiveRow('gameScore', '0-0') + updateActiveRow('setScore', '0-0') + } updateActiveRow('isPointStart', 1) updateActiveRow('shotInRally', 1) updateActiveRow('side', 'Deuce') updateActiveRow('isBreakPoint', 1) updateActiveRow('pointStartTime', data.videoTimestamp) + setCurrentPage('ServerLocation') + } + } + ], + ServerLocation: [ + { + courtImage: true, + label: 'Select Server Location', + action: (data) => { + updateActiveRow('serverStartLocation', data.x) + setCurrentPage('ReturnerLocation') + } + } + ], + ReturnerLocation: [ + { + courtImage: true, + label: 'Select Returner Location', + action: (data) => { + updateActiveRow('returnerStartLocation', data.x) setCurrentPage('FirstServe') } } @@ -1222,6 +1322,12 @@ export const getTaggerButtonData = ( updateActiveRow('isExcitingPoint', '1') } }, + { + label: 'Unforced Error', + action: () => { + updateActiveRow('isUnforcedError', '1') + } + }, { courtImage: true, label: 'Select Shot Result Location', @@ -1391,6 +1497,8 @@ export const columnNames = [ 'side', 'serverName', 'serverFarNear', + 'serverStartLocation', + 'returnerStartLocation', 'firstServeIn', 'firstServeZone', 'firstServeXCoord', @@ -1420,6 +1528,7 @@ export const columnNames = [ 'isErrorWideL', 'isErrorNet', 'isErrorLong', + 'isUnforcedError', 'clientTeam', 'Date', 'Division', From 76e09fbd86ea8d91f4c37778872663ccd46964e3 Mon Sep 17 00:00:00 2001 From: Leo Cardozo Date: Mon, 25 Nov 2024 14:12:30 -0800 Subject: [PATCH 02/10] added server and returner location --- app/services/taggerButtonData.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/services/taggerButtonData.js b/app/services/taggerButtonData.js index 177c46c..fe5cbc3 100644 --- a/app/services/taggerButtonData.js +++ b/app/services/taggerButtonData.js @@ -34,8 +34,6 @@ Additional Properties of 'data': let serverScore = 0 let returnerScore = 0 -// const player1SetScore = 0 -// const player2SetScore = 0 let player1GameScore = 0 let player2GameScore = 0 let isAce = false From 43089f3e982d3a8af194a350ccc9ab354eea4f08 Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Sun, 1 Dec 2024 18:28:49 -0800 Subject: [PATCH 03/10] @routing problems --- app/upload-match/page.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/upload-match/page.js b/app/upload-match/page.js index 9614b77..0c31288 100644 --- a/app/upload-match/page.js +++ b/app/upload-match/page.js @@ -8,8 +8,8 @@ import getTeams from '@/app/services/getTeams.js' import { initialSchema, uiSchema } from '@/app/services/matchSchemas.js' import { searchableProperties } from '@/app/services/searchableProperties.js' -import { useData } from '@/app/components/DataProvider.js' -import { useAuth } from '@/app/components/AuthWrapper.js' +import { useData } from '@/app/DataProvider.js' +import { useAuth } from '@/app/AuthWrapper.js' import styles from '@/app/styles/Upload.module.css' From 41c277e9c66ce77037d3832b93bf31df3f763278 Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Mon, 2 Dec 2024 19:01:41 -0800 Subject: [PATCH 04/10] display pdf --- app/DataProvider.js | 21 +++++++++++++++++- app/matches/[slug]/page.js | 2 +- app/services/matchSchemas.js | 42 ++++++++++++++++++++++++++++-------- app/upload-match/page.js | 4 +++- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/app/DataProvider.js b/app/DataProvider.js index 6bd7204..13e8ce7 100644 --- a/app/DataProvider.js +++ b/app/DataProvider.js @@ -7,8 +7,9 @@ import React, { useContext } from 'react' import { collection, getDocs, doc, updateDoc, addDoc } from 'firebase/firestore' +import { ref, uploadBytes, getDownloadURL } from 'firebase/storage' -import { db } from '@/app/services/initializeFirebase.js' +import { db, storage } from '@/app/services/initializeFirebase.js' import { useAuth } from '@/app/AuthWrapper.js' import getTeams from '@/app/services/getTeams.js' @@ -92,6 +93,24 @@ export const DataProvider = ({ children }) => { const createMatch = useCallback(async (collectionName, newMatchData) => { try { + console.log(newMatchData.pdfFile) + let pdfUrl = null + if (newMatchData.pdfFile) { + // First, upload the PDF to Firebase Storage + const pdfRef = ref(storage, `match-pdfs/${newMatchData.pdfFile.name}`) + // const metadata = { + // contentType: 'application/pdf' + // } + + const snapshot = await uploadBytes( + pdfRef, + newMatchData.pdfFile + // metadata + ) + pdfUrl = await getDownloadURL(snapshot.ref) + } + newMatchData.pdfFile = pdfUrl + const newMatch = { id: 'temp-id', collection: collectionName, diff --git a/app/matches/[slug]/page.js b/app/matches/[slug]/page.js index deb8421..da53932 100644 --- a/app/matches/[slug]/page.js +++ b/app/matches/[slug]/page.js @@ -429,7 +429,7 @@ const MatchPage = () => { {showPDF ? (