From ede0530e0a28723e055a5cbebb52ee59a0c51120 Mon Sep 17 00:00:00 2001 From: Aman Date: Sat, 4 Jan 2020 01:50:56 +0530 Subject: [PATCH] mail improved --- .gitignore | 13 + README.md | 249 + archieve/_error.js | 35 + archieve/collections.js | 17 + archieve/schedule.js | 11 + package.json | 49 + public/css/bootstrap.min.css | 7 + public/css/fonts/iconsmind.woff | Bin 0 -> 1177484 bytes public/css/fonts/simple-line-icons.ttf | Bin 0 -> 46532 bytes public/css/fonts/text/nexa/NexaBold.woff | Bin 0 -> 18180 bytes public/css/fonts/text/nexa/NexaLight.woff | Bin 0 -> 18024 bytes public/css/index/app.css | 326 + public/css/index/core.css | 3 + public/css/index/main.css | 2 + public/css/index/pageloader.css | 1 + public/css/login.css | 51 + public/favicon.ico | Bin 0 -> 32988 bytes public/font-awesome.js | 5 + .../index/illustrations/drawings/teamwork.svg | 252 + public/images/index/kit/event1.jpg | Bin 0 -> 125288 bytes public/images/index/kit/event2.jpg | Bin 0 -> 90212 bytes public/images/index/kit/event3.svg | 133 + public/images/property_image.png | Bin 0 -> 13952 bytes public/images/samnivesha.png | Bin 0 -> 353903 bytes public/robots.txt | 2 + razzle.config.js | 15 + src/server/config.js | 16 + src/server/index.js | 32 + src/server/models/event.model.js | 29 + src/server/models/user.model.js | 51 + src/server/routes.js | 0 src/server/routes/event.routes.js | 54 + src/server/routes/forgot.route.js | 41 + src/server/routes/login.route.js | 7 + src/server/routes/mail.routes.js | 5 + src/server/routes/signup.routes.js | 9 + src/server/routes/users.routes.js | 67 + src/server/server.js | 123 + src/server/test.js | 17 + src/shared/App.js | 70 + src/shared/about.js | 139 + src/shared/blog.js | 259 + src/shared/components/auth.js | 24 + src/shared/components/authContext.js | 4 + src/shared/components/footer.js | 6 + src/shared/components/header.js | 185 + src/shared/components/layout.js | 11 + src/shared/components/notification.js | 14 + src/shared/components/protected.routes.js | 42 + src/shared/components/tag.js | 20 + src/shared/contact.js | 148 + src/shared/css/blog.css | 1 + src/shared/css/core.css | 3 + src/shared/css/forgot.css | 3 + src/shared/css/header.css | 121 + src/shared/css/loader.css | 1 + src/shared/css/main.css | 1 + src/shared/css/notification.css | 25 + src/shared/css/profile.css | 5 + src/shared/events.js | 47 + src/shared/forgotpassword.js | 101 + .../index/illustrations/drawings/teamwork.svg | 252 + src/shared/images/index/kit/event1.jpg | Bin 0 -> 125288 bytes src/shared/images/index/kit/event2.jpg | Bin 0 -> 90212 bytes src/shared/images/index/kit/event3.svg | 133 + src/shared/images/property_image.png | Bin 0 -> 13952 bytes src/shared/images/samnivesha.png | Bin 0 -> 353903 bytes src/shared/index.js | 266 + src/shared/login.js | 161 + src/shared/profile.js | 320 + src/shared/signup.js | 299 + src/shared/sponsors.js | 47 + src/shared/workshop.js | 48 + src/web/client.js | 17 + utils/fetchImage.js | 26 + utils/getEventsData.js | 8 + utils/getUserData.js | 9 + utils/redirect.js | 10 + utils/sendmail.js | 26 + utils/sessionconfig.js | 17 + utils/verifylogin.js | 22 + yarn.lock | 9784 +++++++++++++++++ 82 files changed, 14297 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 archieve/_error.js create mode 100644 archieve/collections.js create mode 100644 archieve/schedule.js create mode 100644 package.json create mode 100644 public/css/bootstrap.min.css create mode 100644 public/css/fonts/iconsmind.woff create mode 100644 public/css/fonts/simple-line-icons.ttf create mode 100644 public/css/fonts/text/nexa/NexaBold.woff create mode 100644 public/css/fonts/text/nexa/NexaLight.woff create mode 100644 public/css/index/app.css create mode 100644 public/css/index/core.css create mode 100644 public/css/index/main.css create mode 100644 public/css/index/pageloader.css create mode 100644 public/css/login.css create mode 100644 public/favicon.ico create mode 100644 public/font-awesome.js create mode 100644 public/images/index/illustrations/drawings/teamwork.svg create mode 100644 public/images/index/kit/event1.jpg create mode 100644 public/images/index/kit/event2.jpg create mode 100644 public/images/index/kit/event3.svg create mode 100644 public/images/property_image.png create mode 100644 public/images/samnivesha.png create mode 100644 public/robots.txt create mode 100644 razzle.config.js create mode 100644 src/server/config.js create mode 100644 src/server/index.js create mode 100644 src/server/models/event.model.js create mode 100644 src/server/models/user.model.js create mode 100644 src/server/routes.js create mode 100644 src/server/routes/event.routes.js create mode 100644 src/server/routes/forgot.route.js create mode 100644 src/server/routes/login.route.js create mode 100644 src/server/routes/mail.routes.js create mode 100644 src/server/routes/signup.routes.js create mode 100644 src/server/routes/users.routes.js create mode 100644 src/server/server.js create mode 100644 src/server/test.js create mode 100644 src/shared/App.js create mode 100644 src/shared/about.js create mode 100644 src/shared/blog.js create mode 100644 src/shared/components/auth.js create mode 100644 src/shared/components/authContext.js create mode 100644 src/shared/components/footer.js create mode 100644 src/shared/components/header.js create mode 100644 src/shared/components/layout.js create mode 100644 src/shared/components/notification.js create mode 100644 src/shared/components/protected.routes.js create mode 100644 src/shared/components/tag.js create mode 100644 src/shared/contact.js create mode 100644 src/shared/css/blog.css create mode 100644 src/shared/css/core.css create mode 100644 src/shared/css/forgot.css create mode 100644 src/shared/css/header.css create mode 100644 src/shared/css/loader.css create mode 100644 src/shared/css/main.css create mode 100644 src/shared/css/notification.css create mode 100644 src/shared/css/profile.css create mode 100644 src/shared/events.js create mode 100644 src/shared/forgotpassword.js create mode 100644 src/shared/images/index/illustrations/drawings/teamwork.svg create mode 100644 src/shared/images/index/kit/event1.jpg create mode 100644 src/shared/images/index/kit/event2.jpg create mode 100644 src/shared/images/index/kit/event3.svg create mode 100644 src/shared/images/property_image.png create mode 100644 src/shared/images/samnivesha.png create mode 100644 src/shared/index.js create mode 100644 src/shared/login.js create mode 100644 src/shared/profile.js create mode 100644 src/shared/signup.js create mode 100644 src/shared/sponsors.js create mode 100644 src/shared/workshop.js create mode 100644 src/web/client.js create mode 100644 utils/fetchImage.js create mode 100644 utils/getEventsData.js create mode 100644 utils/getUserData.js create mode 100644 utils/redirect.js create mode 100644 utils/sendmail.js create mode 100644 utils/sessionconfig.js create mode 100644 utils/verifylogin.js create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..82d4b25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +logs +*.log +npm-debug.log* +.DS_Store + +coverage +node_modules +build +.env +.env.local +.env.development.local +.env.test.local +.env.production.local \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3b141a0 --- /dev/null +++ b/README.md @@ -0,0 +1,249 @@ +**WARNING: This is the documentation for `razzle@next` (Webpack 4).** +[Go here for for razzle@0.8.x (stable) docs (Webpack 3)](https://github.com/jaredpalmer/razzle/tree/master). + +![repo-banner](https://user-images.githubusercontent.com/4060187/28923990-050a32d4-782e-11e7-9da7-574ce5a8b455.png) + +[![CircleCI](https://circleci.com/gh/jaredpalmer/razzle/tree/master.svg?style=shield)](https://circleci.com/gh/jaredpalmer/razzle/tree/master) ![Razzle-status](https://david-dm.org/jaredpalmer/razzle.svg?path=packages/razzle) [![npm version](https://badge.fury.io/js/razzle.svg)](https://badge.fury.io/js/razzle) + +Universal JavaScript applications are tough to setup. Either you buy into a framework like [Next.js](https://github.com/zeit/next.js) or [react-server](https://github.com/redfin/react-server), fork a boilerplate, or set things up yourself. Aiming to fill this void, Razzle is a tool that abstracts all complex configuration needed for SSR into a single dependency--giving you the awesome developer experience of [create-react-app](https://github.com/facebookincubator/create-react-app), but then leaving the rest of your app's architectural decisions about frameworks, routing, and data fetching up to you. With this approach, Razzle not only works with React, but also Reason, Elm, Vue, Angular, and most importantly......whatever comes next. + +**Razzle comes with the "battery-pack included"**: + +* :fire: Universal Hot Module Replacement, so both the client and server update whenever you make edits. No annoying restarts necessary +* Comes with your favorite ES6 JavaScript goodies (through `babel-preset-razzle`) +* Comes with the same CSS setup as [create-react-app](https://github.com/facebookincubator/create-react-app) +* Works with [React](https://github.com/facebook/react), [Preact](https://github.com/developit/preact), [Elm](http://elm-lang.org/), [Reason-React](https://github.com/jaredpalmer/razzle/tree/master/examples/with-reason-react), [Inferno](https://github.com/infernojs), and [Rax](https://github.com/alibaba/rax) as well as [Angular](https://github.com/angular/angular) and [Vue](https://github.com/vuejs/vue) if that's your thing +* Escape hatches for customization via `.babelrc` and `razzle.config.js` +* [Jest](https://github.com/facebook/jest) test runner setup with sensible defaults via `razzle test` + +## Quick Start + +[![Greenkeeper badge](https://badges.greenkeeper.io/jaredpalmer/razzle.svg)](https://greenkeeper.io/) + +```bash +npm install -g create-razzle-app + +create-razzle-app my-app +cd my-app +npm start +``` + +Then open http://localhost:3000/ to see your app. Your console should look like this: + +Razzle Development Mode + +**That's it**. You don't need to worry about setting up multiple webpack configs or other build tools. Just start editing `src/App.js` and go! + +Below is a list of commands you will probably find useful. + +### `npm start` or `yarn start` + +Runs the project in development mode. +You can view your application at `http://localhost:3000` + +The page will reload if you make edits. + +### `npm run build` or `yarn build` + +Builds the app for production to the build folder. + +The build is minified and the filenames include the hashes. +Your app is ready to be deployed! + +### `npm run start:prod` or `yarn start:prod` + +Runs the compiled app in production. + +You can again view your application at `http://localhost:3000` + +### `npm test` or `yarn test` + +Runs the test watcher (Jest) in an interactive mode. +By default, runs tests related to files changed since the last commit. + +### `npm start -- --inspect` or `yarn start -- --inspect` + +To debug the node server, you can use `razzle start --inspect`. This will start the node server and enable the inspector agent. For more information, see [this](https://nodejs.org/en/docs/inspector/). + +### `npm start -- --inspect-brk` or `yarn start -- --inspect-brk` + +To debug the node server, you can use `razzle start --inspect-brk`. This will start the node server, enable the inspector agent and Break before user code starts. For more information, see [this](https://nodejs.org/en/docs/inspector/). + +### `rs` + +If your application is running, and you need to manually restart your server, you do not need to completely kill and rebundle your application. Instead you can just type `rs` and press enter in terminal. + +## Razzle Hot Restart + + + + + +**Table of Contents** + +* [Customization](#customization) + * [Extending Babel Config](#extending-babel-config) + * [Extending Webpack](#extending-webpack) + * [Environment Variables](#environment-variables) + * [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) + * [Windows (cmd.exe)](#windows-cmdexe) + * [Linux, macOS (Bash)](#linux-macos-bash) + * [Adding Environment Variables In `.env`](#adding-environment-variables-in-env) + * [What other `.env` files are can be used?](#what-other-env-files-are-can-be-used) +* [How Razzle works (the secret sauce)](#how-razzle-works-the-secret-sauce) +* [Inspiration](#inspiration) + * [Author](#author) +* [Contributors](#contributors) + + + +## Customization + +### Customizing Babel Config + +Razzle comes with most of ES6 stuff you need. However, if you want to add your own babel transformations, just add a `.babelrc` file to the root of your project. + +```js +{ + "presets": [ + "razzle/babel", // NEEDED + "stage-0" + ], + "plugins": [ + // additional plugins + ] +} +``` + +A word of advice: the `.babelrc` file will replace the internal razzle babelrc template. You must include at the very minimum the default razzle/babel preset. + +### Extending Webpack + +You can also extend the underlying webpack config. Create a file called `razzle.config.js` in your project's root. + +```js +// razzle.config.js + +module.exports = { + modify: (config, { target, dev }, webpack) => { + // do something to config + + return config; + }, +}; +``` + +A word of advice: `razzle.config.js` is an escape hatch. However, since it's just JavaScript, you can and should publish your `modify` function to npm to make it reusable across your projects. For example, imagine you added some custom webpack loaders and published it as a package to npm as `my-razzle-modifictions`. You could then write your `razzle.config.js` like so: + +``` +// razzle.config.js +const modify = require('my-razzle-modifictions'); + +module.exports = { + modify +} +``` + +Last but not least, if you find yourself needing a more customized setup, Razzle is _very_ forkable. There is one webpack configuration factory that is 300 lines of code, and 4 scripts (`build`, `start`, `test`, and `init`). The paths setup is shamelessly taken from [create-react-app](https://github.com/facebookincubator/create-react-app), and the rest of the code related to logging. + +### Environment Variables + +**The environment variables are embedded during the build time.** You can read them at runtime just because by default we export them with the `webpack.DefinePlugin`. + +* `process.env.RAZZLE_PUBLIC_DIR`: Path to the public directory. +* `process.env.RAZZLE_ASSETS_MANIFEST`: Path to a file containing compiled asset outputs +* `process.env.REACT_BUNDLE_PATH`: Relative path to where React will be bundled during development. Unless you are modifying the output path of your webpack config, you can safely ignore this. This path is used by `react-error-overlay` and webpack to power up the fancy runtime error iframe. For example, if you are using common chunks and an extra entry to create a vendor bundle with stuff like react, react-dom, react-router, etc. called `vendor.js`, and you've changed webpack's output to `[name].js` in development, you'd want to set this environment variable to `/static/js/vendor.js`. If you do not make this change, nothing bad will happen, you will simply not get the cool error overlay when there are runtime errors. You'll just see them in the console. Note: This does not impact production bundling. +* `process.env.VERBOSE`: default is false, setting this to true will not clear the console when you make edits in development (useful for debugging). +* `process.env.PORT`: default is `3000`, unless changed +* `process.env.HOST`: default is `0.0.0.0` +* `process.env.NODE_ENV`: `'development'` or `'production'` +* `process.env.BUILD_TARGET`: either `'client'` or `'server'` +* `process.env.PUBLIC_PATH`: Only in used in `razzle build`. You can alter the `webpack.config.output.publicPath` of the client assets (bundle, css, and images). This is useful if you plan to serve your assets from a CDN. Make sure to _include_ a trailing slash (e.g. `PUBLIC_PATH=https://cdn.example.com/`). If you are using React and altering the public path, make sure to also [include the `crossorigin` attribute](https://reactjs.org/docs/installation.html#using-a-cdn) on your `` + : `` + } + + +
${markup}
+ + + ` + ); + } + }); + }); + +export default server; diff --git a/src/server/test.js b/src/server/test.js new file mode 100644 index 0000000..3a78f9c --- /dev/null +++ b/src/server/test.js @@ -0,0 +1,17 @@ +const axios = require("axios"); +const sendTo = "aman29271@gmail.com"; +const link = `reset/abc`; +const subject = "Password Reset link"; +const body = `Please click on this link ${link} to reset your password.`; +axios + .post("http://localhost:3000/mail", { sendTo, subject, body }) + .then(response => { + if (response.status == 200) { + // res.send(200).json({ message: "Reset Mail sent." }); + console.log("Reset Mail sent."); + } + }) + .catch((err) => { + // res.status(404).json({ message: "Mail Error" }); + console.log(err.toJSON().code); + }); diff --git a/src/shared/App.js b/src/shared/App.js new file mode 100644 index 0000000..c0535e4 --- /dev/null +++ b/src/shared/App.js @@ -0,0 +1,70 @@ +import React, { useState, useEffect } from "react"; +import { Route, Switch } from "react-router-dom"; +import Home from "./index"; +import About from "./about"; +import Contact from "./contact"; +import Events from "./events"; +import Blog from "./blog"; +import Profile from "./profile"; +import Login from "./login"; +import Signup from "./signup"; +import Workshop from "./workshop"; +import Sponsors from "./sponsors"; +import Header from "./components/header"; +import Cookies from "js-cookie"; +import Forgotpassword from './forgotpassword' + +import AuthContext from "./components/authContext"; +import { + ProtectedProfile, + ProtectedLogin, + ProtectedSignup, + ProtectedResetPassword +} from "./components/protected.routes"; + +const App = props => { + const [isAuthenticated, setIsAuthenticated] = useState(false); + const [user, setUser] = useState(""); + const [firstRender, setFirstrender] = useState(true); + const { store } = props; + useEffect(() => { + function runAtFirstRender() { + if (store.length > 1) { + // User is already logged in + if (store[0].userData == !"undefined" && Cookies.get("uid") !== "") { + setIsAuthenticated(true); + setUser(store[0].userData); + } else { + setIsAuthenticated(true); + setUser(store[0].userData); + } + } + setFirstrender(false); + } + if (firstRender) { + runAtFirstRender(); + } + }); + return ( + +
+ + } /> + + + + {/* */} + + + + + + + + + ); +}; + +export default App; diff --git a/src/shared/about.js b/src/shared/about.js new file mode 100644 index 0000000..a722072 --- /dev/null +++ b/src/shared/about.js @@ -0,0 +1,139 @@ +import React, { Component } from "react"; +import Layout from "./components/layout"; +import {Helmet} from 'react-helmet' + +class About extends Component { + constructor(props) { + super(props); + this.state = {}; + } + // componentDidMount() {}; + render() { + return ( + <> + + + + + +
+
+
+
+

About us

+

+ Association of Civil Engineers +

+

+ Samnivesha is the annual technical fest of the Department of + Civil and Environmental Engineering (DCEE) with a myriad of + events revolving around the exciting areas of Civil and + Environmental engineering. India needs better engineers for + its infrastructural and economic growth. With this vision in + our mind the DCEE annually conducts its very own technical + fest to attract engineers from all over the country and + provide them plethora of events to compete for and win + exciting rewards. +
+
The technical extravaganza is conducted by the + Association of Civil Engineers (ACE), the official + departmental Club of DCEE. Samnivesha will be a pioneer, a + fest first of its kind in Bihar, a fest completely based on + Civil Engineering! This festival forms a forum of similar + minds encouraging them to engage technically and develop + skills in civil applications. Samnivesha includes various + events, right from developing plans, testing minds on + knowledge and application in the constructionWorld! +

The first edition of Samnivesha was a huge + success, comprising of exciting events, workshops and guest + lectures. The whole idea behind the fest is to provide + exposure to various industrial and research topics in Civil + engineering. Students from colleges across Bihar + participated with great zeal and enthusiasm. The total + footfall is estimated to be around 2000! Prof Devdas Menon + (IIT Madras) gave a very informative guest lecture. Several + events like Richter 9.0 related to earthquake resistibility, + BluePrint to showcase your designing skills, CiviQ to test + your knowledge in this field, House of cards attracted huge + participation from various colleges of Bihar. A workshop on + STAAD PRO, software widely used in structural engineering + was also conducted by none other than Bentley itself. +
+
Now ACE is back with another edition of Samnivesha. +

We envisage this edition of Samniveshato be a + grand success in not only Bihar but also the Eastern India. + It will restore the glory of Bihar as the greatest centre of + education for which it was once known for and ultimately + serve the purpose of producing better engineers for a better + tomorrow. +

+
+
+ +
+
+
+
+ +
+
+ {/*
+
+ +

+ Lorem ipsum dolor sit amet +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed + do eiusmod tempor incididunt ut labore et dolore magna aliqua. +

+ +
+
+ +
+
*/} + {/*
*/} + {/*
+ +
*/} + {/*
+ +

+ Lorem ipsum dolor sit amet +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed + do eiusmod tempor incididunt ut labore et dolore magna aliqua. +

+ + Learn More + +
*/} + {/*
*/} +
+
+
+ + ); + } +} + +export default About; diff --git a/src/shared/blog.js b/src/shared/blog.js new file mode 100644 index 0000000..5e2123d --- /dev/null +++ b/src/shared/blog.js @@ -0,0 +1,259 @@ +import React from "react"; +import Layout from "./components/layout"; + +const Blog = () => { + return ( + +
+
+
+
+
+ +
+
+
+

Tristique senectus et netus et.

+

+ Purus semper eget duis at tellus at urna condimentum mattis. + Non blandit massa enim nec. Integer enim neque volutpat ac + tincidunt vitae semper quis. Accumsan tortor posuere ac ut + consequat semper viverra nam. +

+

+ Learn more +

+
+
+
+
+
+
+
+ +
+
+
+

Tempor orci dapibus ultrices in.

+

+ Ut venenatis tellus in metus vulputate. Amet consectetur + adipiscing elit pellentesque. Sed arcu non odio euismod + lacinia at quis risus. Faucibus turpis in eu mi bibendum + neque egestas cmonsu songue. Phasellus vestibulum lorem sed + risus. +

+

+ Learn more +

+
+
+
+
+
+
+
+ +
+
+
+

Leo integer malesuada nunc vel risus.

+

+ Imperdiet dui accumsan sit amet nulla facilisi morbi. Fusce + ut placerat orci nulla pellentesque dignissim enim. Libero + id faucibus nisl tincidunt eget nullam. Commodo viverra + maecenas accumsan lacus vel facilisis. +

+

+ Learn more +

+
+
+
+
+
+
+

Perfect for developers or designers!

+
+

+ Vel fringilla est ullamcorper eget nulla facilisi. Nulla facilisi + nullam vehicula ipsum a. Neque egestas congue quisque egestas diam + in arcu cursus. +

+
+
+
+
+
+

Hello World

+

What is up?

+
+
+
+
+

Foo

+

Bar

+
+
+
+
+

Third column

+

With some content

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Proin ornare magna eros, eu pellentesque tortor vestibulum + ut. Maecenas non massa sem. Etiam finibus odio quis feugiat + facilisis. +

+
+
+
+
+
+
+
+
+
+

Vertical tiles

+

Top box

+
+
+

Vertical tiles

+

Bottom box

+
+
+
+
+

Middle box

+

With an image

+
+ Description +
+
+
+
+
+
+

Wide column

+

Aligned with the right column

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Proin ornare magna eros, eu pellentesque tortor vestibulum + ut. Maecenas non massa sem. Etiam finibus odio quis + feugiat facilisis. +

+
+
+
+
+
+
+
+

Tall column

+

With even more content

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Etiam semper diam at erat pulvinar, at pulvinar felis + blandit. Vestibulum volutpat tellus diam, consequat + gravida libero rhoncus ut. Morbi maximus, leo sit amet + vehicula eleifend, nunc dui porta orci, quis semper odio + felis ut quam. +

+

+ Suspendisse varius ligula in molestie lacinia. Maecenas + varius eget ligula a sagittis. Pellentesque interdum, nisl + nec interdum maximus, augue diam porttitor lorem, et + sollicitudin felis neque sit amet erat. Maecenas imperdiet + felis nisi, fringilla luctus felis hendrerit sit amet. + Aenean vitae gravida diam, finibus dignissim turpis. Sed + eget varius ligula, at volutpat tortor. +

+

+ Integer sollicitudin, tortor a mattis commodo, velit urna + rhoncus erat, vitae congue lectus dolor consequat libero. + Donec leo ligula, maximus et pellentesque sed, gravida a + metus. Cras ullamcorper a nunc ac porta. Aliquam ut + aliquet lacus, quis faucibus libero. Quisque non semper + leo. +

+
+
+
+
+
+
+
+
+

Side column

+

With some content

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Proin ornare magna eros, eu pellentesque tortor vestibulum + ut. Maecenas non massa sem. Etiam finibus odio quis feugiat + facilisis. +

+
+
+
+
+
+

Main column

+

With some content

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Proin ornare magna eros, eu pellentesque tortor vestibulum + ut. Maecenas non massa sem. Etiam finibus odio quis feugiat + facilisis. +

+
+
+
+
+
+
+
+

Murphy's law

+

+ Anything that can go wrong will go wrong +

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Proin ornare magna eros, eu pellentesque tortor vestibulum + ut. Maecenas non massa sem. Etiam finibus odio quis feugiat + facilisis. +

+
+
+
+
+
+

Main column

+

With some content

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Proin ornare magna eros, eu pellentesque tortor vestibulum + ut. Maecenas non massa sem. Etiam finibus odio quis feugiat + facilisis. +

+
+
+
+
+
+
+ +
+ ); +}; +export default Blog; diff --git a/src/shared/components/auth.js b/src/shared/components/auth.js new file mode 100644 index 0000000..b859181 --- /dev/null +++ b/src/shared/components/auth.js @@ -0,0 +1,24 @@ +import react, { Component } from "react"; +import Cookies from "js-cookie"; + +class Auth extends Component { + constructor(props) { + super(props); + this.state = { + isLoggedIn: false, + user: "" + }; + } + isAuthenticated() { + const sid = Cookies.get("sid"); + console.log(sid); + return this.state.user; + } + isLoggedIn() { + return this.state.isLoggedIn; + } + logout() { + this.setState({ isLoggedIn: false, user: "" }); + } +} +export default new Auth(); diff --git a/src/shared/components/authContext.js b/src/shared/components/authContext.js new file mode 100644 index 0000000..1ef061e --- /dev/null +++ b/src/shared/components/authContext.js @@ -0,0 +1,4 @@ +import React from 'react' + +const AuthContext = React.createContext() +export default AuthContext \ No newline at end of file diff --git a/src/shared/components/footer.js b/src/shared/components/footer.js new file mode 100644 index 0000000..03a82ef --- /dev/null +++ b/src/shared/components/footer.js @@ -0,0 +1,6 @@ +import React from "react"; + +const Footer = () => { + return
; +}; +export default Footer; diff --git a/src/shared/components/header.js b/src/shared/components/header.js new file mode 100644 index 0000000..ba408d5 --- /dev/null +++ b/src/shared/components/header.js @@ -0,0 +1,185 @@ +import React, { useState, useContext } from "react"; +import "../css/header.css"; +import { Link } from "react-router-dom"; +import Cookies from "js-cookie"; +import AuthContext from "./authContext"; +const axios = require("axios"); + +const config = { + environment: Boolean(process.env.NODE_ENV !== "production") +}; + +const styles = { + nav: { + backgroundColor: "unset", + position: "absolute", + width: "100%" + } +}; +const Header = props => { + const { isAuthenticated, setIsAuthenticated, setUser } = useContext( + AuthContext + ); + const [isMobile, setIsMobile] = useState(""); + const hideMenu = () => { + setIsMobile(""); + }; + const showMenu = () => { + setIsMobile("is-active"); + }; + const logout = () => { + Cookies.remove("uid"); + setIsAuthenticated(false); + setUser(""); + axios + .post("/logout") + .then(res => { + if (res.data == "success") { + this.props.history.push("/"); + } + }) + .catch(err => { + console.log(err); + }); + }; + const Prefetch = config.environment ? "true" : "false"; + return ( + + ); +}; +export default Header; diff --git a/src/shared/components/layout.js b/src/shared/components/layout.js new file mode 100644 index 0000000..a653570 --- /dev/null +++ b/src/shared/components/layout.js @@ -0,0 +1,11 @@ +import React from "react"; +import Footer from '../components/footer' +function Layout({ children }) { + return ( + <> + {children} +