diff --git a/app.js b/app.js new file mode 100644 index 0000000..e6a623d --- /dev/null +++ b/app.js @@ -0,0 +1,236 @@ +const { + expressCspHeader, + INLINE, + NONE, + SELF +} = require("express-csp-header"); +require("dotenv").config(); //for env vars +const express = require("express"); +//const expressLayouts = require('express-ejs-layouts'); +const mongoose = require("mongoose"); +const app = express(); +//const flash = require('connect-flash'); +const session = require("express-session"); +const passport = require("passport"); +const bodyParser = require("body-parser"); +const helmet = require("helmet"); +const cors = require("cors"); +const path = require("path"); + +//Passport config +require("./config/passport-google")(passport); +//passport is for authenticating only +//flash message is a message stored in a session and displayed after a redirect of some sort + +//DB Config +const db = require("./config/keys").MongoURI; +//Connect to mongo +mongoose + .connect(db, { + useNewUrlParser: true, + useUnifiedTopology: true, + }) + .then(() => console.log("MongoDB connected", process.env.Mongo_URI)) + .catch((err) => console.log(err.message)); +//EJS +//app.use(expressLayouts); +//app.set('view engine', 'ejs'); +//Bodyparser +app.use( + express.urlencoded({ + extended: true, + }) +); +app.use(bodyParser.json()); + +app.use(cors()); +app.use( + expressCspHeader({ + directives: { + "default-src": [ + SELF, + "*.google.com", + "https://*/", + "https://kit.fontawesome.com/", + "https://images.squarespace-cdn.com/", + "https://fonts.gstatic.com/", + "*.googleapis.com", + "kit.fontawesome.com", + "https://apis.google.com/js/", + "https://kit.fontawesome.com/*", + "*.google.com", + "https://kit.fontawesome.com/", + "https://images.squarespace-cdn.com/", + "https://fonts.gstatic.com/", + "*.googleapis.com", + "kit.fontawesome.com", + "https://apis.google.com/js/", + "data:", + "https://apis.google.com/js/api.js", + "apis.google.com", + "self", + + SELF, + INLINE, + ], + "script-src": [ + SELF, + "*.google.com", + "https://kit.fontawesome.com/", + "https://images.squarespace-cdn.com/", + "https://fonts.gstatic.com/", + "*.googleapis.com", + "kit.fontawesome.com", + "https://apis.google.com/js/", + "https://kit.fontawesome.com/*", + "*.google.com", + "https://kit.fontawesome.com/", + "https://images.squarespace-cdn.com/", + "https://fonts.gstatic.com/", + "*.googleapis.com", + "kit.fontawesome.com", + "https://apis.google.com/js/", + "data:", + "https://apis.google.com/js/api.js", + "apis.google.com", + "self", + "data: *", + INLINE, + ], + "img-src": ["data:image/svg+xml", SELF, + "*.google.com", + "https://*/", + "https://kit.fontawesome.com/", + "https://images.squarespace-cdn.com/", + "https://fonts.gstatic.com/", + "*.googleapis.com", + "kit.fontawesome.com", + "https://apis.google.com/js/", + "https://kit.fontawesome.com/*", + "*.google.com", + "https://kit.fontawesome.com/", + "https://images.squarespace-cdn.com/", + "https://fonts.gstatic.com/", + "*.googleapis.com", + "kit.fontawesome.com", + "https://apis.google.com/js/", + "data:", + "https://apis.google.com/js/api.js", + "apis.google.com", + "self", + + SELF, + INLINE, + ], + }, + }) +); +//Express session +// app.use( +// session({ +// secret: "keyboard cat", +// resave: false, +// saveUninitialized: false, +// }) +// ); +//when user is authenticated its serialised to cookies and then attached to req.user(as well as req.session.passport.user) +//on subsequent requests, passport.initialize() middleware is called. +//It finds the passport.user attached to the session, if it doesnt(user yet not authenticated) it creates it like req.passport.user={} +//passport.initialize middleware is invoked on every request. It ensures the session contains a passport.user object, which may be empty +app.use(passport.initialize()); + +//next passport.session() is invoked. If it finds a serialised user object in the session, it considers the request to be authenticated. +//it then calls the passport.deserializeUser whule attaching the loaded user ibject to req as req.user() +//passport.session middleware is a Passport Strategy which will load the user object onto req.user if a serialised user object was found in the server. +//passport.deserializeUser is invoked on every request by passport.session. It enables us to load additional user information on every request. This user object is attached to the request as req.user making it accessible in our request handling. +// +// app.use(passport.session()); +//Connect flash +// app.use(flash()); + +// //Global vars +// app.use(function (req, res, next) { +// res.locals.success_msg = req.flash('success_msg'); +// res.locals.error_msg = req.flash('error_msg'); +// res.locals.error_msg = req.flash('error') +// next(); +// }); +// app.use((req, res, next) => [ +// res.setHeader("default-src 'self'; script-src 'report-sample' 'self' https://apis.google.com/js/api.js https://kit.fontawesome.com/5a3d56a40e.js; style-src 'report-sample' 'self' https://fonts.googleapis.com https://kit-free.fontawesome.com; object-src 'none'; base-uri 'self'; connect-src 'self'; font-src 'self' https://fonts.gstatic.com https://kit-free.fontawesome.com; frame-src 'self' https://accounts.google.com; img-src 'self'; manifest-src 'self'; media-src 'self'; report-uri https://5f4b9f5fb641482c3e7cfaaa.endpoint.csper.io/; worker-src 'self';") +// ]) +app.use("/public", express.static("public")); + +//Routes +app.use("/api/menu", require("./routes/api_menu")); +//app.use("/api/dish", require("./routes/api_dish")); no use as all the dishes are inside the Menu +app.use("/api/profile", require("./routes/api_profile")); +app.use("/api/cart", require("./routes/api_cart")); +app.use("/api/order", require("./routes/api_order")); +app.use("/api/cafe", require("./routes/api_cafe")); +if (process.env.NODE_ENV === "production") { + // Set static folder + app.use(express.static("gsuser/build")); + + app.get("*", (req, res) => { + res.sendFile(path.resolve(__dirname, "gsuser", "build", "index.html")); + }); +} +app.get("/404", function(req, res, next) { + // trigger a 404 since no other middleware + // will match /404 after this one, and we're not + // responding here + next(); +}); + +app.get("/403", function(req, res, next) { + // trigger a 403 error + var err = new Error("not allowed!"); + err.status = 403; + next(err); +}); + +app.get("/500", function(req, res, next) { + // trigger a generic (500) error + next(new Error("keyboard cat!")); +}); + +// Error handlers + +// Since this is the last non-error-handling +// middleware use()d, we assume 404, as nothing else +// responded. + +// $ curl http://localhost:3000/notfound +// $ curl http://localhost:3000/notfound -H "Accept: application/json" +// $ curl http://localhost:3000/notfound -H "Accept: text/plain" + +app.use(function(req, res, next) { + res.status(404).json({ + message: "Requested route not found", + }); +}); + +// error-handling middleware, take the same form +// as regular middleware, however they require an +// arity of 4, aka the signature (err, req, res, next). +// when connect has an error, it will invoke ONLY error-handling +// middleware. + +// If we were to next() here any remaining non-error-handling +// middleware would then be executed, or if we next(err) to +// continue passing the error, only error-handling middleware +// would remain being executed, however here +// we simply respond with an error page. + +// app.use(function(err, req, res, next) { +// // we may use properties of the error object +// // here and next(err) appropriately, or if +// // we possibly recovered from the error, simply next(). +// res.status(err.status || 500).json({ +// error: err.message +// }); +// }); +const PORT = process.env.PORT || 5000; +app.listen(PORT, () => { + console.log(`Server started on ${PORT}`); +}); \ No newline at end of file diff --git a/src/config/.passport-google.js.un~ b/config/.passport-google.js.un~ similarity index 100% rename from src/config/.passport-google.js.un~ rename to config/.passport-google.js.un~ diff --git a/src/config/auth.js b/config/auth.js similarity index 100% rename from src/config/auth.js rename to config/auth.js diff --git a/src/config/auth.js.orig b/config/auth.js.orig similarity index 100% rename from src/config/auth.js.orig rename to config/auth.js.orig diff --git a/config/keys.js b/config/keys.js new file mode 100644 index 0000000..1e32270 --- /dev/null +++ b/config/keys.js @@ -0,0 +1,3 @@ +module.exports = { + MongoURI: 'mongodb+srv://dipin:dipin@cluster0.jskbn.mongodb.net/TestDB?retryWrites=true&w=majority' +} \ No newline at end of file diff --git a/src/config/mongo-url.js b/config/mongo-url.js similarity index 100% rename from src/config/mongo-url.js rename to config/mongo-url.js diff --git a/src/config/multer_support.js b/config/multer_support.js similarity index 100% rename from src/config/multer_support.js rename to config/multer_support.js diff --git a/src/config/passport-google.js b/config/passport-google.js similarity index 100% rename from src/config/passport-google.js rename to config/passport-google.js diff --git a/src/gsadmin/.gitignore b/gsadmin/.gitignore similarity index 100% rename from src/gsadmin/.gitignore rename to gsadmin/.gitignore diff --git a/src/gsadmin/README.md b/gsadmin/README.md similarity index 100% rename from src/gsadmin/README.md rename to gsadmin/README.md diff --git a/src/gsadmin/package-lock.json b/gsadmin/package-lock.json similarity index 100% rename from src/gsadmin/package-lock.json rename to gsadmin/package-lock.json diff --git a/gsadmin/package.json b/gsadmin/package.json new file mode 100644 index 0000000..d6494b9 --- /dev/null +++ b/gsadmin/package.json @@ -0,0 +1,49 @@ +{ + "name": "gsadmin", + "version": "0.1.0", + "private": true, + "dependencies": { + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^7.1.2", + "bootstrap": "^4.5.0", + "bootstrap-social": "^5.1.1", + "cross-fetch": "^3.0.5", + "font-awesome": "^4.7.0", + "prop-types": "^15.7.2", + "react": "^16.13.1", + "react-animation-components": "^3.0.0", + "react-dom": "^16.13.1", + "react-popper": "^2.2.3", + "react-redux": "^7.2.0", + "react-redux-form": "^1.16.14", + "react-router-dom": "^5.2.0", + "react-scripts": "3.4.1", + "react-transition-group": "^4.4.1", + "reactstrap": "^8.4.1", + "redux": "^4.0.5", + "redux-logger": "^3.0.6", + "redux-thunk": "^2.3.0" + }, + "scripts": { + "start": "set PORT=3006 && react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": "react-app" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} \ No newline at end of file diff --git a/src/gsadmin/public/assets/images/alberto.png b/gsadmin/public/assets/images/alberto.png similarity index 100% rename from src/gsadmin/public/assets/images/alberto.png rename to gsadmin/public/assets/images/alberto.png diff --git a/src/gsadmin/public/assets/images/buffet.png b/gsadmin/public/assets/images/buffet.png similarity index 100% rename from src/gsadmin/public/assets/images/buffet.png rename to gsadmin/public/assets/images/buffet.png diff --git a/src/gsadmin/public/assets/images/elaicheesecake.png b/gsadmin/public/assets/images/elaicheesecake.png similarity index 100% rename from src/gsadmin/public/assets/images/elaicheesecake.png rename to gsadmin/public/assets/images/elaicheesecake.png diff --git a/src/gsadmin/public/assets/images/logo.png b/gsadmin/public/assets/images/logo.png similarity index 100% rename from src/gsadmin/public/assets/images/logo.png rename to gsadmin/public/assets/images/logo.png diff --git a/src/gsadmin/public/assets/images/uthappizza.png b/gsadmin/public/assets/images/uthappizza.png similarity index 100% rename from src/gsadmin/public/assets/images/uthappizza.png rename to gsadmin/public/assets/images/uthappizza.png diff --git a/src/gsadmin/public/assets/images/vadonut.png b/gsadmin/public/assets/images/vadonut.png similarity index 100% rename from src/gsadmin/public/assets/images/vadonut.png rename to gsadmin/public/assets/images/vadonut.png diff --git a/src/gsadmin/public/assets/images/zucchipakoda.png b/gsadmin/public/assets/images/zucchipakoda.png similarity index 100% rename from src/gsadmin/public/assets/images/zucchipakoda.png rename to gsadmin/public/assets/images/zucchipakoda.png diff --git a/src/gsadmin/public/c1.jpg b/gsadmin/public/c1.jpg similarity index 100% rename from src/gsadmin/public/c1.jpg rename to gsadmin/public/c1.jpg diff --git a/src/gsadmin/public/favicon.ico b/gsadmin/public/favicon.ico similarity index 100% rename from src/gsadmin/public/favicon.ico rename to gsadmin/public/favicon.ico diff --git a/src/gsadmin/public/header-bg.jpg b/gsadmin/public/header-bg.jpg similarity index 100% rename from src/gsadmin/public/header-bg.jpg rename to gsadmin/public/header-bg.jpg diff --git a/src/gsadmin/public/img.jpg b/gsadmin/public/img.jpg similarity index 100% rename from src/gsadmin/public/img.jpg rename to gsadmin/public/img.jpg diff --git a/src/gsadmin/public/index.html b/gsadmin/public/index.html similarity index 100% rename from src/gsadmin/public/index.html rename to gsadmin/public/index.html diff --git a/src/gsadmin/public/logo192.png b/gsadmin/public/logo192.png similarity index 100% rename from src/gsadmin/public/logo192.png rename to gsadmin/public/logo192.png diff --git a/src/gsadmin/public/logo512.png b/gsadmin/public/logo512.png similarity index 100% rename from src/gsadmin/public/logo512.png rename to gsadmin/public/logo512.png diff --git a/src/gsadmin/public/manifest.json b/gsadmin/public/manifest.json similarity index 100% rename from src/gsadmin/public/manifest.json rename to gsadmin/public/manifest.json diff --git a/src/gsadmin/public/robots.txt b/gsadmin/public/robots.txt similarity index 100% rename from src/gsadmin/public/robots.txt rename to gsadmin/public/robots.txt diff --git a/gsadmin/src/App.css b/gsadmin/src/App.css new file mode 100644 index 0000000..3d97c27 --- /dev/null +++ b/gsadmin/src/App.css @@ -0,0 +1,220 @@ +@import url("https://fonts.googleapis.com/css2?family=Squada+One&display=swap"); +@import url("https://fonts.googleapis.com/css2?family=Viga&display=swap"); +@import url("https://fonts.googleapis.com/css2?family=Raleway&display=swap"); +:root { + --secondary-color: #ff4e00; + --dark-color: #2f2838; + --light-color: #fefff9; +} + +* { + margin: 0; + padding: 0; + background-color: transparent; +} + +.gs-error { + text-align: center; + min-height: 100vh; + background-color: transparent; + align-items: center; + justify-content: center; + font-size: calc(10px + 5vmin); + color: #fff; + padding: 20vw 20vh 20vw 20vh; +} + +body { + margin: 0px auto; + justify-content: center; + font-size: calc(10px + 1vmin); + color: #ffffff; + font-family: "Viga", sans-serif; +} + +.container-fluid { + padding-right: 7vw; + padding-left: 7vw; + min-height: 100vh; +} +.gs-raleway { + font-family: 'Raleway'; +} +.gs-about{ + text-align: justify; + padding: 0 10vw; +} + +.gs-container +{ + background-image:linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url("https://images.squarespace-cdn.com/content/v1/5c5c3833840b161566b02a76/1573133725500-Y5PCN0V04I86HDAT8AT0/ke17ZwdGBToddI8pDm48kLkXF2pIyv_F2eUT9F60jBl7gQa3H78H3Y0txjaiv_0fDoOvxcdMmMKkDsyUqMSsMWxHk725yiiHCCLfrh8O1z4YTzHvnKhyp6Da-NYroOW3ZGjoBKy3azqku80C789l0iyqMbMesKd95J-X4EagrgU9L3Sa3U8cogeb0tjXbfawd0urKshkc5MgdBeJmALQKw/WBC_7095.jpg?format=2500w"); + background-repeat: no-repeat; + background-size: cover; + background-position: center; + padding-top: 150px; +} +.gs-container-dark +{ + background-image:linear-gradient(rgba(0,0,0,0.7),rgba(0,0,0,0.7)), url("https://images.squarespace-cdn.com/content/v1/5c5c3833840b161566b02a76/1573133725500-Y5PCN0V04I86HDAT8AT0/ke17ZwdGBToddI8pDm48kLkXF2pIyv_F2eUT9F60jBl7gQa3H78H3Y0txjaiv_0fDoOvxcdMmMKkDsyUqMSsMWxHk725yiiHCCLfrh8O1z4YTzHvnKhyp6Da-NYroOW3ZGjoBKy3azqku80C789l0iyqMbMesKd95J-X4EagrgU9L3Sa3U8cogeb0tjXbfawd0urKshkc5MgdBeJmALQKw/WBC_7095.jpg?format=2500w"); + background-repeat: no-repeat; + background-size: cover; + background-position: center; + padding-top: 150px; +} + +.gs-nav-active { + background-color: #fff; + color: var(--dark-color); + font-weight: 700; + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); +} + +.navbar-dark .navbar-nav .nav-link { + color: rgba(255, 255, 255, 0.9); +} + +.navbar-dark .navbar-nav .nav-link:focus, +.navbar-dark .navbar-nav .nav-link:hover { + color: #fff; +} + +.navbar-dark .navbar-nav .active > .nav-link, +.navbar-dark .navbar-nav .nav-link.active, +.navbar-dark .navbar-nav .nav-link.show, +.navbar-dark .navbar-nav .show > .nav-link { + color: #fff; +} + +.navbar-light .navbar-nav .nav-link { + color: rgba(0, 0, 0, 0.9); +} + +.navbar-light .navbar-nav .nav-link:focus, +.navbar-light .navbar-nav .nav-link:hover { + color: var(--dark-color); +} + +.navbar-light .navbar-nav .active > .nav-link, +.navbar-light .navbar-nav .nav-link.active, +.navbar-light .navbar-nav .nav-link.show, +.navbar-light .navbar-nav .show > .nav-link { + color: #0f0f0f; +} + +/* span{ + font-size: small; +} */ + +.btn-login { + font-size: auto; + background-color: transparent; + border: none; +} + +.btn-nav { + background-color: var(--secondary-color); + color: #ffffff; + padding-left: 3vw; + border: none; + margin: 20px auto; +} + +.i-nav { + margin-left: 3vw; +} + +.line { + display: inline-block; + min-height: 0px; + min-width: 60px; + border: 1px solid white; + margin-bottom: 0.4rem; + background-color: white; +} + +.space { + display: inline-block; + min-height: 0px; + min-width: 65px; +} + +.space-s { + display: inline-block; + min-height: 0px; + min-width: 35px; +} + +/* .box-h{ + background-image: url("/c1.jpg"); + background-repeat: no-repeat; + background-size: 100% 100%; +} */ + +.row-700 { + min-height: 700px; +} + +.btn-profile { + font-size: small; + border: 1px solid transparent; + background-blend-mode: darken; + padding: 0px 10px; +} + +.g { + color: red; + font-size: calc(16px + 5vmin); +} + +.s-active { + color: var(--dark-color); + font-size: calc(16px + 5vmin); +} + +.s { + color: var(--light-color); + font-size: calc(16px + 5vmin); +} + +.media-menu { + background-color: #ffffff; + color: var(--dark-color); + border: 2px solid transparent; + border-radius: 5px; +} + +.login-card { + color: var(--dark-color); + padding: 10px 20px; + position: fixed; + top: 0; + width: 100vw; + height: 100vh; + z-index: 10; +} + +.footer { + background-color: #ffffff; + color: var(--dark-color); + margin: 0px auto; + padding: 20px 0px 20px 0px; +} + +address { + font-size: 80%; + margin: 0px; + color: #0f0f0f; +} + +.gs-body { + min-height: 600px; +} + +.gs-color-dark { + color: var(--dark-color); +} + +/* +.Card { + font-family: 'Raleway'; +} */ diff --git a/src/gsadmin/src/App.js b/gsadmin/src/App.js similarity index 100% rename from src/gsadmin/src/App.js rename to gsadmin/src/App.js diff --git a/src/gsadmin/src/App.test.js b/gsadmin/src/App.test.js similarity index 100% rename from src/gsadmin/src/App.test.js rename to gsadmin/src/App.test.js diff --git a/gsadmin/src/components/Aboutus.js b/gsadmin/src/components/Aboutus.js new file mode 100644 index 0000000..482f9fd --- /dev/null +++ b/gsadmin/src/components/Aboutus.js @@ -0,0 +1,23 @@ +import React from 'react'; +import { Card, CardHeader, CardTitle, CardBody, CardText } from 'reactstrap'; +import { NONE } from 'express-csp-header'; + +function Aboutus(props) { + return ( +
+ +

+ About Us +

+

Our Story

+

+ We're digital nomads, living a digital life! And one thing that we have learned over the course of this evolution is that whatever we want or need, can be obtained with just a few clicks on our beloved smart devices. In this digital life we the students of IIT Indore have tried to make your life more simpler by making a Web App called Greasy Spoon which allows you to search for your favourite Cafe in the campus and their respective dishes. Crowded cafes of the campus have been inconvenient for all of us, and would also have been unsafe because of the current pandemic situation. +

Greasy spoon allows you to order food online, keeping your safety and convenience in mind. Through this medium we can also receive your feedbacks for the dishes and particular cafe in our campus. +This site is created by second year students Akash, Dipin, Siddhesh and Harsh, as part of IITISoC 2020.

+You can give feedback by contacting us, or better yet, contribute to the repository: Our repository +

+
+ ); +} + +export default Aboutus; \ No newline at end of file diff --git a/src/gsadmin/src/components/DishPost.js b/gsadmin/src/components/DishPost.js similarity index 100% rename from src/gsadmin/src/components/DishPost.js rename to gsadmin/src/components/DishPost.js diff --git a/src/gsadmin/src/components/EditDish.js b/gsadmin/src/components/EditDish.js similarity index 86% rename from src/gsadmin/src/components/EditDish.js rename to gsadmin/src/components/EditDish.js index 5533c7e..f35e04e 100644 --- a/src/gsadmin/src/components/EditDish.js +++ b/gsadmin/src/components/EditDish.js @@ -4,9 +4,12 @@ import { baseUrl } from '../shared/baseUrl'; function EditDish(props) { const [dish_name, setName] = useState(props.dish.dish_name); const [price, setPrice] = useState(props.dish.price / 100); - const [description, setDescription] = useState(props.dish.description); - const [featured, setFeatured] = useState(props.dish.featured); - const [category, setCategory] = useState(props.dish.category); + const idescription = props.dish.description ? props.dish.description : ''; + const [description, setDescription] = useState(idescription); + const ifeatured = props.dish.featured ? props.dish.featured : false; + const [featured, setFeatured] = useState(ifeatured); + const icategory = props.dish.category ? props.dish.category : ''; + const [category, setCategory] = useState(icategory); const [dishImage, setImage] = useState(null); function handleSubmit(event) { @@ -67,7 +70,7 @@ function EditDish(props) {
- No image found + Dish Image
diff --git a/src/gsuser/src/components/Footer.js b/gsadmin/src/components/Footer.js similarity index 79% rename from src/gsuser/src/components/Footer.js rename to gsadmin/src/components/Footer.js index ff788a6..1a90481 100644 --- a/src/gsuser/src/components/Footer.js +++ b/gsadmin/src/components/Footer.js @@ -12,7 +12,7 @@ function Footer(props) {
  • Home
  • About Us
  • Menu
  • -
  • Contact Us
  • +
  • Order
  • @@ -29,12 +29,11 @@ function Footer(props) {
    - - - - - - + + + + +
    diff --git a/gsadmin/src/components/HeaderComponent.js b/gsadmin/src/components/HeaderComponent.js new file mode 100644 index 0000000..f9e840a --- /dev/null +++ b/gsadmin/src/components/HeaderComponent.js @@ -0,0 +1,81 @@ +import React, { useState } from 'react'; +import { Navbar, NavbarBrand, Nav, NavbarToggler, Collapse, NavItem} from 'reactstrap'; +import { NavLink } from 'react-router-dom'; +import LoginButton from './LoginButton'; + + +function HeaderComponent(props) { + const [isNavOpen, toggleNavbar] = useState(false); + + const [gsnavbar, setNavbar] = useState(false); + + + const changeNavBg =()=>{ + if(window.scrollY >= 70) + { + setNavbar(true); + }else { + setNavbar(false); + } + } + window.addEventListener('scroll', changeNavBg); + return ( + + +
    + + GREASYSPOON + + toggleNavbar(!isNavOpen)} /> + + + + {props.user != null + ? + + + {props.user.name} + + + : null + } + + + +
    +
    +
    + ); +} + +export default HeaderComponent; \ No newline at end of file diff --git a/gsadmin/src/components/HomeComponent.js b/gsadmin/src/components/HomeComponent.js new file mode 100644 index 0000000..cf0bfef --- /dev/null +++ b/gsadmin/src/components/HomeComponent.js @@ -0,0 +1,45 @@ +import React from 'react'; +import { Button } from 'reactstrap'; +import { Link } from 'react-router-dom'; + +function HomeComponent(props) { + + return ( +
    +
    +
    +

    Discover your taste

    +

    Eat healthy stay wealthy

    + + {props.auth.isAuthenticated + ? + + : + +} + + +

    + + + + + + + + + + +
    +
    +
    + ); +} + +export default HomeComponent; \ No newline at end of file diff --git a/src/gsadmin/src/components/LoadingComponent.js b/gsadmin/src/components/LoadingComponent.js similarity index 100% rename from src/gsadmin/src/components/LoadingComponent.js rename to gsadmin/src/components/LoadingComponent.js diff --git a/src/gsadmin/src/components/LoginButton.js b/gsadmin/src/components/LoginButton.js similarity index 57% rename from src/gsadmin/src/components/LoginButton.js rename to gsadmin/src/components/LoginButton.js index 91f2388..8b38a28 100644 --- a/src/gsadmin/src/components/LoginButton.js +++ b/gsadmin/src/components/LoginButton.js @@ -1,14 +1,10 @@ import React, { useState } from 'react'; -import {Nav, Button, Modal, Card, ModalHeader, NavItem, TabContent, TabPane, ModalBody, Media } from 'reactstrap'; +import { Nav, Button, Modal, Card, ModalHeader, NavItem, TabContent, TabPane, ModalBody, Media } from 'reactstrap'; import SignIn from './SignIn'; -import { NavLink } from 'react-router-dom'; import SignUp from './SignUp'; function LoginButton(props) { - const [loginmodal, setLogin] = useState(false); - const toggleModal = () => { - setLogin(!loginmodal); - } + const [activeTab, setActive] = useState("1"); const toggleTab = tab => { if (activeTab !== tab) @@ -18,33 +14,33 @@ function LoginButton(props) {
    {props.user != null ? - : - } - +
    -
    - -
    -
    - -
    +
    + +
    +
    + +
    - + - + diff --git a/src/gsadmin/src/components/MainComponent.js b/gsadmin/src/components/MainComponent.js similarity index 77% rename from src/gsadmin/src/components/MainComponent.js rename to gsadmin/src/components/MainComponent.js index 5d3687c..e36e5f7 100644 --- a/src/gsadmin/src/components/MainComponent.js +++ b/gsadmin/src/components/MainComponent.js @@ -1,21 +1,16 @@ -import React, { Component } from 'react'; +import React, { Component, useState } from 'react'; import { Switch, Route, Redirect, withRouter } from 'react-router-dom'; import { connect } from 'react-redux'; -import { actions } from 'react-redux-form'; -//import { TransitionGroup, CSSTransition } from 'react-transition-group'; import HeaderComponent from './HeaderComponent'; import HomeComponent from './HomeComponent'; import MenuComponet from './MenuComponent'; -import LoginComponent from './Login'; -import SignUp from './SignUp'; - -import {DISHES} from '../shared/dishes'; import Footer from './Footer'; import {signin, signup, logout, fetchMenu, deleteDish, checkauth, addDishWI, editDishWI, acceptOrder, rejectOrder, completeOrder} from '../redux/ActionCreators'; import OrderPanel from './OrderPanel'; +import Aboutus from './Aboutus'; const mapStateToProps =(state)=>{ return{ @@ -41,7 +36,16 @@ completeOrder: (orderId)=>dispatch(completeOrder(orderId)), }); class Main extends Component { - + constructor(props){ + super(props); + this.state={ + loginmodal: false + } + this.toggleModal = this.toggleModal.bind(this); + } + toggleModal(){ + this.setState({loginmodal: !this.state.loginmodal}); + } componentDidMount(){ if(localStorage.getItem('token') != null) { @@ -50,6 +54,7 @@ class Main extends Component { } render(){ + const PrivateRoute = ({ component: Component, ...rest }) => ( ( @@ -64,13 +69,12 @@ class Main extends Component { return (
    - + - + } /> + } /> } /> - {/*} /> - */}