diff --git a/README.md b/README.md index 0c83cde..594edff 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,7 @@ -# Getting Started with Create React App -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.\ -You will also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) - -### Analyzing the Bundle Size - -This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) - -### Making a Progressive Web App - -This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) - -### Advanced Configuration - -This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) - -### Deployment - -This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) - -### `npm run build` fails to minify - -This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) +# Feelingz-An anonymous platform for people +### This is a prototype-based website which will help people to express their feelings, with identity kept as anonymous. Intention behind this project is to help people to fight their own war against depression. +## Technology Used +### Frontend: HTML, CSS, JS (ReactJS) +### Backend: NodeJS +### Database: Firebase realtime DB diff --git a/package.json b/package.json index 430f906..cfc8c96 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "browserslist": { "production": [ ">0.2%", - "not dead", + "not op_mini all" ], "development": [ diff --git a/public/index.html b/public/index.html index 7dc96df..fa9d7bc 100644 --- a/public/index.html +++ b/public/index.html @@ -26,6 +26,9 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> + + + React App diff --git a/src/App.js b/src/App.js index f951c19..1f94440 100644 --- a/src/App.js +++ b/src/App.js @@ -1,8 +1,8 @@ -import React, { useEffect,useReducer,useState } from "react"; +import React, { useEffect,useReducer } from "react"; import './css/App.css'; //react router -import {BrowserRouter as Router, Switch,Route,Link} from "react-router-dom"; +import {BrowserRouter as Router, Switch,Route} from "react-router-dom"; //toast import {ToastContainer} from "react-toastify"; @@ -17,7 +17,7 @@ import "firebase/database" //ContextAPI STUFF import reducer from "./Context/reducer"; -import UserContext from "./Context/UserContext"; + import PostContext from "./Context/PostContext"; import { SET_POST,SET_LOADING } from "./Context/actions.types"; @@ -27,7 +27,7 @@ import LandingBody from './Components/LandingBody'; import SignIn from './Components/SignIn'; import SignUp from './Components/SignUp'; import NotFound from './Components/NotFound'; -import HomePage from "./Components/HomePage"; + //TODO: create useeffect for calling objects from the database //initializing Firebase at root page @@ -43,10 +43,11 @@ const initialState={ postToUpdateKey:null, isLoading:false, user:{},//because its storing uuid and email + isUpdate:false, }; function App() { const [state,dispatch] = useReducer(reducer,initialState); - const [user,setUser] = useState(null) + const getPosts = async () => { dispatch({ type:SET_LOADING, diff --git a/src/Components/HomePage.js b/src/Components/HomePage.js index c4030a8..5fad062 100644 --- a/src/Components/HomePage.js +++ b/src/Components/HomePage.js @@ -1,6 +1,6 @@ //This page will be shown after logging in! -import React,{useState,useContext,useEffect} from 'react' -import UserContext from "../Context/PostContext"; +import React from 'react' + import Posts from './Posts'; import PostSection from './PostSection'; @@ -13,25 +13,10 @@ import PostSection from './PostSection'; //TODO: SET Loading graphics here //********************************************************************************* */ const HomePage = () => { - const context=useContext(UserContext);//This was done for fetching the email from the context and displaying Hello to the email - // const [postsarray,setPostsarray]= useState([]); - // useEffect(()=>{ - // const localposts = localStorage.getItem("postobject"); - // if(localposts) - // { - // setPostsarray(JSON.parse(localposts));//if localposts present,load it on screen - // } - // },[]); - - // const addPosts = async post => { - // setPostsarray([...postsarray,post]); - // } - // useEffect(() =>{ - // localStorage.setItem("postobject",JSON.stringify(postsarray)) - // },[postsarray]); + return ( -
+
diff --git a/src/Components/LandingBody.js b/src/Components/LandingBody.js index c3d3b3f..0ca1c78 100644 --- a/src/Components/LandingBody.js +++ b/src/Components/LandingBody.js @@ -1,19 +1,18 @@ import React,{useContext} from "react"; -// import UserContext from "../Context/UserContext"; + import "../css/LandingBody.css"; -import {GiThink} from "react-icons/gi"; + import HomePage from "./HomePage"; import LandingPage from "./LandingPage"; import PostContext from "../Context/PostContext"; const LandingBody = () =>{ - // const context = useContext(UserContext); - const {state,dispatch}=useContext(PostContext); + + const {state}=useContext(PostContext); const {user}=state; //TODO: Remove user context - { - //console.log("Context",context); - //alert("LANDINGBODY",context.user); + + if(user.email) { console.log(user); @@ -26,8 +25,9 @@ const LandingBody = () =>{ //working! ) } - } - + + + } export default LandingBody; \ No newline at end of file diff --git a/src/Components/LandingPage.js b/src/Components/LandingPage.js index 99d8f08..a905d87 100644 --- a/src/Components/LandingPage.js +++ b/src/Components/LandingPage.js @@ -8,11 +8,25 @@ const LandingPage = () =>{ return(

Welcome to my website!

+ + What is website about? +
- Feelingz is a website which will help people to express their feelings anonymously. +

Feelingz is a website which will help people to express their feelings anonymously. +

Your identity is kept completely anonymous here! You just need to login and pour out all feelings which are troubling you! +

+ बन्धुरात्मात्मनस्तस्य येनात्मैवात्मना जित: |
+अनात्मनस्तु शत्रुत्वे वर्ते तात्मैव शत्रुवत् || 6|| +

+ Translation: For those who have conquered the mind, it is their friend. For those who have failed to do so, + the mind works like an enemy. +

+


+


+
) } diff --git a/src/Components/NavigationBar.js b/src/Components/NavigationBar.js index 6c492be..4ecea1e 100644 --- a/src/Components/NavigationBar.js +++ b/src/Components/NavigationBar.js @@ -3,23 +3,38 @@ import {Link} from "react-router-dom"; import {GiFlowers} from "react-icons/gi"; import "../css/NavigationBar.css"; import Button from "./Button"; -import Footer from "./Footer"; +import { toast } from "react-toastify"; import PostContext from "../Context/PostContext"; -import { UNSET_USER } from "../Context/actions.types"; +import { POST_TO_UPDATE, UNSET_USER, UPDATE_POST } from "../Context/actions.types"; const NavigationBar = () =>{ const {state,dispatch}=useContext(PostContext); - const {user}=state; + const {user,postToUpdate}=state; console.log(user); var HandleSignOut=()=>{ console.log("OUT"); console.log(state); + if(postToUpdate!==null) + { + postToUpdate + } dispatch({ type:UNSET_USER, }); + dispatch({ + type:UPDATE_POST, + update:false, + }) + dispatch({ + type:POST_TO_UPDATE, + payload:null, + key:null + }); + toast("Signed out Successfully!",{type:"success"}); + console.log("State after Signing out",state); } return(
diff --git a/src/Components/PostSection.js b/src/Components/PostSection.js index 1c139e1..6c3ef1f 100644 --- a/src/Components/PostSection.js +++ b/src/Components/PostSection.js @@ -3,39 +3,24 @@ import React,{useState,useEffect,useContext} from "react"; import { v4 } from "uuid"; import "../css/PostSection.css" import Button from "./Button"; -import Posts from "./Posts"; + import firebase from "firebase/app" //context stuff -import UserContext from "../Context/UserContext"; + import PostContext from "../Context/PostContext"; -import {POST_TO_UPDATE} from "../Context/actions.types" -import { useHistory } from "react-router"; +import {POST_TO_UPDATE, UPDATE_POST} from "../Context/actions.types" + import { toast } from "react-toastify"; //TODO:action function which will be triggered on button click const PostSection = () =>{ const [postString,setPostString] = useState(""); - const [isUpdate, setIsUpdate] = useState(false); - // const context=useContext(UserContext); + //remove this -// const Action = e =>{ -// e.preventDefault(); -// if(postString === "") -// { -// (alert("Enter string")) -// return; -// } -// const post={ -// postString,id:v4() -// }; -// addPosts(post); -// setPostString(""); - -// } const {state,dispatch}=useContext(PostContext); - const {postToUpdate,postToUpdateKey,user}=state; + const {postToUpdate,postToUpdateKey,user,isUpdate}=state; useEffect(()=>{ if(postToUpdate) { @@ -44,7 +29,11 @@ const PostSection = () =>{ // alert("use effect triggered!"); setPostString(postToUpdate.postString); console.log(postToUpdate,postToUpdateKey); - setIsUpdate(true); + dispatch({ + type:UPDATE_POST, + update:true, + }); + } },[postToUpdate]); const email=user.email; @@ -68,7 +57,7 @@ const PostSection = () =>{ }; //Update const updatePost = async () => { -// alert("Update triggered000"); + console.log(postToUpdateKey); try { firebase @@ -88,12 +77,21 @@ console.log(postToUpdateKey); //function which will decide whether we have to update or add post const handleSubmit = e =>{ e.preventDefault(); - if(postString=="") + if(postString==="") { - if(isUpdate==true) + if(isUpdate===true) { + dispatch({ + type:POST_TO_UPDATE, + payload:null, + key:null + }); alert("Please don't leave the update field blank"); - setIsUpdate(false); + //isupdate + dispatch({ + type:UPDATE_POST, + update:false, + }); return; } else{ @@ -103,8 +101,12 @@ const handleSubmit = e =>{ } isUpdate ? updatePost() : addPost(); setPostString(''); - // toast("Success",{type:"success"}); - setIsUpdate(false); + + + dispatch({ + type:UPDATE_POST, + update:false, + }); dispatch({ type:POST_TO_UPDATE, diff --git a/src/Components/Posts.js b/src/Components/Posts.js index dd43e30..e72d1d1 100644 --- a/src/Components/Posts.js +++ b/src/Components/Posts.js @@ -1,36 +1,36 @@ -import React,{useState,useContext,useReducer,useEffect} from 'react'; +import React,{useContext} from 'react'; import "../css/Posts.css"; import { BsTrashFill } from "react-icons/bs"; import { FiEdit2 } from "react-icons/fi"; import {ListGroup,ListGroupItem} from "reactstrap" //TODO: DONE! just fetch the object and display using map function import PostContext from '../Context/PostContext'; -import UserContext from '../Context/UserContext'; + import { SET_POST,SET_LOADING, POST_TO_UPDATE } from '../Context/actions.types'; import firebase from '@firebase/app'; import { toast } from 'react-toastify'; import 'firebase/database'; +import { IconContext } from 'react-icons'; const Posts = () => { const {state,dispatch}= useContext(PostContext);//MISTAKE :used useReducer instead of useContext const {posts,isLoading,user} = state; -// const context=useContext(UserContext); + //test successful! -const [isUpdate, setIsUpdate] = useState(false); -// const [keyy,setKeyy] = useState([]);alert("Hello") -// var flag=false;alert("Hello") + + const updateContact=(keyy,value)=>{ //when button is clicked, set isupdate=true - // console.log(keyy,value); + dispatch({ type:POST_TO_UPDATE, payload:value, key:keyy }); - console.log(state); + } const deleteContact = (key)=>{ try { @@ -52,23 +52,19 @@ const updateContact=(keyy,value)=>{ -// border: 1px solid #ddd; -// margin-top: 38px; -// background-color: #f6f6f6; -// padding: 49px; -// text-align: justify; -// margin: 40px; -// margin-bottom: 18px; + return (

POSTS

{Object.entries(posts).map(([key,value])=>( {value.postString} - {(value.email==user.email) ?( - + {(value.email===user.email) ?( + + updateContact(key,value)}className="ml-2"/> deleteContact(key)} className="text-danger icon"/> + ):(console.log('h'))} @@ -77,14 +73,7 @@ const updateContact=(keyy,value)=>{ ))} -{/* {postsarray.map(post =>( - - {post.postString} - - - - -))} */} +
) diff --git a/src/Components/SignIn.js b/src/Components/SignIn.js index 97852f2..58f8ec2 100644 --- a/src/Components/SignIn.js +++ b/src/Components/SignIn.js @@ -1,10 +1,9 @@ import React, { Fragment } from "react"; -import Footer from "./Footer"; import SignInBody from "./SignInBody"; -import NavigationBar from "./NavigationBar"; + const SignIn = () =>{ - // alert("Hello"); + return( diff --git a/src/Components/SignInBody.js b/src/Components/SignInBody.js index ea2c18b..748569b 100644 --- a/src/Components/SignInBody.js +++ b/src/Components/SignInBody.js @@ -25,7 +25,7 @@ const SignInBody = () =>{ .auth() .signInWithEmailAndPassword(email,password) .then(res =>{ - console.log(res); + dispatch({ type:SET_USER, @@ -35,7 +35,7 @@ const SignInBody = () =>{ } }); - console.log(user); + }) .catch(error =>{ console.log(error); @@ -43,11 +43,13 @@ const SignInBody = () =>{ type:"error" }) }) + toast("Signed in Successfully!",{type:"success"}) + } const handleFormSubmit = e =>{ e.preventDefault(); - if((email=='')||(password=='')) + if((email==='')||(password==='')) { alert("Please enter the missing details.."); @@ -56,7 +58,7 @@ const SignInBody = () =>{ handleSignIn(); } //We need to show this page based on some conditions - //alert("SIGNINBODY",context); + if(user.email){ return diff --git a/src/Components/SignUp.js b/src/Components/SignUp.js index 49bebd9..b0a98ea 100644 --- a/src/Components/SignUp.js +++ b/src/Components/SignUp.js @@ -1,7 +1,7 @@ import React, { Fragment } from "react"; -import Footer from "./Footer"; + import SignUpBody from "./SignUpBody"; -import NavigationBar from "./NavigationBar"; + const SignUp = () =>{ return( diff --git a/src/Components/SignUpBody.js b/src/Components/SignUpBody.js index 11f400d..1362d63 100644 --- a/src/Components/SignUpBody.js +++ b/src/Components/SignUpBody.js @@ -29,7 +29,7 @@ const SignUpBody = () =>{ .then( res =>{ console.log(res); - // context.setUser({email:res.user.email ,uid:res.user.uid}); + dispatch({ type:SET_USER, payload:{ @@ -49,7 +49,7 @@ const SignUpBody = () =>{ } const handleFormSubmit = e =>{ e.preventDefault(); - if((email=='')||(password=='')) + if((email==='')||(password==='')) { alert("Please enter the missing details.."); diff --git a/src/Context/UserContext.js b/src/Context/UserContext.js deleted file mode 100644 index 16998f4..0000000 --- a/src/Context/UserContext.js +++ /dev/null @@ -1,5 +0,0 @@ -import {createContext} from "react"; - -const UserContext = createContext(); - -export default UserContext; \ No newline at end of file diff --git a/src/Context/actions.types.js b/src/Context/actions.types.js index 8524c09..37ee23a 100644 --- a/src/Context/actions.types.js +++ b/src/Context/actions.types.js @@ -3,3 +3,4 @@ export const SET_POST = "SET_POST"; export const POST_TO_UPDATE = "POST_TO_UPDATE"; export const SET_USER = "SET_USER"; export const UNSET_USER = "UNSET_USER"; +export const UPDATE_POST = "UPDATE_POST"; diff --git a/src/Context/reducer.js b/src/Context/reducer.js index 286e1af..5a9e0e2 100644 --- a/src/Context/reducer.js +++ b/src/Context/reducer.js @@ -2,7 +2,8 @@ import { POST_TO_UPDATE, SET_LOADING, SET_POST, SET_USER, - UNSET_USER} from "./actions.types"; + UNSET_USER, + UPDATE_POST} from "./actions.types"; export default (state,action) =>{ switch (action.type) { @@ -22,16 +23,21 @@ export default (state,action) =>{ postToUpdateKey:action.key, }; - case SET_USER: + case SET_USER: //this will add user email and uuid in the state as soon as user logs in return{ ...state, user:action.payload, }; - case UNSET_USER: + case UNSET_USER: //this will reset user={} immediately after user signs out return{ ...state,user:{ }, - } + } + case UPDATE_POST: + return{ + ...state, + isUpdate:action.update, //update will say whether to set true or false + } default: return state; } diff --git a/src/css/Footer.css b/src/css/Footer.css index 1fa9e77..c64212d 100644 --- a/src/css/Footer.css +++ b/src/css/Footer.css @@ -10,7 +10,7 @@ text-align: center; border : 2px solid black; border-top: none; - padding:14px; + padding:17px; background-color: gainsboro; } diff --git a/src/css/HomePage.css b/src/css/HomePage.css new file mode 100644 index 0000000..e69de29 diff --git a/src/css/LandingBody.css b/src/css/LandingBody.css index 3432af7..33fef6e 100644 --- a/src/css/LandingBody.css +++ b/src/css/LandingBody.css @@ -1,6 +1,6 @@ .landpage{ text-align: center; - height:550px; + height:auto; border: 3px solid black; background-color: rgb(71, 255, 71); } @@ -9,4 +9,9 @@ size: 35px; width: 55px; height: 31px; +} +.intro{ + font-family: 'Ubuntu', sans-serif; + padding:2px; + font-size: 24px; } \ No newline at end of file diff --git a/src/css/PostSection.css b/src/css/PostSection.css index 467b7e2..56d7e33 100644 --- a/src/css/PostSection.css +++ b/src/css/PostSection.css @@ -27,7 +27,7 @@ } .button1{ margin-left: 23px; - height: 31px; + height: 47px; border-radius: 20px; /* text-align: center; position: absolute; diff --git a/src/css/Posts.css b/src/css/Posts.css index ecf29f7..2a38f77 100644 --- a/src/css/Posts.css +++ b/src/css/Posts.css @@ -50,5 +50,8 @@ background-color: rgb(86, 197, 66); -webkit-text-decoration: solid; text-decoration: solid; } +.editicon{ + margin:5px; +} \ No newline at end of file diff --git a/src/css/SignInBody.css b/src/css/SignInBody.css index 55175a1..0a21f74 100644 --- a/src/css/SignInBody.css +++ b/src/css/SignInBody.css @@ -1,6 +1,6 @@ .SignInbody { text-align: center; - height:550px; + height:590px; border: 3px solid black; padding: 20px; background-color: rgb(71, 255, 71); diff --git a/src/css/SignUpBody.css b/src/css/SignUpBody.css index 2b8c198..3a0dfce 100644 --- a/src/css/SignUpBody.css +++ b/src/css/SignUpBody.css @@ -1,6 +1,6 @@ .signupbody { text-align: center; - height:550px; + height: 590px; border: 3px solid black; /* background-color: rgb(36, 195, 97); */ padding: 20px;