diff --git a/App.js b/App.js index ecdf448..1bca7bb 100644 --- a/App.js +++ b/App.js @@ -24,7 +24,7 @@ export default function App() { // persistence: getReactNativePersistence(ReactNativeAsyncStorage) //async-storage in Waiver page return ( - + diff --git a/pages/Waiver.js b/pages/Waiver.js index 44ee839..090b906 100644 --- a/pages/Waiver.js +++ b/pages/Waiver.js @@ -2,8 +2,10 @@ import Checkbox from 'expo-checkbox'; import React, { useEffect, useState } from 'react'; import { ScrollView, View, Text, TextInput, TouchableOpacity, StyleSheet, Image, CheckBox, Alert } from 'react-native'; import { addWaiver } from "./api/waivers.js" +import { collection, addDoc } from 'firebase/firestore'; import { doc, getDoc } from 'firebase/firestore'; import { auth, db } from '../firebaseConfig'; +import { getAuth } from 'firebase/auth'; export default function Waiver({route, navigation}) { const [lastName, setLastName] = useState(''); @@ -34,52 +36,113 @@ export default function Waiver({route, navigation}) { const [isChecked, setIsChecked] = useState(false); const [uid, setUid] = useState(''); - // await and async? - const handleSubmit = () => { - // Firebase + useEffect(() => { + const auth = getAuth(); + const user = auth.currentUser; + if (user) { + setUid(user.uid); + } + }, []); + + const handleSubmit = async () => { if (isChecked) { - if (lastName || firstInitial || volunteerName || volunteerEmail || volunteerPhoneCell || volunteerPhoneHome - || homeAddress || homeCity || homeZip || mailingAddress || mailingCity || mailingZip || emergencyContactName - || emergencyContactRelationship || emergencyContactPhoneCell || emergencyContactPhoneHome || volunteerAgreement - || volunteerDate) { - addWaiver(uid, emergencyContactName, emergencyContactPhoneCell, emergencyContactPhoneHome, - emergencyContactRelationship, firstInitial, homeAddress, homeCity, homeZip, lastName, - mailingAddress, mailingCity, mailingZip, parentGuardianAddress, parentGuardianEmail, - parentGuardianName, parentGuardianSignature, volunteerDate, volunteerEmail, volunteerName, - volunteerPhoneCell, volunteerPhoneHome, volunteerSignature); + const waiverData = { + uid, // Include uid in the waiver data + emergencyContactName, + emergencyContactPhoneCell, + emergencyContactPhoneHome, + emergencyContactRelationship, + firstInitial, + homeAddress, + homeCity, + homeZip, + lastName, + mailingAddress, + mailingCity, + mailingZip, + parentGuardianAddress, + parentGuardianEmail, + parentGuardianName, + parentGuardianSignature, + volunteerDate, + volunteerEmail, + volunteerName, + volunteerPhoneCell, + volunteerPhoneHome, + volunteerSignature, + }; + + const hasData = Object.values(waiverData).some(value => value && value.trim()); + + if (hasData) { + try { + await addDoc(collection(db, "waivers"), waiverData); + Alert.alert("Waiver submitted successfully!"); navigation.navigate("Events"); + } catch (error) { + console.error("Error submitting waiver:", error); + Alert.alert("Error submitting waiver. Please try again."); + } + } else { + Alert.alert("Please fill out at least one field."); } - } - else { + } else { Alert.alert("Please agree to the Terms and Conditions"); } }; - useEffect( () => { - async function fetchData() { - const { item } = route.params; - setUid(item.uid); - console.log(item.uid); +// // await and async? +// const handleSubmit = () => { +// // Firebase +// if (isChecked) { +// if (lastName || firstInitial || volunteerName || volunteerEmail || volunteerPhoneCell || volunteerPhoneHome +// || homeAddress || homeCity || homeZip || mailingAddress || mailingCity || mailingZip || emergencyContactName +// || emergencyContactRelationship || emergencyContactPhoneCell || emergencyContactPhoneHome || volunteerAgreement +// || volunteerDate) { +// addWaiver(uid, emergencyContactName, emergencyContactPhoneCell, emergencyContactPhoneHome, +// emergencyContactRelationship, firstInitial, homeAddress, homeCity, homeZip, lastName, +// mailingAddress, mailingCity, mailingZip, parentGuardianAddress, parentGuardianEmail, +// parentGuardianName, parentGuardianSignature, volunteerDate, volunteerEmail, volunteerName, +// volunteerPhoneCell, volunteerPhoneHome, volunteerSignature); +// navigation.navigate("Events"); +// } +// } +// else { +// Alert.alert("Please agree to the Terms and Conditions"); +// } +// }; + +// useEffect( () => { +// async function fetchData() { +// const { item } = route.params; +// setUid(item.uid); +// console.log(item.uid); - const userRef = await getDoc(doc(db, "users", item.uid)); +// const userRef = await getDoc(doc(db, "users", item.uid)); - setLastName(userRef.data().lname); - setFirstInitial(userRef.data().fname[0]); - setVolunteerName(userRef.data().fname + " " + userRef.data().lname); - setVolunteerEmail(userRef.data().email); - setVolunteerPhoneCell(userRef.data().phone); +// setLastName(userRef.data().lname); +// setFirstInitial(userRef.data().fname[0]); +// setVolunteerName(userRef.data().fname + " " + userRef.data().lname); +// setVolunteerEmail(userRef.data().email); +// setVolunteerPhoneCell(userRef.data().phone); + +// // cpontinue doing all the fields from signup!!! slay +// // const event = item; +// // const eventData = event.data(); +// } +// fetchData(); +// }, []) - // cpontinue doing all the fields from signup!!! slay - // const event = item; - // const eventData = event.data(); - } - fetchData(); - }, []) return ( - + {/* */} + + + 9341 Mill Street, Ben Lomond, CA 95005 831-336-3513 + www.mountainartcenter.org + Last Name @@ -99,8 +162,8 @@ export default function Waiver({route, navigation}) { - 9341 Mill Street, Ben Lomond, CA 95005 831-336-3513 - www.mountainartcenter.org + {/* 9341 Mill Street, Ben Lomond, CA 95005 831-336-3513 + www.mountainartcenter.org */} VOLUNTEER WAIVER Release Agreement & Emergency Contact Information @@ -316,44 +379,56 @@ const styles = StyleSheet.create({ headerContainer: { flexDirection: 'row', // justifyContent: 'space-between', - justifyContent: 'flex-start', - alignItems: 'center', + justifyContent: 'space-around', + alignItems: 'flex-start',//align logo and Last name/1st init inputs with main content + // width: '105%', + width: '90%', +// paddingHorizontal: "5%" + }, + logoContainer: { + alignItems: 'flex-start', }, headerRight: { //initial identity - marginTop: 100, + marginTop: 50, alignItems: 'flex-line', flexDirection:'row', - marginLeft: 20, +// marginLeft: 20, + // justifyContent:'space-around' }, logo: { - marginTop: 100, + marginTop: 50, width: 150, height: 50, - marginRight: 20, //distance between logo and init identity + // marginRight: 20, //distance between logo and init identity + flexDirection: 'row', + alignItems: 'flex-start', + resizeMode: 'contain' }, inputContainer: { // marginBottom: 10, - width: 70, - marginLeft: 20, + width: 60, + marginLeft: 10, + justifyContent: "space-around", + marginRight: -6 }, inputLabel: { marginBottom: 5, - fontSize: 14, + marginLeft: 5, + fontSize: 10, color: '#333', fontWeight: 'normal', }, addressText: { fontSize: 8, textAlign: 'left', - marginBottom: 10, - marginRight: 124, + // marginRight: 485, }, scmacEmail: { fontSize: 8, textAlign: 'left', marginBottom: 10, - marginTop: 0.05, - marginRight: 240, + // marginTop: 0.05, + // marginLeft: -600, }, formContainer: { width: '80%', diff --git a/pages/admin/adminIndividualEvent.js b/pages/admin/adminIndividualEvent.js index 7f386b2..dbef4ba 100644 --- a/pages/admin/adminIndividualEvent.js +++ b/pages/admin/adminIndividualEvent.js @@ -9,7 +9,7 @@ import { auth, db } from '../../firebaseConfig'; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { NavigationContainer, useFocusEffect } from '@react-navigation/native'; import { Octicons, Entypo } from '@expo/vector-icons'; -import OptionsMenu from "react-native-options-menu"; +// import OptionsMenu from "react-native-options-menu"; import { createEvent } from '../api/event'; const Tab = createMaterialTopTabNavigator(); diff --git a/pages/admin/adminVolunteers.js b/pages/admin/adminVolunteers.js index 9bade27..d472dd9 100644 --- a/pages/admin/adminVolunteers.js +++ b/pages/admin/adminVolunteers.js @@ -197,7 +197,8 @@ const styles = StyleSheet.create({ filterContainer: { marginTop: 10, padding: 10, - flexDirection: 'row' + flexDirection: 'row', + justifyContent: 'space-around' // adjust filter spacing // backgroundColor: 'rgba(255, 0, 0, 0.3)', }, dateHeader: { @@ -207,6 +208,7 @@ const styles = StyleSheet.create({ }, buttonContainer: { flexDirection: 'row', + justifyContent:'center' }, button: { paddingVertical: 5, @@ -218,6 +220,7 @@ const styles = StyleSheet.create({ color: '#939393', fontSize: 16, fontWeight: 'bold', + }, circle: { width: 40, @@ -228,7 +231,8 @@ const styles = StyleSheet.create({ }, textContainer: { flex: 1, - marginLeft: "5%" + marginLeft: "5%", + justifyContent: 'center' }, name: { fontSize: 16, @@ -245,6 +249,7 @@ const styles = StyleSheet.create({ position: 'absolute', top: -10, right: 0, + // textAlign:'center' }, moreButtonText: { fontSize: 20, @@ -272,10 +277,17 @@ const styles = StyleSheet.create({ justifyContent: 'center', alignContent: 'center', }, + exportButtonContainer: { + flexDirection: 'row', + justifyContent: 'center', + width: "100%", + marginTop: 20, + }, exportButton: { color: 'white', fontSize: 16, fontWeight: 'bold', + }, }); diff --git a/tempCodeRunnerFile.js b/tempCodeRunnerFile.js new file mode 100644 index 0000000..9fb75b8 --- /dev/null +++ b/tempCodeRunnerFile.js @@ -0,0 +1 @@ +E \ No newline at end of file