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 85f9961..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; @@ -108,9 +108,31 @@ 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 = 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((error) => { + console.error("Error sending data to database: ", error); + sendBothInputs(eventID, matchNumber, name, position, teamNumber, jsonData, commentData); + }); + } + + 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);