Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncing w/ firebase #51

Merged
merged 15 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ yarn-error.*
.env*.local

# typescript
*.tsbuildinfo
*.tsbuildinfo
6 changes: 4 additions & 2 deletions app/components/NavButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ interface NavButtonProps {
text: string;
pageName?: string;
disabled?: boolean;
onClick?: () => void;
}

function NavButton({ text, pageName, disabled }: NavButtonProps) {
function NavButton({ text, pageName, disabled, onClick }: NavButtonProps) {
pageName ??= "";
disabled ??= false;
onClick ??= () => {};
const insets = useSafeAreaInsets();

return (
Expand All @@ -23,7 +25,7 @@ function NavButton({ text, pageName, disabled }: NavButtonProps) {
}]}>
<Link href={"/" + pageName} asChild>
<Button textColor={TEXT_COLOR} buttonColor={BACKGROUND_COLOR} mode="contained"
contentStyle={{ height: 80, width: 80 }} disabled={disabled}>{text}</Button>
contentStyle={{ height: 80, width: 80 }} onPress={onClick} disabled={disabled}>{text}</Button>
</Link>
</View>
)
Expand Down
22 changes: 22 additions & 0 deletions app/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,26 @@ import LabeledTextInput from './components/LabeledTextInput';
import { getMatchData, updateNotes } from './api/data';
import PageHeader from './components/Header';
import SummaryTableView from './views/SummaryTableView';
import NavButton from './components/NavButton';
import { getDatabase, ref, set } from 'firebase/database';
import { useEffect, useState } from 'react';
import { firebase, db } from '../firebaseConfig';

export default function App() {
const [ scouterName, setScouterName ] = useState("");
const [ matchNumber, setMatchNumber ] = useState(0);
const [ teamNumber, setTeamNumber ] = useState(0);
const [ matchData, setMatchData ] = useState({});

useEffect(() => {
getMatchData().then((data) => {
setScouterName(data["scouterName"]);
setMatchNumber(data["matchNumber"]);
setTeamNumber(data["teamNumber"]);
setMatchData(data);
});
}, []);

return (
<View style={styles.container}>
<PageHeader title="Summary" pageNumber="4/4" previous='teleop' />
Expand All @@ -17,6 +35,10 @@ export default function App() {
updateNotes(e.nativeEvent.text);
}} oldValue={getMatchData().then((data) => data["notes"])} required />
<Dropdown label="Tags" items={["tag 1", "tag 2"]} placeholder="tag"></Dropdown>

<NavButton text="End" onClick={() => {
set(ref(db, `team_${teamNumber}/${matchNumber}_${scouterName}`), matchData);
}} />
<StatusBar style="auto" />
</View>
);
Expand Down
18 changes: 18 additions & 0 deletions firebaseConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getDatabase } from "firebase/database";

// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyDKDbQsh-ttXTBBpewtfiI_6ag_OABlrPE",
authDomain: "strategy-programming-7525.firebaseapp.com",
databaseURL: "https://strategy-programming-7525-default-rtdb.firebaseio.com",
projectId: "strategy-programming-7525",
storageBucket: "strategy-programming-7525.firebasestorage.app",
messagingSenderId: "611655993814",
appId: "1:611655993814:web:7c30807b2ccdf1303e3c77"
};

// Initialize Firebase
export const firebase = initializeApp(firebaseConfig);
export const db = getDatabase(firebase);
6 changes: 6 additions & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { getDefaultConfig } = require('@expo/metro-config');

const defaultConfig = getDefaultConfig(__dirname);
defaultConfig.resolver.sourceExts.push('cjs');

module.exports = defaultConfig;
Loading