├── .gitignore ├── README.md ├── build ├── _redirects ├── asset-manifest.json ├── favicon.png ├── index.html ├── manifest.json ├── precache-manifest.6c79c24bbe33c3bfdb7d79ed851bd1d0.js ├── robots.txt ├── service-worker.js └── static │ ├── css │ ├── main.050523cc.chunk.css │ └── main.050523cc.chunk.css.map │ └── js │ ├── 2.27d8e5b0.chunk.js │ ├── 2.27d8e5b0.chunk.js.LICENSE.txt │ ├── 2.27d8e5b0.chunk.js.map │ ├── main.36c2a1b6.chunk.js │ ├── main.36c2a1b6.chunk.js.map │ ├── runtime-main.ff02b437.js │ └── runtime-main.ff02b437.js.map ├── package.json ├── photos ├── account.PNG ├── architecture.png ├── favicon.png ├── login and dashboard.gif ├── login.PNG ├── signup.PNG └── tododashboard.PNG ├── public ├── _redirects ├── favicon.png ├── index.html ├── manifest.json └── robots.txt ├── src ├── App.css ├── App.js ├── App.test.js ├── components │ ├── account.js │ └── todo.js ├── index.js ├── pages │ ├── home.js │ ├── login.js │ └── signup.js ├── serviceWorker.js ├── setupTests.js └── util │ └── auth.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | 13 | # misc 14 | .DS_Store 15 | .env.local 16 | .env.development.local 17 | .env.test.local 18 | .env.production.local 19 | 20 | npm-debug.log* 21 | yarn-debug.log* 22 | yarn-error.log* 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##### Full Tutorial with auth implementation using Firebase: 2 | 3 | https://www.freecodecamp.org/news/how-to-build-a-todo-application-using-reactjs-and-firebase/ 4 | 5 | 6 | ### Demo 7 | url - https://reacttodoappfirebaseauth.netlify.app/ 8 | 9 | 10 | ## Architecture 11 | 12 | ![image](https://github.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/blob/master/photos/architecture.png) 13 | 14 | 15 | ## screens 16 | 17 | ![image](https://github.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/blob/master/photos/login.PNG) 18 | 19 | ![image](https://github.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/blob/master/photos/signup.PNG) 20 | 21 | ![image](https://github.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/blob/master/photos/tododashboard.PNG) 22 | 23 | ![image](https://github.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/blob/master/photos/account.PNG) 24 | 25 | #### Components used 26 | 27 | - ReactJS 28 | - Material UI 29 | - Firebase 30 | - ExpressJS 31 | - Postman 32 | 33 | 34 | ******************************************************************************************************************************** 35 | 36 | 37 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 38 | 39 | ## Available Scripts 40 | 41 | In the project directory, you can run: 42 | 43 | ### `yarn start` 44 | 45 | Runs the app in the development mode.
46 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 47 | 48 | The page will reload if you make edits.
49 | You will also see any lint errors in the console. 50 | 51 | ### `yarn test` 52 | 53 | Launches the test runner in the interactive watch mode.
54 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 55 | 56 | ### `yarn build` 57 | 58 | Builds the app for production to the `build` folder.
59 | It correctly bundles React in production mode and optimizes the build for the best performance. 60 | 61 | The build is minified and the filenames include the hashes.
62 | Your app is ready to be deployed! 63 | 64 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 65 | 66 | ### `yarn eject` 67 | 68 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 69 | 70 | 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. 71 | 72 | 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. 73 | 74 | 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. 75 | 76 | ## Learn More 77 | 78 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 79 | 80 | To learn React, check out the [React documentation](https://reactjs.org/). 81 | 82 | ### Code Splitting 83 | 84 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 85 | 86 | ### Analyzing the Bundle Size 87 | 88 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 89 | 90 | ### Making a Progressive Web App 91 | 92 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 93 | 94 | ### Advanced Configuration 95 | 96 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 97 | 98 | ### Deployment 99 | 100 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 101 | 102 | ### `yarn build` fails to minify 103 | 104 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 105 | -------------------------------------------------------------------------------- /build/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 -------------------------------------------------------------------------------- /build/asset-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": { 3 | "main.css": "/static/css/main.050523cc.chunk.css", 4 | "main.js": "/static/js/main.36c2a1b6.chunk.js", 5 | "main.js.map": "/static/js/main.36c2a1b6.chunk.js.map", 6 | "runtime-main.js": "/static/js/runtime-main.ff02b437.js", 7 | "runtime-main.js.map": "/static/js/runtime-main.ff02b437.js.map", 8 | "static/js/2.27d8e5b0.chunk.js": "/static/js/2.27d8e5b0.chunk.js", 9 | "static/js/2.27d8e5b0.chunk.js.map": "/static/js/2.27d8e5b0.chunk.js.map", 10 | "index.html": "/index.html", 11 | "precache-manifest.6c79c24bbe33c3bfdb7d79ed851bd1d0.js": "/precache-manifest.6c79c24bbe33c3bfdb7d79ed851bd1d0.js", 12 | "service-worker.js": "/service-worker.js", 13 | "static/css/main.050523cc.chunk.css.map": "/static/css/main.050523cc.chunk.css.map", 14 | "static/js/2.27d8e5b0.chunk.js.LICENSE.txt": "/static/js/2.27d8e5b0.chunk.js.LICENSE.txt" 15 | }, 16 | "entrypoints": [ 17 | "static/js/runtime-main.ff02b437.js", 18 | "static/js/2.27d8e5b0.chunk.js", 19 | "static/css/main.050523cc.chunk.css", 20 | "static/js/main.36c2a1b6.chunk.js" 21 | ] 22 | } -------------------------------------------------------------------------------- /build/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/build/favicon.png -------------------------------------------------------------------------------- /build/index.html: -------------------------------------------------------------------------------- 1 | Todo List App with firebase Authentication
-------------------------------------------------------------------------------- /build/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /build/precache-manifest.6c79c24bbe33c3bfdb7d79ed851bd1d0.js: -------------------------------------------------------------------------------- 1 | self.__precacheManifest = (self.__precacheManifest || []).concat([ 2 | { 3 | "revision": "ad2fb95f6244fafa9b0e393eafd278e9", 4 | "url": "/index.html" 5 | }, 6 | { 7 | "revision": "70fc031d7f087b1079d9", 8 | "url": "/static/css/main.050523cc.chunk.css" 9 | }, 10 | { 11 | "revision": "24d7ddc2c4780399e258", 12 | "url": "/static/js/2.27d8e5b0.chunk.js" 13 | }, 14 | { 15 | "revision": "0749163b59fbee32225059cb60c18af6", 16 | "url": "/static/js/2.27d8e5b0.chunk.js.LICENSE.txt" 17 | }, 18 | { 19 | "revision": "70fc031d7f087b1079d9", 20 | "url": "/static/js/main.36c2a1b6.chunk.js" 21 | }, 22 | { 23 | "revision": "03cc00eb0c215cdb696d", 24 | "url": "/static/js/runtime-main.ff02b437.js" 25 | } 26 | ]); -------------------------------------------------------------------------------- /build/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /build/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Welcome to your Workbox-powered service worker! 3 | * 4 | * You'll need to register this file in your web app and you should 5 | * disable HTTP caching for this file too. 6 | * See https://goo.gl/nhQhGp 7 | * 8 | * The rest of the code is auto-generated. Please don't update this file 9 | * directly; instead, make changes to your Workbox build configuration 10 | * and re-run your build process. 11 | * See https://goo.gl/2aRDsh 12 | */ 13 | 14 | importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"); 15 | 16 | importScripts( 17 | "/precache-manifest.6c79c24bbe33c3bfdb7d79ed851bd1d0.js" 18 | ); 19 | 20 | self.addEventListener('message', (event) => { 21 | if (event.data && event.data.type === 'SKIP_WAITING') { 22 | self.skipWaiting(); 23 | } 24 | }); 25 | 26 | workbox.core.clientsClaim(); 27 | 28 | /** 29 | * The workboxSW.precacheAndRoute() method efficiently caches and responds to 30 | * requests for URLs in the manifest. 31 | * See https://goo.gl/S9QRab 32 | */ 33 | self.__precacheManifest = [].concat(self.__precacheManifest || []); 34 | workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); 35 | 36 | workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), { 37 | 38 | blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/], 39 | }); 40 | -------------------------------------------------------------------------------- /build/static/css/main.050523cc.chunk.css: -------------------------------------------------------------------------------- 1 | .App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{-webkit-animation:App-logo-spin 20s linear infinite;animation:App-logo-spin 20s linear infinite}}.App-header{background-color:#282c34;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:calc(10px + 2vmin);color:#fff}.App-link{color:#61dafb}@-webkit-keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}} 2 | /*# sourceMappingURL=main.050523cc.chunk.css.map */ -------------------------------------------------------------------------------- /build/static/css/main.050523cc.chunk.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["App.css"],"names":[],"mappings":"AAAA,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,mDAA4C,CAA5C,2CACF,CACF,CAEA,YACE,wBAAyB,CACzB,gBAAiB,CACjB,YAAa,CACb,qBAAsB,CACtB,kBAAmB,CACnB,sBAAuB,CACvB,4BAA6B,CAC7B,UACF,CAEA,UACE,aACF,CAEA,iCACE,GACE,sBACF,CACA,GACE,uBACF,CACF,CAPA,yBACE,GACE,sBACF,CACA,GACE,uBACF,CACF","file":"main.050523cc.chunk.css","sourcesContent":[".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"]} -------------------------------------------------------------------------------- /build/static/js/2.27d8e5b0.chunk.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /** 8 | * A better abstraction over CSS. 9 | * 10 | * @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present 11 | * @website https://github.com/cssinjs/jss 12 | * @license MIT 13 | */ 14 | 15 | /** @license React v0.19.1 16 | * scheduler.production.min.js 17 | * 18 | * Copyright (c) Facebook, Inc. and its affiliates. 19 | * 20 | * This source code is licensed under the MIT license found in the 21 | * LICENSE file in the root directory of this source tree. 22 | */ 23 | 24 | /** @license React v16.13.1 25 | * react-dom.production.min.js 26 | * 27 | * Copyright (c) Facebook, Inc. and its affiliates. 28 | * 29 | * This source code is licensed under the MIT license found in the 30 | * LICENSE file in the root directory of this source tree. 31 | */ 32 | 33 | /** @license React v16.13.1 34 | * react-is.production.min.js 35 | * 36 | * Copyright (c) Facebook, Inc. and its affiliates. 37 | * 38 | * This source code is licensed under the MIT license found in the 39 | * LICENSE file in the root directory of this source tree. 40 | */ 41 | 42 | /** @license React v16.13.1 43 | * react.production.min.js 44 | * 45 | * Copyright (c) Facebook, Inc. and its affiliates. 46 | * 47 | * This source code is licensed under the MIT license found in the 48 | * LICENSE file in the root directory of this source tree. 49 | */ 50 | -------------------------------------------------------------------------------- /build/static/js/main.36c2a1b6.chunk.js: -------------------------------------------------------------------------------- 1 | (this.webpackJsonpview=this.webpackJsonpview||[]).push([[0],{143:function(e,t,a){e.exports=a(191)},188:function(e,t,a){},191:function(e,t,a){"use strict";a.r(t);var n=a(0),o=a.n(n),r=a(9),l=a.n(r),i=a(126),s=a(11),c=a(18),m=a(27),u=a(28),d=a(29),p=a(31),h=a(248),g=a(228),f=a(226),b=a(247),E=a(231),v=a(230),y=a(71),N=a.n(y),C=a(52),w=a(24),x=a.n(w),S=a(224),T=a(229),k=a(12),O=a.n(k),j=function(e){Object(p.a)(a,e);var t=Object(d.a)(a);function a(e){var n;return Object(m.a)(this,a),(n=t.call(this,e)).handleChange=function(e){n.setState(Object(c.a)({},e.target.name,e.target.value))},n.handleSubmit=function(e){e.preventDefault(),n.setState({loading:!0});var t={email:n.state.email,password:n.state.password};O.a.post("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/login",t).then((function(e){localStorage.setItem("AuthToken","Bearer ".concat(e.data.token)),n.setState({loading:!1}),n.props.history.push("/")})).catch((function(e){n.setState({errors:e.response.data,loading:!1})}))},n.state={email:"",password:"",errors:[],loading:!1},n}return Object(u.a)(a,[{key:"render",value:function(){var e=this.props.classes,t=this.state,a=t.errors,n=t.loading;return o.a.createElement(S.a,{component:"main",maxWidth:"xs"},o.a.createElement(f.a,null),o.a.createElement("div",{className:e.paper},o.a.createElement(h.a,{className:e.avatar},o.a.createElement(N.a,null)),o.a.createElement(C.a,{component:"h1",variant:"h5"},"Login"),o.a.createElement("form",{className:e.form,noValidate:!0},o.a.createElement(b.a,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,id:"email",label:"Email Address",name:"email",autoComplete:"email",autoFocus:!0,helperText:a.email,error:!!a.email,onChange:this.handleChange}),o.a.createElement(b.a,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,name:"password",label:"Password",type:"password",id:"password",autoComplete:"current-password",helperText:a.password,error:!!a.password,onChange:this.handleChange}),o.a.createElement(g.a,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",className:e.submit,onClick:this.handleSubmit,disabled:n||!this.state.email||!this.state.password},"Sign In",n&&o.a.createElement(T.a,{size:30,className:e.progess})),o.a.createElement(v.a,{container:!0},o.a.createElement(v.a,{item:!0},o.a.createElement(E.a,{href:"signup",variant:"body2"},"Don't have an account? Sign Up"))),a.general&&o.a.createElement(C.a,{variant:"body2",className:e.customError},a.general))))}}]),a}(n.Component),W=x()((function(e){return{paper:{marginTop:e.spacing(8),display:"flex",flexDirection:"column",alignItems:"center"},avatar:{margin:e.spacing(1),backgroundColor:e.palette.secondary.main},form:{width:"100%",marginTop:e.spacing(1)},submit:{margin:e.spacing(3,0,2)},customError:{color:"red",fontSize:"0.8rem",marginTop:10},progess:{position:"absolute"}}}))(j),P=function(e){Object(p.a)(a,e);var t=Object(d.a)(a);function a(e){var n;return Object(m.a)(this,a),(n=t.call(this,e)).handleChange=function(e){n.setState(Object(c.a)({},e.target.name,e.target.value))},n.handleSubmit=function(e){e.preventDefault(),n.setState({loading:!0});var t={firstName:n.state.firstName,lastName:n.state.lastName,phoneNumber:n.state.phoneNumber,country:n.state.country,username:n.state.username,email:n.state.email,password:n.state.password,confirmPassword:n.state.confirmPassword};O.a.post("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/signup",t).then((function(e){localStorage.setItem("AuthToken","".concat(e.data.token)),n.setState({loading:!1}),n.props.history.push("/")})).catch((function(e){n.setState({errors:e.response.data,loading:!1})}))},n.state={firstName:"",lastName:"",phoneNumber:"",country:"",username:"",email:"",password:"",confirmPassword:"",errors:[],loading:!1},n}return Object(u.a)(a,[{key:"componentWillReceiveProps",value:function(e){e.UI.errors&&this.setState({errors:e.UI.errors})}},{key:"render",value:function(){var e=this.props.classes,t=this.state,a=t.errors,n=t.loading;return o.a.createElement(S.a,{component:"main",maxWidth:"xs"},o.a.createElement(f.a,null),o.a.createElement("div",{className:e.paper},o.a.createElement(h.a,{className:e.avatar},o.a.createElement(N.a,null)),o.a.createElement(C.a,{component:"h1",variant:"h5"},"Sign up"),o.a.createElement("form",{className:e.form,noValidate:!0},o.a.createElement(v.a,{container:!0,spacing:2},o.a.createElement(v.a,{item:!0,xs:12,sm:6},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"firstName",label:"First Name",name:"firstName",autoComplete:"firstName",helperText:a.firstName,error:!!a.firstName,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12,sm:6},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"lastName",label:"Last Name",name:"lastName",autoComplete:"lastName",helperText:a.lastName,error:!!a.lastName,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12,sm:6},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"username",label:"User Name",name:"username",autoComplete:"username",helperText:a.username,error:!!a.username,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12,sm:6},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"phoneNumber",label:"Phone Number",name:"phoneNumber",autoComplete:"phoneNumber",pattern:"[7-9]{1}[0-9]{9}",helperText:a.phoneNumber,error:!!a.phoneNumber,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"email",label:"Email Address",name:"email",autoComplete:"email",helperText:a.email,error:!!a.email,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"country",label:"Country",name:"country",autoComplete:"country",helperText:a.country,error:!!a.country,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,name:"password",label:"Password",type:"password",id:"password",autoComplete:"current-password",helperText:a.password,error:!!a.password,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,name:"confirmPassword",label:"Confirm Password",type:"password",id:"confirmPassword",autoComplete:"current-password",onChange:this.handleChange}))),o.a.createElement(g.a,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",className:e.submit,onClick:this.handleSubmit,disabled:n||!this.state.email||!this.state.password||!this.state.firstName||!this.state.lastName||!this.state.country||!this.state.username||!this.state.phoneNumber},"Sign Up",n&&o.a.createElement(T.a,{size:30,className:e.progess})),o.a.createElement(v.a,{container:!0,justify:"flex-end"},o.a.createElement(v.a,{item:!0},o.a.createElement(E.a,{href:"login",variant:"body2"},"Already have an account? Sign in"))))))}}]),a}(n.Component),I=x()((function(e){return{paper:{marginTop:e.spacing(8),display:"flex",flexDirection:"column",alignItems:"center"},avatar:{margin:e.spacing(1),backgroundColor:e.palette.secondary.main},form:{width:"100%",marginTop:e.spacing(3)},submit:{margin:e.spacing(3,0,2)},progess:{position:"absolute"}}}))(P),L=a(77),A=a(120),z=a.n(A),B=a(233),D=a(234),q=a(235),V=a(236),F=a(3),H=function(e){null===localStorage.getItem("AuthToken")&&e.push("/login")},U=function(e){Object(p.a)(a,e);var t=Object(d.a)(a);function a(e){var n;return Object(m.a)(this,a),(n=t.call(this,e)).componentWillMount=function(){H(n.props.history);var e=localStorage.getItem("AuthToken");O.a.defaults.headers.common={Authorization:"".concat(e)},O.a.get("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user").then((function(e){console.log(e.data),n.setState({firstName:e.data.userCredentials.firstName,lastName:e.data.userCredentials.lastName,email:e.data.userCredentials.email,phoneNumber:e.data.userCredentials.phoneNumber,country:e.data.userCredentials.country,username:e.data.userCredentials.username,uiLoading:!1})})).catch((function(e){403===e.response.status&&n.props.history.push("/login"),console.log(e),n.setState({errorMsg:"Error in retrieving the data"})}))},n.handleChange=function(e){n.setState(Object(c.a)({},e.target.name,e.target.value))},n.handleImageChange=function(e){n.setState({image:e.target.files[0]})},n.profilePictureHandler=function(e){e.preventDefault(),n.setState({uiLoading:!0}),H(n.props.history);var t=localStorage.getItem("AuthToken"),a=new FormData;a.append("image",n.state.image),a.append("content",n.state.content),O.a.defaults.headers.common={Authorization:"".concat(t)},O.a.post("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user/image",a,{headers:{"content-type":"multipart/form-data"}}).then((function(){window.location.reload()})).catch((function(e){403===e.response.status&&n.props.history.push("/login"),console.log(e),n.setState({uiLoading:!1,imageError:"Error in posting the data"})}))},n.updateFormValues=function(e){e.preventDefault(),n.setState({buttonLoading:!0}),H(n.props.history);var t=localStorage.getItem("AuthToken");O.a.defaults.headers.common={Authorization:"".concat(t)};var a={firstName:n.state.firstName,lastName:n.state.lastName,country:n.state.country};O.a.post("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user",a).then((function(){n.setState({buttonLoading:!1})})).catch((function(e){403===e.response.status&&n.props.history.push("/login"),console.log(e),n.setState({buttonLoading:!1})}))},n.state={firstName:"",lastName:"",email:"",phoneNumber:"",username:"",country:"",profilePicture:"",uiLoading:!0,buttonLoading:!1,imageError:""},n}return Object(u.a)(a,[{key:"render",value:function(){var e=this.props,t=e.classes,a=Object(L.a)(e,["classes"]);return!0===this.state.uiLoading?o.a.createElement("main",{className:t.content},o.a.createElement("div",{className:t.toolbar}),this.state.uiLoading&&o.a.createElement(T.a,{size:150,className:t.uiProgess})):o.a.createElement("main",{className:t.content},o.a.createElement("div",{className:t.toolbar}),o.a.createElement(B.a,Object.assign({},a,{className:Object(F.a)(t.root,t)}),o.a.createElement(D.a,null,o.a.createElement("div",{className:t.details},o.a.createElement("div",null,o.a.createElement(C.a,{className:t.locationText,gutterBottom:!0,variant:"h4"},this.state.firstName," ",this.state.lastName),o.a.createElement(g.a,{variant:"outlined",color:"primary",type:"submit",size:"small",startIcon:o.a.createElement(z.a,null),className:t.uploadButton,onClick:this.profilePictureHandler},"Upload Photo"),o.a.createElement("input",{type:"file",onChange:this.handleImageChange}),!!this.state.imageError&&o.a.createElement("div",{className:t.customError}," ","Wrong Image Format || Supported Format are PNG and JPG"))),o.a.createElement("div",{className:t.progress})),o.a.createElement(q.a,null)),o.a.createElement("br",null),o.a.createElement(B.a,Object.assign({},a,{className:Object(F.a)(t.root,t)}),o.a.createElement("form",{autoComplete:"off",noValidate:!0},o.a.createElement(q.a,null),o.a.createElement(D.a,null,o.a.createElement(v.a,{container:!0,spacing:3},o.a.createElement(v.a,{item:!0,md:6,xs:12},o.a.createElement(b.a,{fullWidth:!0,label:"First name",margin:"dense",name:"firstName",variant:"outlined",value:this.state.firstName,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,md:6,xs:12},o.a.createElement(b.a,{fullWidth:!0,label:"Last name",margin:"dense",name:"lastName",variant:"outlined",value:this.state.lastName,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,md:6,xs:12},o.a.createElement(b.a,{fullWidth:!0,label:"Email",margin:"dense",name:"email",variant:"outlined",disabled:!0,value:this.state.email,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,md:6,xs:12},o.a.createElement(b.a,{fullWidth:!0,label:"Phone Number",margin:"dense",name:"phone",type:"number",variant:"outlined",disabled:!0,value:this.state.phoneNumber,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,md:6,xs:12},o.a.createElement(b.a,{fullWidth:!0,label:"User Name",margin:"dense",name:"userHandle",disabled:!0,variant:"outlined",value:this.state.username,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,md:6,xs:12},o.a.createElement(b.a,{fullWidth:!0,label:"Country",margin:"dense",name:"country",variant:"outlined",value:this.state.country,onChange:this.handleChange})))),o.a.createElement(q.a,null),o.a.createElement(V.a,null))),o.a.createElement(g.a,{color:"primary",variant:"contained",type:"submit",className:t.submitButton,onClick:this.updateFormValues,disabled:this.state.buttonLoading||!this.state.firstName||!this.state.lastName||!this.state.country},"Save details",this.state.buttonLoading&&o.a.createElement(T.a,{size:30,className:t.progess})))}}]),a}(n.Component),M=x()((function(e){return{content:{flexGrow:1,padding:e.spacing(3)},toolbar:e.mixins.toolbar,root:{},details:{display:"flex"},avatar:{height:110,width:100,flexShrink:0,flexGrow:0},locationText:{paddingLeft:"15px"},buttonProperty:{position:"absolute",top:"50%"},uiProgess:{position:"fixed",zIndex:"1000",height:"31px",width:"31px",left:"50%",top:"35%"},progess:{position:"absolute"},uploadButton:{marginLeft:"8px",margin:e.spacing(1)},customError:{color:"red",fontSize:"0.8rem",marginTop:10},submitButton:{marginTop:"10px"}}}))(U),G=a(49),R=a(240),J=a(122),$=a.n(J),K=a(241),Q=a(242),X=a(238),Y=a(86),Z=a.n(Y),_=a(195),ee=a(237),te=a(239),ae=a(85),ne=a.n(ae),oe=a(121),re=a.n(oe),le=function(e){var t;return t={content:{flexGrow:1,padding:e.spacing(3)},toolbar:e.mixins.toolbar,title:{marginLeft:e.spacing(2),flex:1},submitButton:{display:"block",color:"white",textAlign:"center",position:"absolute",top:14,right:10},floatingButton:{position:"fixed",bottom:0,right:0},form:{width:"98%",marginLeft:13,marginTop:"130px"}},Object(c.a)(t,"toolbar",e.mixins.toolbar),Object(c.a)(t,"root",{minWidth:470}),Object(c.a)(t,"bullet",{display:"inline-block",margin:"0 2px",transform:"scale(0.8)"}),Object(c.a)(t,"pos",{marginBottom:12}),Object(c.a)(t,"uiProgess",{position:"fixed",zIndex:"1000",height:"31px",width:"31px",left:"50%",top:"35%"}),Object(c.a)(t,"dialogeStyle",{maxWidth:"50%"}),Object(c.a)(t,"viewRoot",{margin:0,padding:e.spacing(2)}),Object(c.a)(t,"closeButton",{position:"absolute",right:e.spacing(1),top:e.spacing(1),color:e.palette.grey[500]}),t},ie=o.a.forwardRef((function(e,t){return o.a.createElement(_.a,Object.assign({direction:"up",ref:t},e))})),se=function(e){Object(p.a)(a,e);var t=Object(d.a)(a);function a(e){var n;return Object(m.a)(this,a),(n=t.call(this,e)).handleChange=function(e){n.setState(Object(c.a)({},e.target.name,e.target.value))},n.componentWillMount=function(){H(n.props.history);var e=localStorage.getItem("AuthToken");O.a.defaults.headers.common={Authorization:"".concat(e)},O.a.get("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todos").then((function(e){n.setState({todos:e.data,uiLoading:!1})})).catch((function(e){console.log(e)}))},n.state={todos:"",title:"",body:"",todoId:"",errors:[],open:!1,uiLoading:!0,buttonType:"",viewOpen:!1},n.deleteTodoHandler=n.deleteTodoHandler.bind(Object(G.a)(n)),n.handleEditClickOpen=n.handleEditClickOpen.bind(Object(G.a)(n)),n.handleViewOpen=n.handleViewOpen.bind(Object(G.a)(n)),n}return Object(u.a)(a,[{key:"deleteTodoHandler",value:function(e){H(this.props.history);var t=localStorage.getItem("AuthToken");O.a.defaults.headers.common={Authorization:"".concat(t)};var a=e.todo.todoId;O.a.delete("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo/".concat(a)).then((function(){window.location.reload()})).catch((function(e){console.log(e)}))}},{key:"handleEditClickOpen",value:function(e){this.setState({title:e.todo.title,body:e.todo.body,todoId:e.todo.todoId,buttonType:"Edit",open:!0})}},{key:"handleViewOpen",value:function(e){this.setState({title:e.todo.title,body:e.todo.body,viewOpen:!0})}},{key:"render",value:function(){var e=this,t=x()(le)((function(e){var t=e.children,a=e.classes,n=e.onClose,r=Object(L.a)(e,["children","classes","onClose"]);return o.a.createElement(ee.a,Object.assign({disableTypography:!0,className:a.root},r),o.a.createElement(C.a,{variant:"h6"},t),n?o.a.createElement(X.a,{"aria-label":"close",className:a.closeButton,onClick:n},o.a.createElement(Z.a,null)):null)})),a=x()((function(e){return{viewRoot:{padding:e.spacing(2)}}}))(te.a);ne.a.extend(re.a);var n=this.props.classes,r=this.state,l=r.open,i=r.errors,s=r.viewOpen,c=function(){e.setState({viewOpen:!1})},m=function(t){e.setState({open:!1})};return!0===this.state.uiLoading?o.a.createElement("main",{className:n.content},o.a.createElement("div",{className:n.toolbar}),this.state.uiLoading&&o.a.createElement(T.a,{size:150,className:n.uiProgess})):o.a.createElement("main",{className:n.content},o.a.createElement("div",{className:n.toolbar}),o.a.createElement(X.a,{className:n.floatingButton,color:"primary","aria-label":"Add Todo",onClick:function(){e.setState({todoId:"",title:"",body:"",buttonType:"",open:!0})}},o.a.createElement($.a,{style:{fontSize:60}})),o.a.createElement(R.a,{fullScreen:!0,open:l,onClose:m,TransitionComponent:ie},o.a.createElement(K.a,{className:n.appBar},o.a.createElement(Q.a,null,o.a.createElement(X.a,{edge:"start",color:"inherit",onClick:m,"aria-label":"close"},o.a.createElement(Z.a,null)),o.a.createElement(C.a,{variant:"h6",className:n.title},"Edit"===this.state.buttonType?"Edit Todo":"Create a new Todo"),o.a.createElement(g.a,{autoFocus:!0,color:"inherit",onClick:function(t){H(e.props.history),t.preventDefault();var a={title:e.state.title,body:e.state.body},n={};n="Edit"===e.state.buttonType?{url:"https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo/".concat(e.state.todoId),method:"put",data:a}:{url:"https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo",method:"post",data:a};var o=localStorage.getItem("AuthToken");O.a.defaults.headers.common={Authorization:"".concat(o)},O()(n).then((function(){e.setState({open:!1}),window.location.reload()})).catch((function(t){e.setState({open:!0,errors:t.response.data}),console.log(t)}))},className:n.submitButton},"Edit"===this.state.buttonType?"Save":"Submit"))),o.a.createElement("form",{className:n.form,noValidate:!0},o.a.createElement(v.a,{container:!0,spacing:2},o.a.createElement(v.a,{item:!0,xs:12},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"todoTitle",label:"Todo Title",name:"title",autoComplete:"todoTitle",helperText:i.title,value:this.state.title,error:!!i.title,onChange:this.handleChange})),o.a.createElement(v.a,{item:!0,xs:12},o.a.createElement(b.a,{variant:"outlined",required:!0,fullWidth:!0,id:"todoDetails",label:"Todo Details",name:"body",autoComplete:"todoDetails",multiline:!0,rows:25,rowsMax:25,helperText:i.body,error:!!i.body,onChange:this.handleChange,value:this.state.body}))))),o.a.createElement(v.a,{container:!0,spacing:2},this.state.todos.map((function(t){return o.a.createElement(v.a,{item:!0,xs:12,sm:6},o.a.createElement(B.a,{className:n.root,variant:"outlined"},o.a.createElement(D.a,null,o.a.createElement(C.a,{variant:"h5",component:"h2"},t.title),o.a.createElement(C.a,{className:n.pos,color:"textSecondary"},ne()(t.createdAt).fromNow()),o.a.createElement(C.a,{variant:"body2",component:"p"},"".concat(t.body.substring(0,65)))),o.a.createElement(V.a,null,o.a.createElement(g.a,{size:"small",color:"primary",onClick:function(){return e.handleViewOpen({todo:t})}}," ","View"," "),o.a.createElement(g.a,{size:"small",color:"primary",onClick:function(){return e.handleEditClickOpen({todo:t})}},"Edit"),o.a.createElement(g.a,{size:"small",color:"primary",onClick:function(){return e.deleteTodoHandler({todo:t})}},"Delete"))))}))),o.a.createElement(R.a,{onClose:c,"aria-labelledby":"customized-dialog-title",open:s,fullWidth:!0,classes:{paperFullWidth:n.dialogeStyle}},o.a.createElement(t,{id:"customized-dialog-title",onClose:c},this.state.title),o.a.createElement(a,{dividers:!0},o.a.createElement(b.a,{fullWidth:!0,id:"todoDetails",name:"body",multiline:!0,readonly:!0,rows:1,rowsMax:25,value:this.state.body,InputProps:{disableUnderline:!0}}))))}}]),a}(n.Component),ce=x()(le)(se),me=a(243),ue=a(227),de=a(244),pe=a(245),he=a(246),ge=a(124),fe=a.n(ge),be=a(123),Ee=a.n(be),ve=a(125),ye=a.n(ve),Ne=function(e){Object(p.a)(a,e);var t=Object(d.a)(a);function a(e){var n;return Object(m.a)(this,a),(n=t.call(this,e)).state={render:!1},n.loadAccountPage=function(e){n.setState({render:!0})},n.loadTodoPage=function(e){n.setState({render:!1})},n.logoutHandler=function(e){localStorage.removeItem("AuthToken"),n.props.history.push("/login")},n.componentWillMount=function(){H(n.props.history);var e=localStorage.getItem("AuthToken");O.a.defaults.headers.common={Authorization:"".concat(e)},O.a.get("https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user").then((function(e){console.log(e.data),n.setState({firstName:e.data.userCredentials.firstName,lastName:e.data.userCredentials.lastName,email:e.data.userCredentials.email,phoneNumber:e.data.userCredentials.phoneNumber,country:e.data.userCredentials.country,username:e.data.userCredentials.username,uiLoading:!1,profilePicture:e.data.userCredentials.imageUrl})})).catch((function(e){403===e.response.status&&n.props.history.push("/login"),console.log(e),n.setState({errorMsg:"Error in retrieving the data"})}))},n.state={firstName:"",lastName:"",profilePicture:"",uiLoading:!0,imageLoading:!1},n}return Object(u.a)(a,[{key:"render",value:function(){var e=this.props.classes;return!0===this.state.uiLoading?o.a.createElement("div",{className:e.root},this.state.uiLoading&&o.a.createElement(T.a,{size:150,className:e.uiProgess})):o.a.createElement("div",{className:e.root},o.a.createElement(f.a,null),o.a.createElement(K.a,{position:"fixed",className:e.appBar},o.a.createElement(Q.a,null,o.a.createElement(C.a,{variant:"h6",noWrap:!0},"TodoApp"))),o.a.createElement(me.a,{className:e.drawer,variant:"permanent",classes:{paper:e.drawerPaper}},o.a.createElement("div",{className:e.toolbar}),o.a.createElement(q.a,null),o.a.createElement("center",null,o.a.createElement(h.a,{src:this.state.profilePicture,className:e.avatar}),o.a.createElement("p",null," ",this.state.firstName," ",this.state.lastName)),o.a.createElement(q.a,null),o.a.createElement(ue.a,null,o.a.createElement(de.a,{button:!0,key:"Todo",onClick:this.loadTodoPage},o.a.createElement(pe.a,null," ",o.a.createElement(Ee.a,null)," "),o.a.createElement(he.a,{primary:"Todo"})),o.a.createElement(de.a,{button:!0,key:"Account",onClick:this.loadAccountPage},o.a.createElement(pe.a,null," ",o.a.createElement(fe.a,null)," "),o.a.createElement(he.a,{primary:"Account"})),o.a.createElement(de.a,{button:!0,key:"Logout",onClick:this.logoutHandler},o.a.createElement(pe.a,null," ",o.a.createElement(ye.a,null)," "),o.a.createElement(he.a,{primary:"Logout"})))),o.a.createElement("div",null,this.state.render?o.a.createElement(M,null):o.a.createElement(ce,null)))}}]),a}(n.Component),Ce=x()((function(e){return{root:{display:"flex"},appBar:{zIndex:e.zIndex.drawer+1},drawer:{width:240,flexShrink:0},drawerPaper:{width:240},content:{flexGrow:1,padding:e.spacing(3)},avatar:{height:110,width:100,flexShrink:0,flexGrow:0,marginTop:20},uiProgess:{position:"fixed",zIndex:"1000",height:"31px",width:"31px",left:"50%",top:"35%"},toolbar:e.mixins.toolbar}}))(Ne),we=(a(188),a(232)),xe=a(84),Se=a.n(xe)()({palette:{primary:{light:"#8e99f3",main:"#3f51b5",dark:"#26418f",contrastText:"#fff"}}});var Te=function(){return o.a.createElement(we.a,{theme:Se},o.a.createElement(i.a,null,o.a.createElement("div",null,o.a.createElement(s.c,null,o.a.createElement(s.a,{exact:!0,path:"/login",component:W}),o.a.createElement(s.a,{exact:!0,path:"/signup",component:I}),o.a.createElement(s.a,{exact:!0,path:"/",component:Ce})))))};Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));l.a.render(o.a.createElement(o.a.StrictMode,null,o.a.createElement(Te,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[143,1,2]]]); 2 | //# sourceMappingURL=main.36c2a1b6.chunk.js.map -------------------------------------------------------------------------------- /build/static/js/main.36c2a1b6.chunk.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["pages/login.js","pages/signup.js","util/auth.js","components/account.js","components/todo.js","pages/home.js","App.js","serviceWorker.js","index.js"],"names":["login","props","handleChange","event","setState","target","name","value","handleSubmit","preventDefault","loading","userData","email","state","password","axios","post","then","response","localStorage","setItem","data","token","history","push","catch","error","errors","classes","this","Container","component","maxWidth","CssBaseline","className","paper","Avatar","avatar","Typography","variant","form","noValidate","TextField","margin","required","fullWidth","id","label","autoComplete","autoFocus","helperText","onChange","type","Button","color","submit","onClick","disabled","CircularProgress","size","progess","Grid","container","item","Link","href","general","customError","Component","withStyles","theme","marginTop","spacing","display","flexDirection","alignItems","backgroundColor","palette","secondary","main","width","fontSize","position","signup","newUserData","firstName","lastName","phoneNumber","country","username","confirmPassword","nextProps","UI","xs","sm","pattern","justify","authMiddleWare","getItem","account","componentWillMount","authToken","defaults","headers","common","Authorization","get","console","log","userCredentials","uiLoading","status","errorMsg","handleImageChange","image","files","profilePictureHandler","form_data","FormData","append","content","window","location","reload","imageError","updateFormValues","buttonLoading","formRequest","profilePicture","rest","toolbar","uiProgess","Card","clsx","root","CardContent","details","locationText","gutterBottom","startIcon","uploadButton","progress","Divider","md","CardActions","submitButton","flexGrow","padding","mixins","height","flexShrink","paddingLeft","buttonProperty","top","zIndex","left","marginLeft","styles","title","flex","textAlign","right","floatingButton","bottom","minWidth","transform","marginBottom","grey","Transition","React","forwardRef","ref","Slide","direction","todo","todos","err","body","todoId","open","buttonType","viewOpen","deleteTodoHandler","bind","handleEditClickOpen","handleViewOpen","delete","DialogTitle","children","onClose","other","disableTypography","IconButton","aria-label","closeButton","DialogContent","viewRoot","MuiDialogContent","dayjs","extend","relativeTime","handleViewClose","handleClose","style","Dialog","fullScreen","TransitionComponent","AppBar","appBar","Toolbar","edge","userTodo","options","url","method","multiline","rows","rowsMax","map","pos","createdAt","fromNow","substring","aria-labelledby","paperFullWidth","dialogeStyle","dividers","readonly","InputProps","disableUnderline","home","render","loadAccountPage","loadTodoPage","logoutHandler","removeItem","imageUrl","imageLoading","noWrap","Drawer","drawer","drawerPaper","src","List","ListItem","button","key","ListItemIcon","ListItemText","primary","createMuiTheme","light","dark","contrastText","App","exact","path","Boolean","hostname","match","ReactDOM","StrictMode","document","getElementById","navigator","serviceWorker","ready","registration","unregister","message"],"mappings":"iYA2CMA,E,kDACL,WAAYC,GAAQ,IAAD,8BAClB,cAAMA,IAkBPC,aAAe,SAACC,GACf,EAAKC,SAAL,eACED,EAAME,OAAOC,KAAOH,EAAME,OAAOE,SArBjB,EAyBnBC,aAAe,SAACL,GACfA,EAAMM,iBACN,EAAKL,SAAS,CAAEM,SAAS,IACzB,IAAMC,EAAW,CAChBC,MAAO,EAAKC,MAAMD,MAClBE,SAAU,EAAKD,MAAMC,UAEtBC,IACEC,KAAK,mEAAoEL,GACzEM,MAAK,SAACC,GACNC,aAAaC,QAAQ,YAArB,iBAA4CF,EAASG,KAAKC,QAC1D,EAAKlB,SAAS,CACbM,SAAS,IAEV,EAAKT,MAAMsB,QAAQC,KAAK,QAExBC,OAAM,SAACC,GACP,EAAKtB,SAAS,CACbuB,OAAQD,EAAMR,SAASG,KACvBX,SAAS,QAzCZ,EAAKG,MAAQ,CACZD,MAAO,GACPE,SAAU,GACVa,OAAQ,GACRjB,SAAS,GAPQ,E,qDAiDT,IACDkB,EAAYC,KAAK5B,MAAjB2B,QADA,EAEoBC,KAAKhB,MAAzBc,EAFA,EAEAA,OAAQjB,EAFR,EAEQA,QAChB,OACC,kBAACoB,EAAA,EAAD,CAAWC,UAAU,OAAOC,SAAS,MACpC,kBAACC,EAAA,EAAD,MACA,y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YAAa,CACZjK,MAfkB,KAiBnBwC,QAAS,CACR0B,SAAU,EACVC,QAAS7E,EAAME,QAAQ,IAExBnC,OAAQ,CACPgH,OAAQ,IACRrE,MAAO,IACPsE,WAAY,EACZJ,SAAU,EACV3E,UAAW,IAEZ4D,UAAW,CACVjD,SAAU,QACVwE,OAAQ,OACRL,OAAQ,OACRrE,MAAO,OACP2E,KAAM,MACNF,IAAK,OAENvB,QAAS5D,EAAM8E,OAAOlB,WAoIR7D,CAAmBiK,I,4BC1L5BhK,G,OAAQoL,GAAe,CAC5B7K,QAAS,CACR4K,QAAS,CACRE,MAAO,UACP5K,KAAM,UACN6K,KAAM,UACNC,aAAc,WAsBFC,OAhBf,WACE,OACE,kBAAC,KAAD,CAAkBxL,MAAOA,IACzB,kBAAC,IAAD,KACE,6BACE,kBAAC,IAAD,KACE,kBAAC,IAAD,CAAOyL,OAAK,EAACC,KAAK,SAASjO,UAAW/B,IACtC,kBAAC,IAAD,CAAO+P,OAAK,EAACC,KAAK,UAAUjO,UAAWoD,IACvC,kBAAC,IAAD,CAAO4K,OAAK,EAACC,KAAK,IAAIjO,UAAWuM,UClBvB2B,QACW,cAA7BxI,OAAOC,SAASwI,UAEe,UAA7BzI,OAAOC,SAASwI,UAEhBzI,OAAOC,SAASwI,SAASC,MACvB,2DCbNC,IAAS7B,OACP,kBAAC,IAAM8B,WAAP,KACE,kBAAC,GAAD,OAEFC,SAASC,eAAe,SD0HpB,kBAAmBC,WACrBA,UAAUC,cAAcC,MACrBzP,MAAK,SAAA0P,GACJA,EAAaC,gBAEdnP,OAAM,SAAAC,GACLiF,QAAQjF,MAAMA,EAAMmP,c","file":"static/js/main.36c2a1b6.chunk.js","sourcesContent":["import React, { Component } from 'react';\r\nimport Avatar from '@material-ui/core/Avatar';\r\nimport Button from '@material-ui/core/Button';\r\nimport CssBaseline from '@material-ui/core/CssBaseline';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Link from '@material-ui/core/Link';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport LockOutlinedIcon from '@material-ui/icons/LockOutlined';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport withStyles from '@material-ui/core/styles/withStyles';\r\nimport Container from '@material-ui/core/Container';\r\nimport CircularProgress from '@material-ui/core/CircularProgress';\r\n\r\nimport axios from 'axios';\r\n\r\nconst styles = (theme) => ({\r\n\tpaper: {\r\n\t\tmarginTop: theme.spacing(8),\r\n\t\tdisplay: 'flex',\r\n\t\tflexDirection: 'column',\r\n\t\talignItems: 'center'\r\n\t},\r\n\tavatar: {\r\n\t\tmargin: theme.spacing(1),\r\n\t\tbackgroundColor: theme.palette.secondary.main\r\n\t},\r\n\tform: {\r\n\t\twidth: '100%',\r\n\t\tmarginTop: theme.spacing(1)\r\n\t},\r\n\tsubmit: {\r\n\t\tmargin: theme.spacing(3, 0, 2)\r\n\t},\r\n\tcustomError: {\r\n\t\tcolor: 'red',\r\n\t\tfontSize: '0.8rem',\r\n\t\tmarginTop: 10\r\n\t},\r\n\tprogess: {\r\n\t\tposition: 'absolute'\r\n\t}\r\n});\r\n\r\nclass login extends Component {\r\n\tconstructor(props) {\r\n\t\tsuper(props);\r\n\r\n\t\tthis.state = {\r\n\t\t\temail: '',\r\n\t\t\tpassword: '',\r\n\t\t\terrors: [],\r\n\t\t\tloading: false\r\n\t\t};\r\n\t}\r\n\r\n\t/*componentWillReceiveProps(nextProps) {\r\n\t\tif (nextProps.UI.errors) {\r\n\t\t\tthis.setState({\r\n\t\t\t\terrors: nextProps.UI.errors\r\n\t\t\t});\r\n\t\t}\r\n\t} */\r\n\r\n\thandleChange = (event) => {\r\n\t\tthis.setState({\r\n\t\t\t[event.target.name]: event.target.value\r\n\t\t});\r\n\t};\r\n\r\n\thandleSubmit = (event) => {\r\n\t\tevent.preventDefault();\r\n\t\tthis.setState({ loading: true });\r\n\t\tconst userData = {\r\n\t\t\temail: this.state.email,\r\n\t\t\tpassword: this.state.password\r\n\t\t};\r\n\t\taxios\r\n\t\t\t.post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/login', userData)\r\n\t\t\t.then((response) => {\r\n\t\t\t\tlocalStorage.setItem('AuthToken', `Bearer ${response.data.token}`);\r\n\t\t\t\tthis.setState({ \r\n\t\t\t\t\tloading: false,\r\n\t\t\t\t});\t\t\r\n\t\t\t\tthis.props.history.push('/');\r\n\t\t\t})\r\n\t\t\t.catch((error) => {\t\t\t\t\r\n\t\t\t\tthis.setState({\r\n\t\t\t\t\terrors: error.response.data,\r\n\t\t\t\t\tloading: false\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t};\r\n\r\n\trender() {\r\n\t\tconst { classes } = this.props;\r\n\t\tconst { errors, loading } = this.state;\r\n\t\treturn (\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tLogin\r\n\t\t\t\t\t\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tSign In\r\n\t\t\t\t\t\t\t{loading && }\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t{\"Don't have an account? Sign Up\"}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t{errors.general && (\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t{errors.general}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t)}\r\n\t\t\t\t\t\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t);\r\n\t}\r\n}\r\n\r\nexport default withStyles(styles)(login);","import React, { Component } from 'react';\r\nimport Avatar from '@material-ui/core/Avatar';\r\nimport Button from '@material-ui/core/Button';\r\nimport CssBaseline from '@material-ui/core/CssBaseline';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Link from '@material-ui/core/Link';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport LockOutlinedIcon from '@material-ui/icons/LockOutlined';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport Container from '@material-ui/core/Container';\r\nimport withStyles from '@material-ui/core/styles/withStyles';\r\nimport CircularProgress from '@material-ui/core/CircularProgress';\r\n\r\nimport axios from 'axios';\r\n\r\nconst styles = (theme) => ({\r\n\tpaper: {\r\n\t\tmarginTop: theme.spacing(8),\r\n\t\tdisplay: 'flex',\r\n\t\tflexDirection: 'column',\r\n\t\talignItems: 'center'\r\n\t},\r\n\tavatar: {\r\n\t\tmargin: theme.spacing(1),\r\n\t\tbackgroundColor: theme.palette.secondary.main\r\n\t},\r\n\tform: {\r\n\t\twidth: '100%', // Fix IE 11 issue.\r\n\t\tmarginTop: theme.spacing(3)\r\n\t},\r\n\tsubmit: {\r\n\t\tmargin: theme.spacing(3, 0, 2)\r\n\t},\r\n\tprogess: {\r\n\t\tposition: 'absolute'\r\n\t}\r\n});\r\n\r\n\r\nclass signup extends Component {\r\n\tconstructor(props) {\r\n\t\tsuper(props);\r\n\r\n\t\tthis.state = {\r\n\t\t\tfirstName: '',\r\n\t\t\tlastName: '',\r\n\t\t\tphoneNumber: '',\r\n\t\t\tcountry: '',\r\n\t\t\tusername: '',\r\n\t\t\temail: '',\r\n\t\t\tpassword: '',\r\n\t\t\tconfirmPassword: '',\r\n\t\t\terrors: [],\r\n\t\t\tloading: false\r\n\t\t};\r\n\t}\r\n\r\n\tcomponentWillReceiveProps(nextProps) {\r\n\t\tif (nextProps.UI.errors) {\r\n\t\t\tthis.setState({\r\n\t\t\t\terrors: nextProps.UI.errors\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\thandleChange = (event) => {\r\n\t\tthis.setState({\r\n\t\t\t[event.target.name]: event.target.value\r\n\t\t});\r\n\t};\r\n\r\n\thandleSubmit = (event) => {\r\n\t\tevent.preventDefault();\r\n\t\tthis.setState({ loading: true });\r\n\t\tconst newUserData = {\r\n\t\t\tfirstName: this.state.firstName,\r\n\t\t\tlastName: this.state.lastName,\r\n\t\t\tphoneNumber: this.state.phoneNumber,\r\n\t\t\tcountry: this.state.country,\r\n\t\t\tusername: this.state.username,\r\n\t\t\temail: this.state.email,\r\n\t\t\tpassword: this.state.password,\r\n\t\t\tconfirmPassword: this.state.confirmPassword\r\n\t\t};\r\n\t\taxios\r\n\t\t\t.post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/signup', newUserData)\r\n\t\t\t.then((response) => {\r\n\t\t\t\tlocalStorage.setItem('AuthToken', `${response.data.token}`);\r\n\t\t\t\tthis.setState({ \r\n\t\t\t\t\tloading: false,\r\n\t\t\t\t});\t\r\n\t\t\t\tthis.props.history.push('/');\r\n\t\t\t})\r\n\t\t\t.catch((error) => {\r\n\t\t\t\tthis.setState({\r\n\t\t\t\t\terrors: error.response.data,\r\n\t\t\t\t\tloading: false\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t};\r\n\r\n\trender() {\r\n\t\tconst { classes } = this.props;\r\n\t\tconst { errors, loading } = this.state;\r\n\t\treturn (\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tSign up\r\n\t\t\t\t\t\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tSign Up\r\n\t\t\t\t\t\t\t{loading && }\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\tAlready have an account? Sign in\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t);\r\n\t}\r\n}\r\n\r\n\r\nexport default withStyles(styles)(signup);","export const authMiddleWare = (history) => {\r\n const authToken = localStorage.getItem('AuthToken');\r\n if(authToken === null){\r\n history.push('/login')\r\n }\r\n}","import React, { Component } from 'react';\r\n\r\nimport withStyles from '@material-ui/core/styles/withStyles';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport CircularProgress from '@material-ui/core/CircularProgress';\r\nimport CloudUploadIcon from '@material-ui/icons/CloudUpload';\r\nimport { Card, CardActions, CardContent, Divider, Button, Grid, TextField } from '@material-ui/core';\r\n\r\nimport clsx from 'clsx';\r\n\r\nimport axios from 'axios';\r\nimport { authMiddleWare } from '../util/auth';\r\n\r\n\r\nconst styles = (theme) => ({\r\n\tcontent: {\r\n\t\tflexGrow: 1,\r\n\t\tpadding: theme.spacing(3)\r\n\t},\r\n\ttoolbar: theme.mixins.toolbar,\r\n\troot: {},\r\n\tdetails: {\r\n\t\tdisplay: 'flex'\r\n\t},\r\n\tavatar: {\r\n\t\theight: 110,\r\n\t\twidth: 100,\r\n\t\tflexShrink: 0,\r\n\t\tflexGrow: 0\r\n\t},\r\n\tlocationText: {\r\n\t\tpaddingLeft: '15px'\r\n\t},\r\n\tbuttonProperty: {\r\n\t\tposition: 'absolute',\r\n\t\ttop: '50%'\r\n\t},\r\n\tuiProgess: {\r\n\t\tposition: 'fixed',\r\n\t\tzIndex: '1000',\r\n\t\theight: '31px',\r\n\t\twidth: '31px',\r\n\t\tleft: '50%',\r\n\t\ttop: '35%'\r\n\t},\r\n\tprogess: {\r\n\t\tposition: 'absolute'\r\n\t},\r\n\tuploadButton: {\r\n\t\tmarginLeft: '8px',\r\n\t\tmargin: theme.spacing(1)\r\n\t},\r\n\tcustomError: {\r\n\t\tcolor: 'red',\r\n\t\tfontSize: '0.8rem',\r\n\t\tmarginTop: 10\r\n\t},\r\n\tsubmitButton: {\r\n\t\tmarginTop: '10px'\r\n\t}\r\n});\r\n\r\nclass account extends Component {\r\n\tconstructor(props) {\r\n\t\tsuper(props);\r\n\r\n\t\tthis.state = {\r\n\t\t\tfirstName: '',\r\n\t\t\tlastName: '',\r\n\t\t\temail: '',\r\n\t\t\tphoneNumber: '',\r\n\t\t\tusername: '',\r\n\t\t\tcountry: '',\r\n\t\t\tprofilePicture: '',\r\n\t\t\tuiLoading: true,\r\n\t\t\tbuttonLoading: false,\r\n\t\t\timageError: ''\r\n\t\t};\r\n\t}\r\n\r\n\tcomponentWillMount = () => {\r\n\t\tauthMiddleWare(this.props.history);\r\n\t\tconst authToken = localStorage.getItem('AuthToken');\r\n\t\taxios.defaults.headers.common = { Authorization: `${authToken}` };\r\n\t\taxios\r\n\t\t\t.get('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user')\r\n\t\t\t.then((response) => {\r\n\t\t\t\tconsole.log(response.data);\r\n\t\t\t\tthis.setState({\r\n\t\t\t\t\tfirstName: response.data.userCredentials.firstName,\r\n\t\t\t\t\tlastName: response.data.userCredentials.lastName,\r\n\t\t\t\t\temail: response.data.userCredentials.email,\r\n\t\t\t\t\tphoneNumber: response.data.userCredentials.phoneNumber,\r\n\t\t\t\t\tcountry: response.data.userCredentials.country,\r\n\t\t\t\t\tusername: response.data.userCredentials.username,\r\n\t\t\t\t\tuiLoading: false\r\n\t\t\t\t});\r\n\t\t\t})\r\n\t\t\t.catch((error) => {\r\n\t\t\t\tif (error.response.status === 403) {\r\n\t\t\t\t\tthis.props.history.push('/login');\r\n\t\t\t\t}\r\n\t\t\t\tconsole.log(error);\r\n\t\t\t\tthis.setState({ errorMsg: 'Error in retrieving the data' });\r\n\t\t\t});\r\n\t};\r\n\r\n\thandleChange = (event) => {\r\n\t\tthis.setState({\r\n\t\t\t[event.target.name]: event.target.value\r\n\t\t});\r\n\t};\r\n\r\n\thandleImageChange = (event) => {\r\n\t\tthis.setState({\r\n\t\t\timage: event.target.files[0]\r\n\t\t});\r\n\t};\r\n\r\n\tprofilePictureHandler = (event) => {\r\n\t\tevent.preventDefault();\r\n\t\tthis.setState({\r\n\t\t\tuiLoading: true\r\n\t\t});\r\n\t\tauthMiddleWare(this.props.history);\r\n\t\tconst authToken = localStorage.getItem('AuthToken');\r\n\t\tlet form_data = new FormData();\r\n\t\tform_data.append('image', this.state.image);\r\n\t\tform_data.append('content', this.state.content);\r\n\t\taxios.defaults.headers.common = { Authorization: `${authToken}` };\r\n\t\taxios\r\n\t\t\t.post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user/image', form_data, {\r\n\t\t\t\theaders: {\r\n\t\t\t\t\t'content-type': 'multipart/form-data'\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\t.then(() => {\r\n\t\t\t\twindow.location.reload();\r\n\t\t\t})\r\n\t\t\t.catch((error) => {\r\n\t\t\t\tif (error.response.status === 403) {\r\n\t\t\t\t\tthis.props.history.push('/login');\r\n\t\t\t\t}\r\n\t\t\t\tconsole.log(error);\r\n\t\t\t\tthis.setState({\r\n\t\t\t\t\tuiLoading: false,\r\n\t\t\t\t\timageError: 'Error in posting the data'\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t};\r\n\r\n\tupdateFormValues = (event) => {\r\n\t\tevent.preventDefault();\r\n\t\tthis.setState({ buttonLoading: true });\r\n\t\tauthMiddleWare(this.props.history);\r\n\t\tconst authToken = localStorage.getItem('AuthToken');\r\n\t\taxios.defaults.headers.common = { Authorization: `${authToken}` };\r\n\t\tconst formRequest = {\r\n\t\t\tfirstName: this.state.firstName,\r\n\t\t\tlastName: this.state.lastName,\r\n\t\t\tcountry: this.state.country\r\n\t\t};\r\n\t\taxios\r\n\t\t\t.post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user', formRequest)\r\n\t\t\t.then(() => {\r\n\t\t\t\tthis.setState({ buttonLoading: false });\r\n\t\t\t})\r\n\t\t\t.catch((error) => {\r\n\t\t\t\tif (error.response.status === 403) {\r\n\t\t\t\t\tthis.props.history.push('/login');\r\n\t\t\t\t}\r\n\t\t\t\tconsole.log(error);\r\n\t\t\t\tthis.setState({\r\n\t\t\t\t\tbuttonLoading: false\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t};\r\n\r\n\trender() {\r\n\t\tconst { classes, ...rest } = this.props;\r\n\t\tif (this.state.uiLoading === true) {\r\n\t\t\treturn (\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t{this.state.uiLoading && }\r\n\t\t\t\t
\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\treturn (\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t{this.state.firstName} {this.state.lastName}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tclassName={classes.uploadButton}\r\n\t\t\t\t\t\t\t\t\t\tonClick={this.profilePictureHandler}\r\n\t\t\t\t\t\t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\t\t\t\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tSave details\r\n\t\t\t\t\t\t{this.state.buttonLoading && }\r\n\t\t\t\t\t\r\n\t\t\t\t
\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport default withStyles(styles)(account);","import React, { Component } from 'react'\r\nimport withStyles from '@material-ui/core/styles/withStyles';\r\nimport Typography from '@material-ui/core/Typography';\r\n\r\nimport Button from '@material-ui/core/Button';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport AddCircleIcon from '@material-ui/icons/AddCircle';\r\nimport AppBar from '@material-ui/core/AppBar';\r\nimport Toolbar from '@material-ui/core/Toolbar';\r\nimport IconButton from '@material-ui/core/IconButton';\r\nimport CloseIcon from '@material-ui/icons/Close';\r\nimport Slide from '@material-ui/core/Slide';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Grid from '@material-ui/core/Grid';\r\nimport Card from '@material-ui/core/Card';\r\nimport CardActions from '@material-ui/core/CardActions';\r\nimport CircularProgress from '@material-ui/core/CircularProgress';\r\nimport CardContent from '@material-ui/core/CardContent';\r\nimport MuiDialogTitle from '@material-ui/core/DialogTitle';\r\nimport MuiDialogContent from '@material-ui/core/DialogContent';\r\n\r\nimport axios from 'axios';\r\nimport dayjs from 'dayjs';\r\nimport relativeTime from 'dayjs/plugin/relativeTime';\r\nimport { authMiddleWare } from '../util/auth';\r\n\r\nconst styles = (theme) => ({\r\n\r\n content: {\r\n flexGrow: 1,\r\n padding: theme.spacing(3),\r\n },\r\n toolbar: theme.mixins.toolbar,\r\n\t\r\n\ttitle: {\r\n\t\tmarginLeft: theme.spacing(2),\r\n\t\tflex: 1\r\n\t},\r\n\tsubmitButton: {\r\n\t\tdisplay: 'block',\r\n\t\tcolor: 'white',\r\n\t\ttextAlign: 'center',\r\n\t\tposition: 'absolute',\r\n\t\ttop: 14,\r\n\t\tright: 10\r\n\t},\r\n\tfloatingButton: {\r\n\t\tposition: 'fixed',\r\n\t\tbottom: 0,\r\n\t\tright: 0\r\n\t},\r\n\tform: {\r\n\t\twidth: '98%',\r\n\t\tmarginLeft: 13,\r\n\t\tmarginTop: '130px'\r\n\t},\r\n\ttoolbar: theme.mixins.toolbar,\r\n\troot: {\r\n\t\tminWidth: 470\r\n\t},\r\n\tbullet: {\r\n\t\tdisplay: 'inline-block',\r\n\t\tmargin: '0 2px',\r\n\t\ttransform: 'scale(0.8)'\r\n\t},\r\n\tpos: {\r\n\t\tmarginBottom: 12\r\n\t},\r\n\tuiProgess: {\r\n\t\tposition: 'fixed',\r\n\t\tzIndex: '1000',\r\n\t\theight: '31px',\r\n\t\twidth: '31px',\r\n\t\tleft: '50%',\r\n\t\ttop: '35%'\r\n\t},\r\n\tdialogeStyle: {\r\n\t\tmaxWidth: '50%'\r\n\t},\r\n\tviewRoot: {\r\n\t\tmargin: 0,\r\n\t\tpadding: theme.spacing(2)\r\n\t},\r\n\tcloseButton: {\r\n\t\tposition: 'absolute',\r\n\t\tright: theme.spacing(1),\r\n\t\ttop: theme.spacing(1),\r\n\t\tcolor: theme.palette.grey[500]\r\n\t}\r\n});\r\n\r\nconst Transition = React.forwardRef(function Transition(props, ref) {\r\n\treturn ;\r\n});\r\n\r\nclass todo extends Component {\r\n\tconstructor(props) {\r\n\t\tsuper(props);\r\n\r\n\t\tthis.state = {\r\n\t\t\ttodos: '',\r\n\t\t\ttitle: '',\r\n\t\t\tbody: '',\r\n\t\t\ttodoId: '',\r\n\t\t\terrors: [],\r\n\t\t\topen: false,\r\n\t\t\tuiLoading: true,\r\n\t\t\tbuttonType: '',\r\n\t\t\tviewOpen: false\r\n\t\t};\r\n\r\n\t\tthis.deleteTodoHandler = this.deleteTodoHandler.bind(this);\r\n\t\tthis.handleEditClickOpen = this.handleEditClickOpen.bind(this);\r\n\t\tthis.handleViewOpen = this.handleViewOpen.bind(this);\r\n\t}\r\n\r\n\thandleChange = (event) => {\r\n\t\tthis.setState({\r\n\t\t\t[event.target.name]: event.target.value\r\n\t\t});\r\n\t};\r\n\r\n\tcomponentWillMount = () => {\r\n\t\tauthMiddleWare(this.props.history);\r\n\t\tconst authToken = localStorage.getItem('AuthToken');\r\n\t\taxios.defaults.headers.common = { Authorization: `${authToken}` };\r\n\t\taxios\r\n\t\t\t.get('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todos')\r\n\t\t\t.then((response) => {\r\n\t\t\t\tthis.setState({\r\n\t\t\t\t\ttodos: response.data,\r\n\t\t\t\t\tuiLoading: false\r\n\t\t\t\t});\r\n\t\t\t})\r\n\t\t\t.catch((err) => {\r\n\t\t\t\tconsole.log(err);\r\n\t\t\t});\r\n\t};\r\n\r\n\tdeleteTodoHandler(data) {\r\n\t\tauthMiddleWare(this.props.history);\r\n\t\tconst authToken = localStorage.getItem('AuthToken');\r\n\t\taxios.defaults.headers.common = { Authorization: `${authToken}` };\r\n\t\tlet todoId = data.todo.todoId;\r\n\t\taxios\r\n\t\t\t.delete(`https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo/${todoId}`)\r\n\t\t\t.then(() => {\r\n\t\t\t\twindow.location.reload();\r\n\t\t\t})\r\n\t\t\t.catch((err) => {\r\n\t\t\t\tconsole.log(err);\r\n\t\t\t});\r\n\t}\r\n\r\n\thandleEditClickOpen(data) {\r\n\t\tthis.setState({\r\n\t\t\ttitle: data.todo.title,\r\n\t\t\tbody: data.todo.body,\r\n\t\t\ttodoId: data.todo.todoId,\r\n\t\t\tbuttonType: 'Edit',\r\n\t\t\topen: true\r\n\t\t});\r\n\t}\r\n\r\n\thandleViewOpen(data) {\r\n\t\tthis.setState({\r\n\t\t\ttitle: data.todo.title,\r\n\t\t\tbody: data.todo.body,\r\n\t\t\tviewOpen: true\r\n\t\t});\r\n\t}\r\n\r\n\trender() {\r\n\t\tconst DialogTitle = withStyles(styles)((props) => {\r\n\t\t\tconst { children, classes, onClose, ...other } = props;\r\n\t\t\treturn (\r\n\t\t\t\t\r\n\t\t\t\t\t{children}\r\n\t\t\t\t\t{onClose ? (\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t) : null}\r\n\t\t\t\t\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\tconst DialogContent = withStyles((theme) => ({\r\n\t\t\tviewRoot: {\r\n\t\t\t\tpadding: theme.spacing(2)\r\n\t\t\t}\r\n\t\t}))(MuiDialogContent);\r\n\r\n\t\tdayjs.extend(relativeTime);\r\n\t\tconst { classes } = this.props;\r\n\t\tconst { open, errors, viewOpen } = this.state;\r\n\r\n\t\tconst handleClickOpen = () => {\r\n\t\t\tthis.setState({\r\n\t\t\t\ttodoId: '',\r\n\t\t\t\ttitle: '',\r\n\t\t\t\tbody: '',\r\n\t\t\t\tbuttonType: '',\r\n\t\t\t\topen: true\r\n\t\t\t});\r\n\t\t};\r\n\r\n\t\tconst handleSubmit = (event) => {\r\n\t\t\tauthMiddleWare(this.props.history);\r\n\t\t\tevent.preventDefault();\r\n\t\t\tconst userTodo = {\r\n\t\t\t\ttitle: this.state.title,\r\n\t\t\t\tbody: this.state.body\r\n\t\t\t};\r\n\t\t\tlet options = {};\r\n\t\t\tif (this.state.buttonType === 'Edit') {\r\n\t\t\t\toptions = {\r\n\t\t\t\t\turl: `https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo/${this.state.todoId}`,\r\n\t\t\t\t\tmethod: 'put',\r\n\t\t\t\t\tdata: userTodo\r\n\t\t\t\t};\r\n\t\t\t} else {\r\n\t\t\t\toptions = {\r\n\t\t\t\t\turl: 'https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo',\r\n\t\t\t\t\tmethod: 'post',\r\n\t\t\t\t\tdata: userTodo\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t\tconst authToken = localStorage.getItem('AuthToken');\r\n\t\t\taxios.defaults.headers.common = { Authorization: `${authToken}` };\r\n\t\t\taxios(options)\r\n\t\t\t\t.then(() => {\r\n\t\t\t\t\tthis.setState({ open: false });\r\n\t\t\t\t\twindow.location.reload();\r\n\t\t\t\t})\r\n\t\t\t\t.catch((error) => {\r\n\t\t\t\t\tthis.setState({ open: true, errors: error.response.data });\r\n\t\t\t\t\tconsole.log(error);\r\n\t\t\t\t});\r\n\t\t};\r\n\r\n\t\tconst handleViewClose = () => {\r\n\t\t\tthis.setState({ viewOpen: false });\r\n\t\t};\r\n\r\n\t\tconst handleClose = (event) => {\r\n\t\t\tthis.setState({ open: false });\r\n\t\t};\r\n\r\n\t\tif (this.state.uiLoading === true) {\r\n\t\t\treturn (\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t{this.state.uiLoading && }\r\n\t\t\t\t
\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\treturn (\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t{this.state.buttonType === 'Edit' ? 'Edit Todo' : 'Create a new Todo'}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t{this.state.buttonType === 'Edit' ? 'Save' : 'Submit'}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t{this.state.todos.map((todo) => (\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t{todo.title}\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t{dayjs(todo.createdAt).fromNow()}\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t{`${todo.body.substring(0, 65)}`}\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t))}\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t{this.state.title}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t
\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport default withStyles(styles)(todo);","import React, { Component } from 'react';\r\nimport axios from 'axios';\r\n\r\nimport Account from '../components/account';\r\nimport Todo from '../components/todo';\r\n\r\nimport Drawer from '@material-ui/core/Drawer';\r\nimport AppBar from '@material-ui/core/AppBar';\r\nimport CssBaseline from '@material-ui/core/CssBaseline';\r\nimport Toolbar from '@material-ui/core/Toolbar';\r\nimport List from '@material-ui/core/List';\r\nimport Typography from '@material-ui/core/Typography';\r\nimport Divider from '@material-ui/core/Divider';\r\nimport ListItem from '@material-ui/core/ListItem';\r\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\r\nimport ListItemText from '@material-ui/core/ListItemText';\r\nimport withStyles from '@material-ui/core/styles/withStyles';\r\nimport AccountBoxIcon from '@material-ui/icons/AccountBox';\r\nimport NotesIcon from '@material-ui/icons/Notes';\r\nimport Avatar from '@material-ui/core/avatar';\r\nimport ExitToAppIcon from '@material-ui/icons/ExitToApp';\r\nimport CircularProgress from '@material-ui/core/CircularProgress';\r\n\r\nimport { authMiddleWare } from '../util/auth'\r\n\r\n\r\n//styles \r\n\r\nconst drawerWidth = 240;\r\n\r\n\r\nconst styles = (theme) => ({\r\n\troot: {\r\n\t\tdisplay: 'flex'\r\n\t},\r\n\tappBar: {\r\n\t\tzIndex: theme.zIndex.drawer + 1\r\n\t},\r\n\tdrawer: {\r\n\t\twidth: drawerWidth,\r\n\t\tflexShrink: 0\r\n\t},\r\n\tdrawerPaper: {\r\n\t\twidth: drawerWidth\r\n\t},\r\n\tcontent: {\r\n\t\tflexGrow: 1,\r\n\t\tpadding: theme.spacing(3)\r\n\t},\r\n\tavatar: {\r\n\t\theight: 110,\r\n\t\twidth: 100,\r\n\t\tflexShrink: 0,\r\n\t\tflexGrow: 0,\r\n\t\tmarginTop: 20\r\n\t},\r\n\tuiProgess: {\r\n\t\tposition: 'fixed',\r\n\t\tzIndex: '1000',\r\n\t\theight: '31px',\r\n\t\twidth: '31px',\r\n\t\tleft: '50%',\r\n\t\ttop: '35%'\r\n\t},\r\n\ttoolbar: theme.mixins.toolbar\r\n});\r\n\r\n\r\nclass home extends Component {\r\n\tstate = {\r\n\t\trender: false\r\n\t};\r\n\r\n\tloadAccountPage = (event) => {\r\n\t\tthis.setState({ render: true });\r\n\t};\r\n\r\n\tloadTodoPage = (event) => {\r\n\t\tthis.setState({ render: false });\r\n\t};\r\n\r\n\tlogoutHandler = (event) => {\r\n\t\tlocalStorage.removeItem('AuthToken');\r\n\t\tthis.props.history.push('/login');\r\n\t};\r\n\r\n\tconstructor(props) {\r\n\t\tsuper(props);\r\n\r\n\t\tthis.state = {\r\n\t\t\tfirstName: '',\r\n\t\t\tlastName: '',\r\n\t\t\tprofilePicture: '',\r\n\t\t\tuiLoading: true,\r\n\t\t\timageLoading: false\r\n\t\t};\r\n\t}\r\n\r\n\tcomponentWillMount = () => {\r\n\t\tauthMiddleWare(this.props.history);\r\n\t\tconst authToken = localStorage.getItem('AuthToken');\r\n\t\taxios.defaults.headers.common = { Authorization: `${authToken}` };\r\n\t\taxios\r\n\t\t\t.get('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user')\r\n\t\t\t.then((response) => {\r\n\t\t\t\tconsole.log(response.data);\r\n\t\t\t\tthis.setState({\r\n\t\t\t\t\tfirstName: response.data.userCredentials.firstName,\r\n\t\t\t\t\tlastName: response.data.userCredentials.lastName,\r\n\t\t\t\t\temail: response.data.userCredentials.email,\r\n\t\t\t\t\tphoneNumber: response.data.userCredentials.phoneNumber,\r\n\t\t\t\t\tcountry: response.data.userCredentials.country,\r\n\t\t\t\t\tusername: response.data.userCredentials.username,\r\n\t\t\t\t\tuiLoading: false,\r\n\t\t\t\t\tprofilePicture: response.data.userCredentials.imageUrl\r\n\t\t\t\t});\r\n\t\t\t})\r\n\t\t\t.catch((error) => {\r\n\t\t\t\tif(error.response.status === 403) {\r\n\t\t\t\t\tthis.props.history.push('/login')\r\n\t\t\t\t}\r\n\t\t\t\tconsole.log(error);\r\n\t\t\t\tthis.setState({ errorMsg: 'Error in retrieving the data' });\r\n\t\t\t});\r\n\t};\r\n\r\n\trender() {\r\n\t\tconst { classes } = this.props;\t\t\r\n\t\tif (this.state.uiLoading === true) {\r\n\t\t\treturn (\r\n\t\t\t\t
\r\n\t\t\t\t\t{this.state.uiLoading && }\r\n\t\t\t\t
\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\treturn (\r\n\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tTodoApp\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t

\r\n\t\t\t\t\t\t\t\t{' '}\r\n\t\t\t\t\t\t\t\t{this.state.firstName} {this.state.lastName}\r\n\t\t\t\t\t\t\t

\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t{' '}\r\n\t\t\t\t\t\t\t\t\t{' '}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t{' '}\r\n\t\t\t\t\t\t\t\t\t{' '}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t{' '}\r\n\t\t\t\t\t\t\t\t\t{' '}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t\t
{this.state.render ? : }
\r\n\t\t\t\t
\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport default withStyles(styles)(home);","import React from 'react';\nimport { BrowserRouter as Router, Route, Switch } from 'react-router-dom';\nimport login from './pages/login'\nimport signup from './pages/signup'\nimport home from './pages/home';\nimport './App.css';\n\nimport { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles';\nimport createMuiTheme from '@material-ui/core/styles/createMuiTheme';\n\nconst theme = createMuiTheme({\n\tpalette: {\n\t\tprimary: {\n\t\t\tlight: '#8e99f3',\n\t\t\tmain: '#3f51b5',\n\t\t\tdark: '#26418f',\n\t\t\tcontrastText: '#fff'\n\t\t}\n\t}\n});\n\n\nfunction App() {\n return (\n \n \n
\n \n \n \n \n \n
\n
\n
\n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' },\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""} -------------------------------------------------------------------------------- /build/static/js/runtime-main.ff02b437.js: -------------------------------------------------------------------------------- 1 | !function(e){function r(r){for(var n,i,l=r[0],f=r[1],a=r[2],c=0,s=[];c0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /photos/account.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/photos/account.PNG -------------------------------------------------------------------------------- /photos/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/photos/architecture.png -------------------------------------------------------------------------------- /photos/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/photos/favicon.png -------------------------------------------------------------------------------- /photos/login and dashboard.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/photos/login and dashboard.gif -------------------------------------------------------------------------------- /photos/login.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/photos/login.PNG -------------------------------------------------------------------------------- /photos/signup.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/photos/signup.PNG -------------------------------------------------------------------------------- /photos/tododashboard.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/photos/tododashboard.PNG -------------------------------------------------------------------------------- /public/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 -------------------------------------------------------------------------------- /public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rajesh-Royal/React-Js-Todo-App-with-firebase-auth/cc094802b78f6215768caa7307a922cea1740285/public/favicon.png -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | Todo List App with firebase Authentication 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; 3 | import login from './pages/login' 4 | import signup from './pages/signup' 5 | import home from './pages/home'; 6 | import './App.css'; 7 | 8 | import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles'; 9 | import createMuiTheme from '@material-ui/core/styles/createMuiTheme'; 10 | 11 | const theme = createMuiTheme({ 12 | palette: { 13 | primary: { 14 | light: '#8e99f3', 15 | main: '#3f51b5', 16 | dark: '#26418f', 17 | contrastText: '#fff' 18 | } 19 | } 20 | }); 21 | 22 | 23 | function App() { 24 | return ( 25 | 26 | 27 |
28 | 29 | 30 | 31 | 32 | 33 |
34 |
35 |
36 | ); 37 | } 38 | 39 | export default App; 40 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/components/account.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | import withStyles from '@material-ui/core/styles/withStyles'; 4 | import Typography from '@material-ui/core/Typography'; 5 | import CircularProgress from '@material-ui/core/CircularProgress'; 6 | import CloudUploadIcon from '@material-ui/icons/CloudUpload'; 7 | import { Card, CardActions, CardContent, Divider, Button, Grid, TextField } from '@material-ui/core'; 8 | 9 | import clsx from 'clsx'; 10 | 11 | import axios from 'axios'; 12 | import { authMiddleWare } from '../util/auth'; 13 | 14 | 15 | const styles = (theme) => ({ 16 | content: { 17 | flexGrow: 1, 18 | padding: theme.spacing(3) 19 | }, 20 | toolbar: theme.mixins.toolbar, 21 | root: {}, 22 | details: { 23 | display: 'flex' 24 | }, 25 | avatar: { 26 | height: 110, 27 | width: 100, 28 | flexShrink: 0, 29 | flexGrow: 0 30 | }, 31 | locationText: { 32 | paddingLeft: '15px' 33 | }, 34 | buttonProperty: { 35 | position: 'absolute', 36 | top: '50%' 37 | }, 38 | uiProgess: { 39 | position: 'fixed', 40 | zIndex: '1000', 41 | height: '31px', 42 | width: '31px', 43 | left: '50%', 44 | top: '35%' 45 | }, 46 | progess: { 47 | position: 'absolute' 48 | }, 49 | uploadButton: { 50 | marginLeft: '8px', 51 | margin: theme.spacing(1) 52 | }, 53 | customError: { 54 | color: 'red', 55 | fontSize: '0.8rem', 56 | marginTop: 10 57 | }, 58 | submitButton: { 59 | marginTop: '10px' 60 | } 61 | }); 62 | 63 | class account extends Component { 64 | constructor(props) { 65 | super(props); 66 | 67 | this.state = { 68 | firstName: '', 69 | lastName: '', 70 | email: '', 71 | phoneNumber: '', 72 | username: '', 73 | country: '', 74 | profilePicture: '', 75 | uiLoading: true, 76 | buttonLoading: false, 77 | imageError: '' 78 | }; 79 | } 80 | 81 | componentWillMount = () => { 82 | authMiddleWare(this.props.history); 83 | const authToken = localStorage.getItem('AuthToken'); 84 | axios.defaults.headers.common = { Authorization: `${authToken}` }; 85 | axios 86 | .get('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user') 87 | .then((response) => { 88 | console.log(response.data); 89 | this.setState({ 90 | firstName: response.data.userCredentials.firstName, 91 | lastName: response.data.userCredentials.lastName, 92 | email: response.data.userCredentials.email, 93 | phoneNumber: response.data.userCredentials.phoneNumber, 94 | country: response.data.userCredentials.country, 95 | username: response.data.userCredentials.username, 96 | uiLoading: false 97 | }); 98 | }) 99 | .catch((error) => { 100 | if (error.response.status === 403) { 101 | this.props.history.push('/login'); 102 | } 103 | console.log(error); 104 | this.setState({ errorMsg: 'Error in retrieving the data' }); 105 | }); 106 | }; 107 | 108 | handleChange = (event) => { 109 | this.setState({ 110 | [event.target.name]: event.target.value 111 | }); 112 | }; 113 | 114 | handleImageChange = (event) => { 115 | this.setState({ 116 | image: event.target.files[0] 117 | }); 118 | }; 119 | 120 | profilePictureHandler = (event) => { 121 | event.preventDefault(); 122 | this.setState({ 123 | uiLoading: true 124 | }); 125 | authMiddleWare(this.props.history); 126 | const authToken = localStorage.getItem('AuthToken'); 127 | let form_data = new FormData(); 128 | form_data.append('image', this.state.image); 129 | form_data.append('content', this.state.content); 130 | axios.defaults.headers.common = { Authorization: `${authToken}` }; 131 | axios 132 | .post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user/image', form_data, { 133 | headers: { 134 | 'content-type': 'multipart/form-data' 135 | } 136 | }) 137 | .then(() => { 138 | window.location.reload(); 139 | }) 140 | .catch((error) => { 141 | if (error.response.status === 403) { 142 | this.props.history.push('/login'); 143 | } 144 | console.log(error); 145 | this.setState({ 146 | uiLoading: false, 147 | imageError: 'Error in posting the data' 148 | }); 149 | }); 150 | }; 151 | 152 | updateFormValues = (event) => { 153 | event.preventDefault(); 154 | this.setState({ buttonLoading: true }); 155 | authMiddleWare(this.props.history); 156 | const authToken = localStorage.getItem('AuthToken'); 157 | axios.defaults.headers.common = { Authorization: `${authToken}` }; 158 | const formRequest = { 159 | firstName: this.state.firstName, 160 | lastName: this.state.lastName, 161 | country: this.state.country 162 | }; 163 | axios 164 | .post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user', formRequest) 165 | .then(() => { 166 | this.setState({ buttonLoading: false }); 167 | }) 168 | .catch((error) => { 169 | if (error.response.status === 403) { 170 | this.props.history.push('/login'); 171 | } 172 | console.log(error); 173 | this.setState({ 174 | buttonLoading: false 175 | }); 176 | }); 177 | }; 178 | 179 | render() { 180 | const { classes, ...rest } = this.props; 181 | if (this.state.uiLoading === true) { 182 | return ( 183 |
184 |
185 | {this.state.uiLoading && } 186 |
187 | ); 188 | } else { 189 | return ( 190 |
191 |
192 | 193 | 194 |
195 |
196 | 197 | {this.state.firstName} {this.state.lastName} 198 | 199 | 210 | 211 | 212 | {this.state.imageError ? ( 213 |
214 | {' '} 215 | Wrong Image Format || Supported Format are PNG and JPG 216 |
217 | ) : ( 218 | false 219 | )} 220 |
221 |
222 |
223 | 224 | 225 | 226 | 227 |
228 | 229 |
230 | 231 | 232 | 233 | 234 | 243 | 244 | 245 | 254 | 255 | 256 | 266 | 267 | 268 | 279 | 280 | 281 | 291 | 292 | 293 | 302 | 303 | 304 | 305 | 306 | 307 | 308 |
309 | 325 |
326 | ); 327 | } 328 | } 329 | } 330 | 331 | export default withStyles(styles)(account); -------------------------------------------------------------------------------- /src/components/todo.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import withStyles from '@material-ui/core/styles/withStyles'; 3 | import Typography from '@material-ui/core/Typography'; 4 | 5 | import Button from '@material-ui/core/Button'; 6 | import Dialog from '@material-ui/core/Dialog'; 7 | import AddCircleIcon from '@material-ui/icons/AddCircle'; 8 | import AppBar from '@material-ui/core/AppBar'; 9 | import Toolbar from '@material-ui/core/Toolbar'; 10 | import IconButton from '@material-ui/core/IconButton'; 11 | import CloseIcon from '@material-ui/icons/Close'; 12 | import Slide from '@material-ui/core/Slide'; 13 | import TextField from '@material-ui/core/TextField'; 14 | import Grid from '@material-ui/core/Grid'; 15 | import Card from '@material-ui/core/Card'; 16 | import CardActions from '@material-ui/core/CardActions'; 17 | import CircularProgress from '@material-ui/core/CircularProgress'; 18 | import CardContent from '@material-ui/core/CardContent'; 19 | import MuiDialogTitle from '@material-ui/core/DialogTitle'; 20 | import MuiDialogContent from '@material-ui/core/DialogContent'; 21 | 22 | import axios from 'axios'; 23 | import dayjs from 'dayjs'; 24 | import relativeTime from 'dayjs/plugin/relativeTime'; 25 | import { authMiddleWare } from '../util/auth'; 26 | 27 | const styles = (theme) => ({ 28 | 29 | content: { 30 | flexGrow: 1, 31 | padding: theme.spacing(3), 32 | }, 33 | toolbar: theme.mixins.toolbar, 34 | 35 | title: { 36 | marginLeft: theme.spacing(2), 37 | flex: 1 38 | }, 39 | submitButton: { 40 | display: 'block', 41 | color: 'white', 42 | textAlign: 'center', 43 | position: 'absolute', 44 | top: 14, 45 | right: 10 46 | }, 47 | floatingButton: { 48 | position: 'fixed', 49 | bottom: 0, 50 | right: 0 51 | }, 52 | form: { 53 | width: '98%', 54 | marginLeft: 13, 55 | marginTop: '130px' 56 | }, 57 | toolbar: theme.mixins.toolbar, 58 | root: { 59 | minWidth: 470 60 | }, 61 | bullet: { 62 | display: 'inline-block', 63 | margin: '0 2px', 64 | transform: 'scale(0.8)' 65 | }, 66 | pos: { 67 | marginBottom: 12 68 | }, 69 | uiProgess: { 70 | position: 'fixed', 71 | zIndex: '1000', 72 | height: '31px', 73 | width: '31px', 74 | left: '50%', 75 | top: '35%' 76 | }, 77 | dialogeStyle: { 78 | maxWidth: '50%' 79 | }, 80 | viewRoot: { 81 | margin: 0, 82 | padding: theme.spacing(2) 83 | }, 84 | closeButton: { 85 | position: 'absolute', 86 | right: theme.spacing(1), 87 | top: theme.spacing(1), 88 | color: theme.palette.grey[500] 89 | } 90 | }); 91 | 92 | const Transition = React.forwardRef(function Transition(props, ref) { 93 | return ; 94 | }); 95 | 96 | class todo extends Component { 97 | constructor(props) { 98 | super(props); 99 | 100 | this.state = { 101 | todos: '', 102 | title: '', 103 | body: '', 104 | todoId: '', 105 | errors: [], 106 | open: false, 107 | uiLoading: true, 108 | buttonType: '', 109 | viewOpen: false 110 | }; 111 | 112 | this.deleteTodoHandler = this.deleteTodoHandler.bind(this); 113 | this.handleEditClickOpen = this.handleEditClickOpen.bind(this); 114 | this.handleViewOpen = this.handleViewOpen.bind(this); 115 | } 116 | 117 | handleChange = (event) => { 118 | this.setState({ 119 | [event.target.name]: event.target.value 120 | }); 121 | }; 122 | 123 | componentWillMount = () => { 124 | authMiddleWare(this.props.history); 125 | const authToken = localStorage.getItem('AuthToken'); 126 | axios.defaults.headers.common = { Authorization: `${authToken}` }; 127 | axios 128 | .get('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todos') 129 | .then((response) => { 130 | this.setState({ 131 | todos: response.data, 132 | uiLoading: false 133 | }); 134 | }) 135 | .catch((err) => { 136 | console.log(err); 137 | }); 138 | }; 139 | 140 | deleteTodoHandler(data) { 141 | authMiddleWare(this.props.history); 142 | const authToken = localStorage.getItem('AuthToken'); 143 | axios.defaults.headers.common = { Authorization: `${authToken}` }; 144 | let todoId = data.todo.todoId; 145 | axios 146 | .delete(`https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo/${todoId}`) 147 | .then(() => { 148 | window.location.reload(); 149 | }) 150 | .catch((err) => { 151 | console.log(err); 152 | }); 153 | } 154 | 155 | handleEditClickOpen(data) { 156 | this.setState({ 157 | title: data.todo.title, 158 | body: data.todo.body, 159 | todoId: data.todo.todoId, 160 | buttonType: 'Edit', 161 | open: true 162 | }); 163 | } 164 | 165 | handleViewOpen(data) { 166 | this.setState({ 167 | title: data.todo.title, 168 | body: data.todo.body, 169 | viewOpen: true 170 | }); 171 | } 172 | 173 | render() { 174 | const DialogTitle = withStyles(styles)((props) => { 175 | const { children, classes, onClose, ...other } = props; 176 | return ( 177 | 178 | {children} 179 | {onClose ? ( 180 | 181 | 182 | 183 | ) : null} 184 | 185 | ); 186 | }); 187 | 188 | const DialogContent = withStyles((theme) => ({ 189 | viewRoot: { 190 | padding: theme.spacing(2) 191 | } 192 | }))(MuiDialogContent); 193 | 194 | dayjs.extend(relativeTime); 195 | const { classes } = this.props; 196 | const { open, errors, viewOpen } = this.state; 197 | 198 | const handleClickOpen = () => { 199 | this.setState({ 200 | todoId: '', 201 | title: '', 202 | body: '', 203 | buttonType: '', 204 | open: true 205 | }); 206 | }; 207 | 208 | const handleSubmit = (event) => { 209 | authMiddleWare(this.props.history); 210 | event.preventDefault(); 211 | const userTodo = { 212 | title: this.state.title, 213 | body: this.state.body 214 | }; 215 | let options = {}; 216 | if (this.state.buttonType === 'Edit') { 217 | options = { 218 | url: `https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo/${this.state.todoId}`, 219 | method: 'put', 220 | data: userTodo 221 | }; 222 | } else { 223 | options = { 224 | url: 'https://us-central1-to-do-app-27bee.cloudfunctions.net/api/todo', 225 | method: 'post', 226 | data: userTodo 227 | }; 228 | } 229 | const authToken = localStorage.getItem('AuthToken'); 230 | axios.defaults.headers.common = { Authorization: `${authToken}` }; 231 | axios(options) 232 | .then(() => { 233 | this.setState({ open: false }); 234 | window.location.reload(); 235 | }) 236 | .catch((error) => { 237 | this.setState({ open: true, errors: error.response.data }); 238 | console.log(error); 239 | }); 240 | }; 241 | 242 | const handleViewClose = () => { 243 | this.setState({ viewOpen: false }); 244 | }; 245 | 246 | const handleClose = (event) => { 247 | this.setState({ open: false }); 248 | }; 249 | 250 | if (this.state.uiLoading === true) { 251 | return ( 252 |
253 |
254 | {this.state.uiLoading && } 255 |
256 | ); 257 | } else { 258 | return ( 259 |
260 |
261 | 262 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | {this.state.buttonType === 'Edit' ? 'Edit Todo' : 'Create a new Todo'} 278 | 279 | 287 | 288 | 289 | 290 |
291 | 292 | 293 | 306 | 307 | 308 | 324 | 325 | 326 |
327 |
328 | 329 | 330 | {this.state.todos.map((todo) => ( 331 | 332 | 333 | 334 | 335 | {todo.title} 336 | 337 | 338 | {dayjs(todo.createdAt).fromNow()} 339 | 340 | 341 | {`${todo.body.substring(0, 65)}`} 342 | 343 | 344 | 345 | 349 | 352 | 355 | 356 | 357 | 358 | ))} 359 | 360 | 361 | 368 | 369 | {this.state.title} 370 | 371 | 372 | 385 | 386 | 387 |
388 | ); 389 | } 390 | } 391 | } 392 | 393 | export default withStyles(styles)(todo); -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | import * as serviceWorker from './serviceWorker'; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById('root') 11 | ); 12 | 13 | // If you want your app to work offline and load faster, you can change 14 | // unregister() to register() below. Note this comes with some pitfalls. 15 | // Learn more about service workers: https://bit.ly/CRA-PWA 16 | serviceWorker.unregister(); 17 | -------------------------------------------------------------------------------- /src/pages/home.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import axios from 'axios'; 3 | 4 | import Account from '../components/account'; 5 | import Todo from '../components/todo'; 6 | 7 | import Drawer from '@material-ui/core/Drawer'; 8 | import AppBar from '@material-ui/core/AppBar'; 9 | import CssBaseline from '@material-ui/core/CssBaseline'; 10 | import Toolbar from '@material-ui/core/Toolbar'; 11 | import List from '@material-ui/core/List'; 12 | import Typography from '@material-ui/core/Typography'; 13 | import Divider from '@material-ui/core/Divider'; 14 | import ListItem from '@material-ui/core/ListItem'; 15 | import ListItemIcon from '@material-ui/core/ListItemIcon'; 16 | import ListItemText from '@material-ui/core/ListItemText'; 17 | import withStyles from '@material-ui/core/styles/withStyles'; 18 | import AccountBoxIcon from '@material-ui/icons/AccountBox'; 19 | import NotesIcon from '@material-ui/icons/Notes'; 20 | import Avatar from '@material-ui/core/avatar'; 21 | import ExitToAppIcon from '@material-ui/icons/ExitToApp'; 22 | import CircularProgress from '@material-ui/core/CircularProgress'; 23 | 24 | import { authMiddleWare } from '../util/auth' 25 | 26 | 27 | //styles 28 | 29 | const drawerWidth = 240; 30 | 31 | 32 | const styles = (theme) => ({ 33 | root: { 34 | display: 'flex' 35 | }, 36 | appBar: { 37 | zIndex: theme.zIndex.drawer + 1 38 | }, 39 | drawer: { 40 | width: drawerWidth, 41 | flexShrink: 0 42 | }, 43 | drawerPaper: { 44 | width: drawerWidth 45 | }, 46 | content: { 47 | flexGrow: 1, 48 | padding: theme.spacing(3) 49 | }, 50 | avatar: { 51 | height: 110, 52 | width: 100, 53 | flexShrink: 0, 54 | flexGrow: 0, 55 | marginTop: 20 56 | }, 57 | uiProgess: { 58 | position: 'fixed', 59 | zIndex: '1000', 60 | height: '31px', 61 | width: '31px', 62 | left: '50%', 63 | top: '35%' 64 | }, 65 | toolbar: theme.mixins.toolbar 66 | }); 67 | 68 | 69 | class home extends Component { 70 | state = { 71 | render: false 72 | }; 73 | 74 | loadAccountPage = (event) => { 75 | this.setState({ render: true }); 76 | }; 77 | 78 | loadTodoPage = (event) => { 79 | this.setState({ render: false }); 80 | }; 81 | 82 | logoutHandler = (event) => { 83 | localStorage.removeItem('AuthToken'); 84 | this.props.history.push('/login'); 85 | }; 86 | 87 | constructor(props) { 88 | super(props); 89 | 90 | this.state = { 91 | firstName: '', 92 | lastName: '', 93 | profilePicture: '', 94 | uiLoading: true, 95 | imageLoading: false 96 | }; 97 | } 98 | 99 | componentWillMount = () => { 100 | authMiddleWare(this.props.history); 101 | const authToken = localStorage.getItem('AuthToken'); 102 | axios.defaults.headers.common = { Authorization: `${authToken}` }; 103 | axios 104 | .get('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/user') 105 | .then((response) => { 106 | console.log(response.data); 107 | this.setState({ 108 | firstName: response.data.userCredentials.firstName, 109 | lastName: response.data.userCredentials.lastName, 110 | email: response.data.userCredentials.email, 111 | phoneNumber: response.data.userCredentials.phoneNumber, 112 | country: response.data.userCredentials.country, 113 | username: response.data.userCredentials.username, 114 | uiLoading: false, 115 | profilePicture: response.data.userCredentials.imageUrl 116 | }); 117 | }) 118 | .catch((error) => { 119 | if(error.response.status === 403) { 120 | this.props.history.push('/login') 121 | } 122 | console.log(error); 123 | this.setState({ errorMsg: 'Error in retrieving the data' }); 124 | }); 125 | }; 126 | 127 | render() { 128 | const { classes } = this.props; 129 | if (this.state.uiLoading === true) { 130 | return ( 131 |
132 | {this.state.uiLoading && } 133 |
134 | ); 135 | } else { 136 | return ( 137 |
138 | 139 | 140 | 141 | 142 | TodoApp 143 | 144 | 145 | 146 | 153 |
154 | 155 |
156 | 157 |

158 | {' '} 159 | {this.state.firstName} {this.state.lastName} 160 |

161 |
162 | 163 | 164 | 165 | 166 | {' '} 167 | {' '} 168 | 169 | 170 | 171 | 172 | 173 | 174 | {' '} 175 | {' '} 176 | 177 | 178 | 179 | 180 | 181 | 182 | {' '} 183 | {' '} 184 | 185 | 186 | 187 | 188 | 189 | 190 |
{this.state.render ? : }
191 |
192 | ); 193 | } 194 | } 195 | } 196 | 197 | export default withStyles(styles)(home); -------------------------------------------------------------------------------- /src/pages/login.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import Avatar from '@material-ui/core/Avatar'; 3 | import Button from '@material-ui/core/Button'; 4 | import CssBaseline from '@material-ui/core/CssBaseline'; 5 | import TextField from '@material-ui/core/TextField'; 6 | import Link from '@material-ui/core/Link'; 7 | import Grid from '@material-ui/core/Grid'; 8 | import LockOutlinedIcon from '@material-ui/icons/LockOutlined'; 9 | import Typography from '@material-ui/core/Typography'; 10 | import withStyles from '@material-ui/core/styles/withStyles'; 11 | import Container from '@material-ui/core/Container'; 12 | import CircularProgress from '@material-ui/core/CircularProgress'; 13 | 14 | import axios from 'axios'; 15 | 16 | const styles = (theme) => ({ 17 | paper: { 18 | marginTop: theme.spacing(8), 19 | display: 'flex', 20 | flexDirection: 'column', 21 | alignItems: 'center' 22 | }, 23 | avatar: { 24 | margin: theme.spacing(1), 25 | backgroundColor: theme.palette.secondary.main 26 | }, 27 | form: { 28 | width: '100%', 29 | marginTop: theme.spacing(1) 30 | }, 31 | submit: { 32 | margin: theme.spacing(3, 0, 2) 33 | }, 34 | customError: { 35 | color: 'red', 36 | fontSize: '0.8rem', 37 | marginTop: 10 38 | }, 39 | progess: { 40 | position: 'absolute' 41 | } 42 | }); 43 | 44 | class login extends Component { 45 | constructor(props) { 46 | super(props); 47 | 48 | this.state = { 49 | email: '', 50 | password: '', 51 | errors: [], 52 | loading: false 53 | }; 54 | } 55 | 56 | /*componentWillReceiveProps(nextProps) { 57 | if (nextProps.UI.errors) { 58 | this.setState({ 59 | errors: nextProps.UI.errors 60 | }); 61 | } 62 | } */ 63 | 64 | handleChange = (event) => { 65 | this.setState({ 66 | [event.target.name]: event.target.value 67 | }); 68 | }; 69 | 70 | handleSubmit = (event) => { 71 | event.preventDefault(); 72 | this.setState({ loading: true }); 73 | const userData = { 74 | email: this.state.email, 75 | password: this.state.password 76 | }; 77 | axios 78 | .post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/login', userData) 79 | .then((response) => { 80 | localStorage.setItem('AuthToken', `Bearer ${response.data.token}`); 81 | this.setState({ 82 | loading: false, 83 | }); 84 | this.props.history.push('/'); 85 | }) 86 | .catch((error) => { 87 | this.setState({ 88 | errors: error.response.data, 89 | loading: false 90 | }); 91 | }); 92 | }; 93 | 94 | render() { 95 | const { classes } = this.props; 96 | const { errors, loading } = this.state; 97 | return ( 98 | 99 | 100 |
101 | 102 | 103 | 104 | 105 | Login 106 | 107 |
108 | 122 | 136 | 148 | 149 | 150 | 151 | {"Don't have an account? Sign Up"} 152 | 153 | 154 | 155 | {errors.general && ( 156 | 157 | {errors.general} 158 | 159 | )} 160 | 161 |
162 |
163 | ); 164 | } 165 | } 166 | 167 | export default withStyles(styles)(login); -------------------------------------------------------------------------------- /src/pages/signup.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import Avatar from '@material-ui/core/Avatar'; 3 | import Button from '@material-ui/core/Button'; 4 | import CssBaseline from '@material-ui/core/CssBaseline'; 5 | import TextField from '@material-ui/core/TextField'; 6 | import Link from '@material-ui/core/Link'; 7 | import Grid from '@material-ui/core/Grid'; 8 | import LockOutlinedIcon from '@material-ui/icons/LockOutlined'; 9 | import Typography from '@material-ui/core/Typography'; 10 | import Container from '@material-ui/core/Container'; 11 | import withStyles from '@material-ui/core/styles/withStyles'; 12 | import CircularProgress from '@material-ui/core/CircularProgress'; 13 | 14 | import axios from 'axios'; 15 | 16 | const styles = (theme) => ({ 17 | paper: { 18 | marginTop: theme.spacing(8), 19 | display: 'flex', 20 | flexDirection: 'column', 21 | alignItems: 'center' 22 | }, 23 | avatar: { 24 | margin: theme.spacing(1), 25 | backgroundColor: theme.palette.secondary.main 26 | }, 27 | form: { 28 | width: '100%', // Fix IE 11 issue. 29 | marginTop: theme.spacing(3) 30 | }, 31 | submit: { 32 | margin: theme.spacing(3, 0, 2) 33 | }, 34 | progess: { 35 | position: 'absolute' 36 | } 37 | }); 38 | 39 | 40 | class signup extends Component { 41 | constructor(props) { 42 | super(props); 43 | 44 | this.state = { 45 | firstName: '', 46 | lastName: '', 47 | phoneNumber: '', 48 | country: '', 49 | username: '', 50 | email: '', 51 | password: '', 52 | confirmPassword: '', 53 | errors: [], 54 | loading: false 55 | }; 56 | } 57 | 58 | componentWillReceiveProps(nextProps) { 59 | if (nextProps.UI.errors) { 60 | this.setState({ 61 | errors: nextProps.UI.errors 62 | }); 63 | } 64 | } 65 | 66 | handleChange = (event) => { 67 | this.setState({ 68 | [event.target.name]: event.target.value 69 | }); 70 | }; 71 | 72 | handleSubmit = (event) => { 73 | event.preventDefault(); 74 | this.setState({ loading: true }); 75 | const newUserData = { 76 | firstName: this.state.firstName, 77 | lastName: this.state.lastName, 78 | phoneNumber: this.state.phoneNumber, 79 | country: this.state.country, 80 | username: this.state.username, 81 | email: this.state.email, 82 | password: this.state.password, 83 | confirmPassword: this.state.confirmPassword 84 | }; 85 | axios 86 | .post('https://us-central1-to-do-app-27bee.cloudfunctions.net/api/signup', newUserData) 87 | .then((response) => { 88 | localStorage.setItem('AuthToken', `${response.data.token}`); 89 | this.setState({ 90 | loading: false, 91 | }); 92 | this.props.history.push('/'); 93 | }) 94 | .catch((error) => { 95 | this.setState({ 96 | errors: error.response.data, 97 | loading: false 98 | }); 99 | }); 100 | }; 101 | 102 | render() { 103 | const { classes } = this.props; 104 | const { errors, loading } = this.state; 105 | return ( 106 | 107 | 108 |
109 | 110 | 111 | 112 | 113 | Sign up 114 | 115 |
116 | 117 | 118 | 130 | 131 | 132 | 144 | 145 | 146 | 147 | 159 | 160 | 161 | 162 | 175 | 176 | 177 | 178 | 190 | 191 | 192 | 193 | 205 | 206 | 207 | 208 | 221 | 222 | 223 | 234 | 235 | 236 | 255 | 256 | 257 | 258 | Already have an account? Sign in 259 | 260 | 261 | 262 |
263 |
264 |
265 | ); 266 | } 267 | } 268 | 269 | 270 | export default withStyles(styles)(signup); -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' }, 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready 134 | .then(registration => { 135 | registration.unregister(); 136 | }) 137 | .catch(error => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /src/util/auth.js: -------------------------------------------------------------------------------- 1 | export const authMiddleWare = (history) => { 2 | const authToken = localStorage.getItem('AuthToken'); 3 | if(authToken === null){ 4 | history.push('/login') 5 | } 6 | } --------------------------------------------------------------------------------