├── src ├── img │ └── profile.jpeg ├── index.js ├── firebase │ ├── deleteDocument.js │ ├── deleteFile.js │ ├── addDocument.js │ ├── uploadFile.js │ ├── updateUserRecords.js │ ├── uploadFileProgress.js │ ├── config.js │ ├── useFirestore.js │ └── deleteUserFiles.js ├── components │ ├── MainNotification.js │ ├── user │ │ ├── inputs │ │ │ ├── SubmitButton.js │ │ │ ├── EmailField.js │ │ │ └── PasswordField.js │ │ ├── ResetPassword.js │ │ ├── settings │ │ │ ├── ChangeEmail.js │ │ │ ├── DeleteAccount.js │ │ │ ├── ChangePassword.js │ │ │ ├── ReAuth.js │ │ │ └── AccountSettings.js │ │ ├── Verification.js │ │ ├── Login.js │ │ └── Profile.js │ ├── upload │ │ ├── Upload.js │ │ ├── progressList │ │ │ ├── ProgressList.js │ │ │ ├── CircularProgressWithLabel.js │ │ │ └── ProgressItem.js │ │ └── Form.js │ ├── Loading.js │ ├── Modal.js │ ├── Notify.js │ ├── crop │ │ ├── utils │ │ │ └── cropImage.js │ │ └── CropEasy.js │ ├── imagesList │ │ ├── Options.js │ │ └── ImagesList.js │ └── Nav.js ├── App.js └── context │ └── AuthContext.js ├── webpack.config.js ├── README.md ├── public └── index.html └── package.json /src/img/profile.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codelikepro22/react-firebase-images-gallery/HEAD/src/img/profile.jpeg -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | resolve: { 3 | fallback: { process: require.resolve('process/browser') }, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Firebase Images Gallery Project 2 | 3 | This project was created for [Youtube Lessons](https://www.youtube.com/watch?v=74rGC1e77tw&list=PLufbXXGswL_qTK6wu3yxprYXL42y9Nvh-). 4 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render( 6 | 7 | 8 | , 9 | document.getElementById('root') 10 | ); 11 | -------------------------------------------------------------------------------- /src/firebase/deleteDocument.js: -------------------------------------------------------------------------------- 1 | import { deleteDoc, doc } from 'firebase/firestore'; 2 | import { db } from './config'; 3 | 4 | const deleteDocument = (collectionName, documentId) => { 5 | return deleteDoc(doc(db, collectionName, documentId)); 6 | }; 7 | 8 | export default deleteDocument; 9 | -------------------------------------------------------------------------------- /src/firebase/deleteFile.js: -------------------------------------------------------------------------------- 1 | import { deleteObject, ref } from 'firebase/storage'; 2 | import { storage } from './config'; 3 | 4 | const deleteFile = (filePath) => { 5 | const imageRef = ref(storage, filePath); 6 | return deleteObject(imageRef); 7 | }; 8 | 9 | export default deleteFile; 10 | -------------------------------------------------------------------------------- /src/components/MainNotification.js: -------------------------------------------------------------------------------- 1 | import { useAuth } from '../context/AuthContext'; 2 | import Notify from './Notify'; 3 | 4 | const MainNotification = () => { 5 | const { 6 | alert: { location }, 7 | } = useAuth(); 8 | return location === 'main' && ; 9 | }; 10 | 11 | export default MainNotification; 12 | -------------------------------------------------------------------------------- /src/components/user/inputs/SubmitButton.js: -------------------------------------------------------------------------------- 1 | import { Send } from '@mui/icons-material'; 2 | import { Button } from '@mui/material'; 3 | 4 | const SubmitButton = () => { 5 | return ( 6 | 9 | ); 10 | }; 11 | 12 | export default SubmitButton; 13 | -------------------------------------------------------------------------------- /src/components/upload/Upload.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import Form from './Form'; 3 | import ProgressList from './progressList/ProgressList'; 4 | 5 | const Upload = () => { 6 | const [files, setFiles] = useState([]); 7 | return ( 8 |
9 |
10 | 11 |
12 | ); 13 | }; 14 | 15 | export default Upload; 16 | -------------------------------------------------------------------------------- /src/firebase/addDocument.js: -------------------------------------------------------------------------------- 1 | import { collection, doc, serverTimestamp, setDoc } from 'firebase/firestore'; 2 | import { db } from './config'; 3 | 4 | const addDocument = (collectionName, documentObj, id) => { 5 | const docRef = doc(collection(db, collectionName), id); 6 | return setDoc(docRef, { 7 | ...documentObj, 8 | timestamp: serverTimestamp(), 9 | }); 10 | }; 11 | 12 | export default addDocument; 13 | -------------------------------------------------------------------------------- /src/components/upload/progressList/ProgressList.js: -------------------------------------------------------------------------------- 1 | import { ImageList } from '@mui/material'; 2 | import React from 'react'; 3 | import ProgressItem from './ProgressItem'; 4 | 5 | const ProgressList = ({ files }) => { 6 | return ( 7 | 8 | {files.map((file, index) => ( 9 | 10 | ))} 11 | 12 | ); 13 | }; 14 | 15 | export default ProgressList; 16 | -------------------------------------------------------------------------------- /src/components/Loading.js: -------------------------------------------------------------------------------- 1 | import { Backdrop, CircularProgress } from '@mui/material'; 2 | import { useAuth } from '../context/AuthContext'; 3 | 4 | const Loading = () => { 5 | const { loading } = useAuth(); 6 | return ( 7 | theme.zIndex.drawer + 999 }} 10 | > 11 | 12 | 13 | ); 14 | }; 15 | 16 | export default Loading; 17 | -------------------------------------------------------------------------------- /src/components/user/inputs/EmailField.js: -------------------------------------------------------------------------------- 1 | import { TextField } from '@mui/material'; 2 | 3 | const EmailField = ({ emailRef, defaultValue = '' }) => { 4 | return ( 5 | 17 | ); 18 | }; 19 | 20 | export default EmailField; 21 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | React Firebase Gallery 12 | 13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /src/firebase/uploadFile.js: -------------------------------------------------------------------------------- 1 | import { getDownloadURL, ref, uploadBytes } from 'firebase/storage'; 2 | import { storage } from './config'; 3 | 4 | const uploadFile = (file, filePath) => { 5 | return new Promise(async (resolve, reject) => { 6 | const storageRef = ref(storage, filePath); 7 | try { 8 | await uploadBytes(storageRef, file); 9 | const url = await getDownloadURL(storageRef); 10 | resolve(url); 11 | } catch (error) { 12 | reject(error); 13 | } 14 | }); 15 | }; 16 | 17 | export default uploadFile; 18 | -------------------------------------------------------------------------------- /src/firebase/updateUserRecords.js: -------------------------------------------------------------------------------- 1 | import { 2 | collection, 3 | doc, 4 | getDocs, 5 | query, 6 | updateDoc, 7 | where, 8 | } from 'firebase/firestore'; 9 | import { db } from './config'; 10 | 11 | const updateUserRecords = (collectionName, uid, updatedObj) => { 12 | return new Promise(async (resolve, reject) => { 13 | const q = query(collection(db, collectionName), where('uid', '==', uid)); 14 | try { 15 | const snapshot = await getDocs(q); 16 | const updatePromises = []; 17 | snapshot.forEach((document) => { 18 | updatePromises.push( 19 | updateDoc(doc(db, collectionName, document.id), updatedObj) 20 | ); 21 | }); 22 | await Promise.all(updatePromises); 23 | resolve(); 24 | } catch (error) { 25 | reject(error); 26 | } 27 | }); 28 | }; 29 | 30 | export default updateUserRecords; 31 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import ImagesList from './components/imagesList/ImagesList'; 2 | import Nav from './components/Nav'; 3 | import Upload from './components/upload/Upload'; 4 | import { Container } from '@mui/material'; 5 | import AuthContext from './context/AuthContext'; 6 | import Modal from './components/Modal'; 7 | import MainNotification from './components/MainNotification'; 8 | import Loading from './components/Loading'; 9 | import Verification from './components/user/Verification'; 10 | 11 | function App() { 12 | return ( 13 | 14 | 15 | 16 | 17 | 18 | 19 |