From 7d341f08b8d7b8528892fb9b8bef75d5828bbff9 Mon Sep 17 00:00:00 2001 From: Jacob Hotz <77470805+Jacob1010-h@users.noreply.github.com> Date: Sun, 24 Mar 2024 20:01:56 -0700 Subject: [PATCH 1/2] add recusive call if an error is detected. --- src/Container.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Container.js b/src/Container.js index 85f9961..60bc5f8 100644 --- a/src/Container.js +++ b/src/Container.js @@ -108,9 +108,20 @@ class Container extends React.Component { }; let positions = ["red1", "red2", "red3", "blue1", "blue2", "blue3"]; - // event match # Name|Position-Team# - set(ref(db, 'scouting/' + eventID + '/match-' + data[1][1] + '/' + name + '|' + positions[position] + '-' + data[2][1] + '/data/'), jsonData); - set(ref(db, 'scouting/' + eventID + '/match-' + data[1][1] + '/' + name + '|' + positions[position] + '-' + data[2][1] + '/comments/'), commentData); + + const sendInputsToData = (eventID, matchNumber, name, position, teamNumber, data, isComments) => { + set(ref(db, 'scouting/' + eventID + '/match-' + matchNumber + '/' + name + '|' + position + '-' + teamNumber + (isComments ? '/comments/' : '/data/')), data) + .then(() => { + console.log("Data sent to database"); + }) + .catch(() => { + console.log("Error sending data to database"); + sendInputsToData(eventID, matchNumber, name, position, teamNumber, data, isComments); + }) + } + + sendInputsToData(eventID, data[1][1], data[0][1], positions[data[3][1]], data[2][1], jsonData, isComments = false); + sendInputsToData(eventID, data[1][1], data[0][1], positions[data[3][1]], data[2][1], commentData, isComments = true); localStorage.setItem("name", name); localStorage.setItem("matchNumber", matchNumber); From 0f5d27f335cf9439cbc1b8a05ee457f3ebbcbf34 Mon Sep 17 00:00:00 2001 From: Jacob Hotz Date: Mon, 25 Mar 2024 14:23:30 -0700 Subject: [PATCH 2/2] ok i fixed it :))) --- requirements.txt | 0 src/Container.js | 35 +++++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/Container.js b/src/Container.js index 60bc5f8..9ce4e31 100644 --- a/src/Container.js +++ b/src/Container.js @@ -67,7 +67,7 @@ class Container extends React.Component { var sendData = data[1]; data = data[0]; - const eventID = '2024casd'; + const eventID = '2024test'; if (sendData) { let validMatch = true; @@ -109,19 +109,30 @@ class Container extends React.Component { let positions = ["red1", "red2", "red3", "blue1", "blue2", "blue3"]; - const sendInputsToData = (eventID, matchNumber, name, position, teamNumber, data, isComments) => { - set(ref(db, 'scouting/' + eventID + '/match-' + matchNumber + '/' + name + '|' + position + '-' + teamNumber + (isComments ? '/comments/' : '/data/')), data) + const sendInputsToData = async (eventID, matchNumber, name, position, teamNumber, jsonData, commentData) => { + set(ref(db, 'scouting/' + eventID + '/match-' + matchNumber + '/' + name + '|' + position + '-' + teamNumber + '/data/'), jsonData); + set(ref(db, 'scouting/' + eventID + '/match-' + matchNumber + '/' + name + '|' + position + '-' + teamNumber + '/comments/'), commentData); + } + + const sendBothInputs = async (eventID, matchNumber, name, position, teamNumber, jsonData, commentData) => { + sendInputsToData(eventID, matchNumber, name, position, teamNumber, jsonData, commentData) .then(() => { - console.log("Data sent to database"); - }) - .catch(() => { - console.log("Error sending data to database"); - sendInputsToData(eventID, matchNumber, name, position, teamNumber, data, isComments); - }) + console.log("Data sent to database"); + }).catch((error) => { + console.error("Error sending data to database: ", error); + sendBothInputs(eventID, matchNumber, name, position, teamNumber, jsonData, commentData); + }); } - - sendInputsToData(eventID, data[1][1], data[0][1], positions[data[3][1]], data[2][1], jsonData, isComments = false); - sendInputsToData(eventID, data[1][1], data[0][1], positions[data[3][1]], data[2][1], commentData, isComments = true); + + sendBothInputs( + eventID, + data[1][1], + data[0][1], + positions[data[3][1]], + data[2][1], + jsonData, + commentData + ); localStorage.setItem("name", name); localStorage.setItem("matchNumber", matchNumber);