Skip to content

Commit

Permalink
Merge pull request #126 from awest25/dynamicURLUPdate
Browse files Browse the repository at this point in the history
transformData bug and update dynamicURL
  • Loading branch information
Fredenck authored Apr 18, 2024
2 parents eaac27a + f2e9aef commit 4b1f31b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions app/(interactive)/matches/[slug]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import PointsList from '../../../components/PointsList';
import ScoreBoard from '../../../components/ScoreBoard';
import MatchTiles from '@/app/components/MatchTiles'; // delete later just for testing

import { collection, getDocs } from 'firebase/firestore';
import { doc, getDoc } from 'firebase/firestore';
import { db } from '../../../services/initializeFirebase';
import transformData from '../../../services/transformData';
import nameMap from '../../../services/nameMap';
Expand All @@ -36,7 +36,7 @@ const MatchPage = () => {

// const router = useRouter();
const pathname = usePathname()
const videoId = pathname.substring(pathname.lastIndexOf('/') + 1);
const docId = pathname.substring(pathname.lastIndexOf('/') + 1);

// Function to jump to a specific time in the video, given in milliseconds, via the YouTube Player API
const handleJumpToTime = (time) => {
Expand All @@ -48,11 +48,10 @@ const MatchPage = () => {
useEffect(() => {
const fetchData = async () => {
try {
const querySnapshot = await getDocs(collection(db, 'matches'));
const matches = querySnapshot.docs.map((doc) => doc.data());
const match = matches.find((match) => match.videoId === videoId);
const matchv2 = transformData(match);
setMatchData(matchv2);
const documentRef = doc(db, 'matches', docId);
const documentSnapshot = await getDoc(documentRef);
const transformedData = transformData(documentSnapshot.data());
setMatchData(transformedData)
} catch (error) {
console.error('Error fetching data:', error);
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/SearchDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SearchDropdown = () => {
.map((doc) => {
const data = doc.data();
return {
value: data.videoId, // Use 'value' to adhere to react-select convention
value: doc.id, // Use 'value' to adhere to react-select convention
label: data.name
};
});
Expand Down
2 changes: 1 addition & 1 deletion app/services/transformData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function transformData(matchData) {
let dataVersion = -1;

// This is the original Dartfish format we used.
if (pointsData[0].Position) {
if (pointsData[0].hasOwnProperty('Position')) {
dataVersion = 0;
}
// This is the new format Leo made.
Expand Down

0 comments on commit 4b1f31b

Please sign in to comment.