diff --git a/src/components/common/svg/GoogleIcon.jsx b/src/components/common/svg/GoogleIcon.jsx index 4072960..f79d665 100644 --- a/src/components/common/svg/GoogleIcon.jsx +++ b/src/components/common/svg/GoogleIcon.jsx @@ -1,10 +1,33 @@ import React from 'react'; const GoogleIcon = () => { - return ( - - ); -} + return ( + + ); +}; - -export default GoogleIcon; \ No newline at end of file +export default GoogleIcon; diff --git a/src/firebase/firebase-config.jsx b/src/firebase/firebase-config.js similarity index 95% rename from src/firebase/firebase-config.jsx rename to src/firebase/firebase-config.js index 25d20a7..f0b9cb8 100644 --- a/src/firebase/firebase-config.jsx +++ b/src/firebase/firebase-config.js @@ -16,6 +16,8 @@ import { signOut, } from 'firebase/auth'; +import { getStorage } from 'firebase/storage'; + const firebaseConfig = { apiKey: 'AIzaSyBhN3fCW3J8o_eRzUiUZrARHtN2VBQKyC4', authDomain: 'bhacks-2023.firebaseapp.com', @@ -83,3 +85,5 @@ export const addApplicationDoc = async (formData, uid) => { throw err; } }; + +export const storage = getStorage(app); diff --git a/src/pages/Application.jsx b/src/pages/Application.jsx index 4c37d12..689aefe 100644 --- a/src/pages/Application.jsx +++ b/src/pages/Application.jsx @@ -1,10 +1,16 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; -import { auth, addApplicationDoc, db } from '../firebase/firebase-config'; +import { + auth, + addApplicationDoc, + db, + storage, +} from '../firebase/firebase-config'; import { useAuthState } from 'react-firebase-hooks/auth'; -import { doc, getDoc, updateDoc } from 'firebase/firestore'; +import { doc, updateDoc } from 'firebase/firestore'; +import { ref, uploadBytes } from 'firebase/storage'; import { useForm, Controller } from 'react-hook-form'; import Select from 'react-select'; @@ -95,12 +101,12 @@ const Application = ({ applicationId }) => { { language: '', experienceLevel: '' }, ]); const [user, loading] = useAuthState(auth); + const [resume, setResume] = useState(null); const navigate = useNavigate(); const { register, handleSubmit, control } = useForm(); // Function runs on application form submission. const onSubmit = async (data) => { - console.log('inside submit'); // Allow null college major if (!data.collegeMajor) { data.collegeMajor = 'N/A'; @@ -139,7 +145,16 @@ const Application = ({ applicationId }) => { languageExperience: programmingInputs, status: 'Submitted', }); - navigate('/login'); + + if (resume != null) { + const resumeRef = ref(storage, `resumes/${applicationId}`); + uploadBytes(resumeRef, resume).then(() => { + navigate('/login'); + }); + } else { + alert('please upload a resume'); + return; + } }; const onError = async (data, e) => { @@ -189,6 +204,7 @@ const Application = ({ applicationId }) => { useEffect(() => { if (loading) return; + console.log(user); if (!user) navigate('/login'); }, [user, loading, navigate]); @@ -787,6 +803,21 @@ const Application = ({ applicationId }) => { +
+ Resume Upload +
+ { + setResume(e.target.files[0]); + }} + /> +