└── Hungry - Customer
├── src
├── Redux
│ ├── Reducers
│ │ ├── Cart.reducer.js
│ │ ├── Food.reducer.js
│ │ ├── Restaurant.reducer.js
│ │ └── Authentication.reducer.js
│ └── store.js
├── Pages
│ ├── Cart.js
│ ├── Home.js
│ ├── RestaurantDetails.js
│ ├── login.js
│ └── CreateProduct.js
├── Configs
│ ├── Colors.js
│ ├── Icons.js
│ ├── Images.js
│ └── Routes.js
├── index.css
├── setupTests.js
├── App.test.js
├── Elements
│ ├── Cta
│ │ ├── IconButton.js
│ │ └── BasicCta.js
│ ├── Inputs
│ │ └── TextInput
│ │ │ └── TextInput.js
│ ├── Rating
│ │ └── RatingC.js
│ ├── Checks
│ │ └── ChecksC.js
│ └── Select
│ │ └── SelectC.js
├── reportWebVitals.js
├── Components
│ ├── AppBar
│ │ └── Appbar.js
│ ├── Lists
│ │ ├── List.js
│ │ ├── RestaurantListItem.js
│ │ └── FoodListItem.js
│ ├── BottomSheet
│ │ └── BottomSheet.js
│ └── CardSlider
│ │ └── CardSlider.js
├── App.js
├── index.js
├── logo.svg
└── App.css
├── public
├── robots.txt
├── favicon.ico
├── logo192.png
├── logo512.png
├── manifest.json
└── index.html
├── .gitignore
├── package.json
└── README.md
/Hungry - Customer/src/Redux/Reducers/Cart.reducer.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Redux/Reducers/Food.reducer.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Hungry - Customer/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/Hungry - Customer/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vaaluvishnu5146/Hungry/HEAD/Hungry - Customer/public/favicon.ico
--------------------------------------------------------------------------------
/Hungry - Customer/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vaaluvishnu5146/Hungry/HEAD/Hungry - Customer/public/logo192.png
--------------------------------------------------------------------------------
/Hungry - Customer/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vaaluvishnu5146/Hungry/HEAD/Hungry - Customer/public/logo512.png
--------------------------------------------------------------------------------
/Hungry - Customer/src/Pages/Cart.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | export default function Cart() {
4 | return
Cart
;
5 | }
6 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Configs/Colors.js:
--------------------------------------------------------------------------------
1 | export const AppColors = Object.freeze({
2 | primary: "#0f172b",
3 | secondary: "#ee4d2a",
4 | light: "#F2F2F2",
5 | dark: "#000000",
6 | });
7 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/index.css:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | margin: 0px;
4 | padding: 0px;
5 | font-family: "Poppins", sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
--------------------------------------------------------------------------------
/Hungry - Customer/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';
6 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Configs/Icons.js:
--------------------------------------------------------------------------------
1 | import {
2 | ChevronRight,
3 | ShoppingCart,
4 | Menu,
5 | ArrowBack,
6 | Edit,
7 | } from "@mui/icons-material";
8 |
9 | const AppIcons = {
10 | RightArrow: ChevronRight,
11 | Cart: ShoppingCart,
12 | Menu: Menu,
13 | back: ArrowBack,
14 | edit: Edit,
15 | };
16 |
17 | export default AppIcons;
18 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Configs/Images.js:
--------------------------------------------------------------------------------
1 | export const AppImages = Object.freeze({
2 | deliveryBoy:
3 | "https://niceillustrations.com/wp-content/uploads/2020/09/Food-Delivery.png",
4 | mockRestaurant:
5 | "https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cmVzdGF1cmFudHxlbnwwfHwwfHw%3D&w=1000&q=80",
6 | });
7 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Elements/Cta/IconButton.js:
--------------------------------------------------------------------------------
1 | import { IconButton } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function IconCta({
5 | color = "",
6 | label = "",
7 | onClick = () => {},
8 | Icon = null,
9 | }) {
10 | return (
11 |
12 |
13 |
14 | );
15 | }
16 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Redux/store.js:
--------------------------------------------------------------------------------
1 | import { configureStore } from "@reduxjs/toolkit";
2 | // ROOT REDUCER
3 | import AuthenticationReducer from "./Reducers/Authentication.reducer";
4 | import RestaurantReducer from "./Reducers/Restaurant.reducer";
5 |
6 | export default configureStore({
7 | // ROOT REDUCER
8 | reducer: {
9 | authentication: AuthenticationReducer,
10 | restaurant: RestaurantReducer,
11 | },
12 | });
13 |
--------------------------------------------------------------------------------
/Hungry - Customer/.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 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Components/AppBar/Appbar.js:
--------------------------------------------------------------------------------
1 | import { Box } from "@mui/material";
2 | import React from "react";
3 | import IconCta from "../../Elements/Cta/IconButton";
4 |
5 | export default function Appbar({
6 | prefix = null,
7 | content = null,
8 | suffix = null,
9 | }) {
10 | return (
11 |
12 | {prefix}
13 | {content}
14 | {suffix}
15 |
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Elements/Cta/BasicCta.js:
--------------------------------------------------------------------------------
1 | import { Button } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function BasicCta({
5 | label = "",
6 | id = "",
7 | overrides = {},
8 | fullWidth = false,
9 | handleClick = () => {},
10 | }) {
11 | return (
12 |
22 | );
23 | }
24 |
--------------------------------------------------------------------------------
/Hungry - Customer/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 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Components/Lists/List.js:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import List from "@mui/material/List";
3 | import ListItemBasic from "../Lists/RestaurantListItem";
4 |
5 | export default function BasicList({ data = [], id = "", ListItem = null }) {
6 | return (
7 |
8 | {data && data.length > 0 ? (
9 | data.map(
10 | (data, index) =>
11 | ListItem &&
12 | )
13 | ) : (
14 | No data found
15 | )}
16 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Elements/Inputs/TextInput/TextInput.js:
--------------------------------------------------------------------------------
1 | import { TextField } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function TextInput({
5 | type = "text",
6 | placeholder = "",
7 | value = "",
8 | onChange = (e) => {},
9 | id = "",
10 | name = "",
11 | label = "",
12 | variant = "outlined",
13 | overrides = {},
14 | }) {
15 | return (
16 |
27 | );
28 | }
29 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Elements/Rating/RatingC.js:
--------------------------------------------------------------------------------
1 | import { Rating } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function RatingC({
5 | value = 1,
6 | onChange = (e) => {},
7 | readOnly = false,
8 | disabled = false,
9 | id = "",
10 | name = "",
11 | size = "small", // small, medium, large
12 | }) {
13 | return (
14 | {
19 | e.target.id = id;
20 | e.target.name = name;
21 | onChange(e);
22 | }}
23 | readOnly={readOnly}
24 | disabled={disabled}
25 | size={size}
26 | />
27 | );
28 | }
29 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Elements/Checks/ChecksC.js:
--------------------------------------------------------------------------------
1 | import { Checkbox, FormControlLabel, FormGroup } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function CheckC({
5 | label = "",
6 | checked = false,
7 | id = "",
8 | name = "",
9 | onChange = (e) => {},
10 | }) {
11 | return (
12 |
13 | }
15 | label={label}
16 | onChange={(e) =>
17 | onChange({
18 | ...e,
19 | target: {
20 | ...e.target,
21 | id: id,
22 | name: name,
23 | type: "checkbox",
24 | },
25 | })
26 | }
27 | />
28 |
29 | );
30 | }
31 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import { Route, Routes } from "react-router-dom";
3 | import "./App.css";
4 | import { openRoutes, closedRoutes } from "./Configs/Routes";
5 | import { useSelector } from "react-redux";
6 |
7 | function App() {
8 | const { isLoggedIn } = useSelector((state) => state.authentication);
9 | return (
10 |
11 |
12 | {isLoggedIn
13 | ? closedRoutes.map((route) => (
14 |
15 | ))
16 | : openRoutes.map((route) => (
17 |
18 | ))}
19 |
20 |
21 | );
22 | }
23 |
24 | export default App;
25 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Components/BottomSheet/BottomSheet.js:
--------------------------------------------------------------------------------
1 | import { Box, Button, Drawer } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function BottomSheet({
5 | children,
6 | anchor = "bottom",
7 | id = "",
8 | toggleDrawer = (type = "", state = false) => {},
9 | isOpen = false,
10 | }) {
11 | return (
12 |
13 | toggleDrawer(id, false)}
17 | >
18 |
25 | {children}
26 |
27 |
28 |
29 | );
30 | }
31 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Redux/Reducers/Restaurant.reducer.js:
--------------------------------------------------------------------------------
1 | import { createSlice } from "@reduxjs/toolkit";
2 |
3 | export const RestaurantReducer = createSlice({
4 | name: "restaurant",
5 | initialState: {
6 | data: [],
7 | trendingRestaurants: [],
8 | servingToday: [],
9 | },
10 | reducers: {
11 | saveRestaurants: (state, action) => {
12 | if (action.payload) {
13 | state.data = action.payload;
14 | state.trendingRestaurants = action.payload.filter(
15 | (data) => data.generalDetails.trending
16 | );
17 | state.servingToday = action.payload.filter(
18 | (data) => data.generalDetails.isOpen
19 | );
20 | }
21 | },
22 | },
23 | });
24 |
25 | // Action creators are generated for each case reducer function
26 | export const { saveRestaurants } = RestaurantReducer.actions;
27 | export default RestaurantReducer.reducer;
28 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Redux/Reducers/Authentication.reducer.js:
--------------------------------------------------------------------------------
1 | import { createSlice } from "@reduxjs/toolkit";
2 |
3 | export const AuthenticationReducer = createSlice({
4 | name: "authentication",
5 | initialState: {
6 | isLoggedIn: false,
7 | user: null,
8 | isUser: false,
9 | isAdmin: false,
10 | isSuperAdmin: false,
11 | },
12 | reducers: {
13 | saveLoggedInUser: (state, action) => {
14 | if (action.payload && action.payload._id) {
15 | state.isLoggedIn = true;
16 | state.user = action.payload;
17 | state.isUser = action.payload.generalDetails.roles.indexOf("user") > -1;
18 | state.isAdmin =
19 | action.payload.generalDetails.roles.indexOf("admin") > -1;
20 | state.isSuperAdmin =
21 | action.payload.generalDetails.roles.indexOf("superAdmin") > -1;
22 | }
23 | },
24 | },
25 | });
26 |
27 | // Action creators are generated for each case reducer function
28 | export const { saveLoggedInUser } = AuthenticationReducer.actions;
29 | export default AuthenticationReducer.reducer;
30 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Configs/Routes.js:
--------------------------------------------------------------------------------
1 | import Login from "../Pages/login";
2 | import Home from "../Pages/Home";
3 | import RestaurantDetails from "../Pages/RestaurantDetails";
4 | import Cart from "../Pages/Cart";
5 | import CreateProduct from "../Pages/CreateProduct";
6 |
7 | export const openRoutes = [
8 | {
9 | name: "Login | Signup",
10 | id: "login",
11 | Component: ,
12 | path: "/",
13 | },
14 | ];
15 |
16 | export const closedRoutes = [
17 | {
18 | name: "Home | For Hungry people",
19 | id: "home",
20 | Component: ,
21 | path: "/",
22 | },
23 | {
24 | name: "Restaurant Details | For Hungry people",
25 | id: "restaurantDetails",
26 | Component: ,
27 | path: "/restaurant/:id",
28 | },
29 | {
30 | name: "Cart | For Hungry people",
31 | id: "cartDetails",
32 | Component: ,
33 | path: "/cart/:id",
34 | },
35 | {
36 | name: "Create Product | For a Restaurant",
37 | id: "createProduct",
38 | Component: ,
39 | path: "/createProduct/:id",
40 | },
41 | ];
42 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Elements/Select/SelectC.js:
--------------------------------------------------------------------------------
1 | import { FormControl, InputLabel, MenuItem, Select } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function SelectC({
5 | handleChange = (e) => {},
6 | label = "",
7 | id = "",
8 | options = [],
9 | overrides = {},
10 | value = "",
11 | name = "",
12 | }) {
13 | return (
14 |
15 | {label}
16 |
39 |
40 | );
41 | }
42 |
--------------------------------------------------------------------------------
/Hungry - Customer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hungry",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@emotion/react": "^11.11.0",
7 | "@emotion/styled": "^11.11.0",
8 | "@fontsource/roboto": "^4.5.8",
9 | "@mui/icons-material": "^5.11.16",
10 | "@mui/material": "^5.12.3",
11 | "@reduxjs/toolkit": "^1.8.5",
12 | "@testing-library/jest-dom": "^5.16.5",
13 | "@testing-library/react": "^13.4.0",
14 | "@testing-library/user-event": "^13.5.0",
15 | "axios": "^1.4.0",
16 | "react": "^18.2.0",
17 | "react-dom": "^18.2.0",
18 | "react-redux": "^8.0.4",
19 | "react-router-dom": "^6.7.0",
20 | "react-scripts": "5.0.1",
21 | "web-vitals": "^2.1.4"
22 | },
23 | "scripts": {
24 | "start": "react-scripts start",
25 | "build": "react-scripts build",
26 | "test": "react-scripts test",
27 | "eject": "react-scripts eject"
28 | },
29 | "eslintConfig": {
30 | "extends": [
31 | "react-app",
32 | "react-app/jest"
33 | ]
34 | },
35 | "browserslist": {
36 | "production": [
37 | ">0.2%",
38 | "not dead",
39 | "not op_mini all"
40 | ],
41 | "development": [
42 | "last 1 chrome version",
43 | "last 1 firefox version",
44 | "last 1 safari version"
45 | ]
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom/client";
3 | import App from "./App";
4 | import reportWebVitals from "./reportWebVitals";
5 | import { BrowserRouter as Router } from "react-router-dom";
6 | import { Provider } from "react-redux";
7 | import store from "./Redux/store";
8 | import { ThemeProvider, createTheme } from "@mui/material/styles";
9 | import { AppColors } from "./Configs/Colors";
10 |
11 | let theme = createTheme({
12 | palette: {
13 | primary: {
14 | main: AppColors.primary,
15 | },
16 | secondary: {
17 | main: AppColors.secondary,
18 | },
19 | },
20 | });
21 |
22 | theme = createTheme(theme, {
23 | palette: {
24 | info: {
25 | main: theme.palette.secondary.main,
26 | },
27 | },
28 | });
29 |
30 | const root = ReactDOM.createRoot(document.getElementById("root"));
31 | root.render(
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | );
40 |
41 | // If you want to start measuring performance in your app, pass a function
42 | // to log results (for example: reportWebVitals(console.log))
43 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
44 | reportWebVitals();
45 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Components/Lists/RestaurantListItem.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {
3 | Box,
4 | ListItem,
5 | ListItemButton,
6 | ListItemIcon,
7 | ListItemText,
8 | Typography,
9 | } from "@mui/material";
10 | import AppIcons from "../../Configs/Icons";
11 | import { AppImages } from "../../Configs/Images";
12 | import RatingC from "../../Elements/Rating/RatingC";
13 | import { useNavigate } from "react-router-dom";
14 |
15 | export default function RestaurantListItem({ data = {} }) {
16 | const navigator = useNavigate();
17 |
18 | return (
19 | navigator(`/restaurant/${data._id}`)}
23 | >
24 |
25 |
33 |
34 |
35 |
36 | {data.restaurantName}
37 |
38 |
39 | {data.addressDetails.city}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | );
50 | }
51 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Components/Lists/FoodListItem.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {
3 | Box,
4 | ListItem,
5 | ListItemButton,
6 | ListItemIcon,
7 | Typography,
8 | } from "@mui/material";
9 | import AppIcons from "../../Configs/Icons";
10 | import RatingC from "../../Elements/Rating/RatingC";
11 |
12 | export default function FoodListItem({ data = {} }) {
13 | return (
14 | {}}>
15 |
16 |
24 |
25 |
26 |
27 | {data.name}
28 |
29 | {data.description}
30 |
31 |
36 |
43 | {data.pricingDetails.actualPrice}
44 |
45 |
46 | {data.pricingDetails.actualOfferPrice}
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | );
57 | }
58 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Components/CardSlider/CardSlider.js:
--------------------------------------------------------------------------------
1 | import { Box, Chip, Typography } from "@mui/material";
2 | import React from "react";
3 |
4 | export default function CardCarouselSlider({ data = [] }) {
5 | return (
6 |
7 |
8 | Trending Restaurants
9 |
10 |
11 | {data &&
12 | data.length > 0 &&
13 | data.map((_d, i) => (
14 |
15 |
21 |
22 |
23 |
24 | {}}
28 | sx={{
29 | color: "#FFFFFF",
30 | height: "20px",
31 | }}
32 | />
33 |
34 |
35 |
40 | {_d.restaurantName}
41 |
42 |
43 | HSR LAYOUT
44 |
45 |
46 |
47 |
48 |
49 |
50 | ))}
51 |
52 |
53 | );
54 | }
55 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Pages/Home.js:
--------------------------------------------------------------------------------
1 | import { Box, Typography } from "@mui/material";
2 | import React, { useState, useEffect } from "react";
3 | import CardSlider from "../Components/CardSlider/CardSlider";
4 | import Appbar from "../Components/AppBar/Appbar";
5 | import IconCta from "../Elements/Cta/IconButton";
6 | import { useNavigate } from "react-router-dom";
7 | import BasicList from "../Components/Lists/List";
8 | import { saveRestaurants } from "../Redux/Reducers/Restaurant.reducer";
9 | import { useSelector, useDispatch } from "react-redux";
10 | import AppIcons from "../Configs/Icons";
11 | import RestaurantListItem from "../Components/Lists/RestaurantListItem";
12 | import axios from "axios";
13 |
14 | export default function Home() {
15 | const navigator = useNavigate();
16 | const dispatcher = useDispatch();
17 | const { trendingRestaurants, servingToday } = useSelector(
18 | (state) => state.restaurant
19 | );
20 |
21 | useEffect(() => {
22 | axios
23 | .get("http://localhost:5000/api/restaurants/getAllRestaurants")
24 | .then((response) => {
25 | const { data } = response.data.result;
26 | if (response && data.length > 0) {
27 | dispatcher(saveRestaurants(data));
28 | }
29 | })
30 | .catch((error) => console.log(error));
31 | }, []);
32 |
33 | return (
34 |
35 | {}} Icon={AppIcons.Menu} />}
37 | content={
38 |
39 | Home Page
40 |
41 | }
42 | suffix={
43 | navigator("/cart/8382463g")}
45 | Icon={AppIcons.Cart}
46 | />
47 | }
48 | />
49 |
50 |
51 |
52 |
53 |
54 |
55 | Other Restaurants
56 |
57 |
58 |
59 |
60 |
61 | );
62 | }
63 |
--------------------------------------------------------------------------------
/Hungry - Customer/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 |
28 |
29 |
33 | Hungry | For People always hungry
34 |
35 |
36 |
37 |
38 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Pages/RestaurantDetails.js:
--------------------------------------------------------------------------------
1 | import { Box, Typography } from "@mui/material";
2 | import React, { useState, useEffect } from "react";
3 | import Appbar from "../Components/AppBar/Appbar";
4 | import IconCta from "../Elements/Cta/IconButton";
5 | import AppIcons from "../Configs/Icons";
6 | import { useNavigate, useParams } from "react-router-dom";
7 | import { useSelector } from "react-redux";
8 | import { AppImages } from "../Configs/Images";
9 | import BasicList from "../Components/Lists/List";
10 | import FoodListItem from "../Components/Lists/FoodListItem";
11 |
12 | export default function RestaurantDetails() {
13 | const navigator = useNavigate();
14 | const params = useParams();
15 | const [food, setFood] = useState();
16 | const { isAdmin } = useSelector((state) => state.authentication);
17 | useEffect(() => {
18 | // GETTING RESTAURANT ID FROM URL PARAMS
19 | if (params["id"]) {
20 | fetch(`http://localhost:5000/api/food/getAllFood/${params["id"]}`)
21 | .then((response) => response.json())
22 | .then((data) => {
23 | const { success, result, message } = data;
24 | if (success && result.count > 0) {
25 | setFood(result.data);
26 | }
27 | })
28 | .catch((error) => console.log(error));
29 | } else {
30 | alert("Restaurant id missing");
31 | }
32 | }, []);
33 | return (
34 |
35 | navigator(-1)} Icon={AppIcons.back} />}
37 | content={
38 |
39 | Restaurant
40 |
41 | }
42 | suffix={
43 | isAdmin && (
44 |
46 | navigator(`/createProduct/${params["id"]}?mode=create"`)
47 | }
48 | Icon={AppIcons.edit}
49 | />
50 | )
51 | }
52 | />
53 |
54 |
59 |
60 |
61 |
62 |
63 |
64 | );
65 | }
66 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Hungry - Customer/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | 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.
37 |
38 | 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.
39 |
40 | 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.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/App.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --primary: #0f172b;
3 | --secondary: #ee4d2a;
4 | }
5 |
6 | html,
7 | body {
8 | margin: 0px;
9 | padding: 0px;
10 | font-family: "Poppins", sans-serif !important;
11 | -webkit-font-smoothing: antialiased;
12 | -moz-osx-font-smoothing: grayscale;
13 | }
14 |
15 | .App {
16 | text-align: center;
17 | }
18 |
19 | .App-logo {
20 | height: 40vmin;
21 | pointer-events: none;
22 | }
23 |
24 | @media (prefers-reduced-motion: no-preference) {
25 | .App-logo {
26 | animation: App-logo-spin infinite 20s linear;
27 | }
28 | }
29 |
30 | .App-header {
31 | background-color: #282c34;
32 | min-height: 100vh;
33 | display: flex;
34 | flex-direction: column;
35 | align-items: center;
36 | justify-content: center;
37 | font-size: calc(10px + 2vmin);
38 | color: white;
39 | }
40 |
41 | .App-link {
42 | color: #61dafb;
43 | }
44 |
45 | @keyframes App-logo-spin {
46 | from {
47 | transform: rotate(0deg);
48 | }
49 | to {
50 | transform: rotate(360deg);
51 | }
52 | }
53 |
54 | .App-container {
55 | width: 100%;
56 | max-width: 560px;
57 | height: 100vh;
58 |
59 | margin: 0px auto;
60 | }
61 |
62 | /* LOGIN PAGE */
63 |
64 | .login-page {
65 | background: #0f172b;
66 | > .login-header {
67 | width: 100%;
68 | height: calc(100vh / 2);
69 | background-position: center;
70 | background-repeat: no-repeat;
71 | background-size: contain;
72 | }
73 |
74 | > .login-body {
75 | padding: 10px 20px;
76 | }
77 | }
78 |
79 | /* HOME PAGE */
80 |
81 | .home-page-content {
82 | padding: 10px 15px;
83 | }
84 |
85 | .heading {
86 | text-align: start;
87 | font-weight: bolder !important;
88 | margin-bottom: 5px;
89 | }
90 |
91 | /* CARD SLIDER CONTAINER */
92 | .carousel-slider {
93 | > .card-slider-container {
94 | position: relative;
95 | display: flex;
96 | align-items: center;
97 | flex-wrap: nowrap;
98 | overflow-x: scroll;
99 |
100 | > .card-wrapper {
101 | min-width: 50%;
102 | height: 280px;
103 | padding: 10px;
104 | box-sizing: border-box;
105 |
106 | > .card {
107 | position: relative;
108 | width: 100%;
109 | height: 100%;
110 | border-radius: 10px;
111 | background-position: center;
112 | background-size: cover;
113 | display: flex;
114 | flex-direction: column;
115 |
116 | > .card-content {
117 | width: 100%;
118 | height: 100%;
119 | z-index: 1;
120 |
121 | > .card-header {
122 | height: 50px;
123 | padding: 10px 10px;
124 | display: flex;
125 | align-items: start;
126 | }
127 | > .card-body {
128 | height: calc(100% - 100px);
129 | display: flex;
130 | align-items: start;
131 | justify-content: end;
132 | flex-direction: column;
133 | padding: 10px 10px;
134 | }
135 | > .card-footer {
136 | height: 50px;
137 | }
138 | }
139 | > .overlay {
140 | position: absolute;
141 | top: 0;
142 | left: 0;
143 | bottom: 0;
144 | right: 0;
145 | background: linear-gradient(
146 | rgba(27, 30, 36, 0) 0%,
147 | rgb(27, 30, 36) 84.21%
148 | );
149 | z-index: 0;
150 | border-radius: 10px;
151 | }
152 | }
153 | }
154 | }
155 | }
156 |
157 | /* APP HEADR */
158 |
159 | .app-header {
160 | width: 100%;
161 | height: 60px;
162 | display: flex;
163 | align-items: center;
164 | > .prefix {
165 | width: 80px;
166 | }
167 | > .content {
168 | width: calc(100% - 160px);
169 | }
170 | > .suffix {
171 | width: 80px;
172 | }
173 | }
174 |
175 | /* LIST ITEM */
176 |
177 | .list-item {
178 | > .list-item-button {
179 | > .list-body {
180 | width: 100%;
181 | > img {
182 | width: 120px;
183 | height: 100%;
184 | object-fit: contain;
185 | border-radius: 10px;
186 | margin-right: 10px;
187 | }
188 | > .list-body-content {
189 | width: calc(100% - 120px - 50px);
190 | display: flex;
191 | flex-direction: column;
192 | justify-content: center;
193 | }
194 | }
195 | }
196 | }
197 |
198 | /* RESTAURANT DETAILS */
199 |
200 | .restaurant-page {
201 | position: relative;
202 | width: 100%;
203 | height: 100vh;
204 | > .restaurant-body {
205 | width: 100%;
206 | > .restaurant-images {
207 | width: 100%;
208 | height: 200px;
209 | object-fit: cover;
210 | }
211 | }
212 | }
213 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Pages/login.js:
--------------------------------------------------------------------------------
1 | import { Box, TextField, Typography } from "@mui/material";
2 | import React, { useState } from "react";
3 | import { AppImages } from "../Configs/Images";
4 | import BasicCta from "../Elements/Cta/BasicCta";
5 | import { AppColors } from "../Configs/Colors";
6 | import { useNavigate } from "react-router-dom";
7 | import { useSelector, useDispatch } from "react-redux";
8 | import { saveLoggedInUser } from "../Redux/Reducers/Authentication.reducer";
9 | import BottomSheet from "../Components/BottomSheet/BottomSheet";
10 | import TextInput from "../Elements/Inputs/TextInput/TextInput";
11 |
12 | export default function Login() {
13 | const navigator = useNavigate();
14 | const dispatcher = useDispatch();
15 | const [loginFormData, setLoginFormData] = useState({});
16 | const [loginDrawer, setLoginDrawer] = useState(false);
17 | const [signupDrawer, setSignupDrawer] = useState(false);
18 | const state = useSelector((state) => state.authentication);
19 |
20 | const handleAuthentication = (type = "") => {
21 | if (type === "signin") {
22 | dispatcher(
23 | saveLoggedInUser({
24 | userName: "Vishnu",
25 | role: ["customer"],
26 | })
27 | );
28 | navigator("/");
29 | }
30 | };
31 |
32 | const handleDrawer = (type = "", state = false) => {
33 | if (state) {
34 | type === "login" ? setLoginDrawer(state) : setSignupDrawer(state);
35 | } else {
36 | type === "login" ? setLoginDrawer(state) : setSignupDrawer(state);
37 | }
38 | };
39 |
40 | const handleLoginForm = (e) => {
41 | if (e) {
42 | let loginFormCopy = {
43 | ...loginFormData,
44 | [e.target.id]: e.target.value,
45 | };
46 | setLoginFormData(loginFormCopy);
47 | }
48 | };
49 |
50 | const handleLogin = (e) => {
51 | if (e) {
52 | fetch("http://localhost:5000/api/auth/signin", {
53 | method: "POST",
54 | body: JSON.stringify(loginFormData),
55 | headers: {
56 | "Content-Type": "application/json",
57 | },
58 | })
59 | .then((response) => response.json())
60 | .then((result) => {
61 | console.log(result);
62 | if (result.success) {
63 | dispatcher(saveLoggedInUser(result.data));
64 | handleDrawer("login", false);
65 | }
66 | })
67 | .catch((error) => console.log(error));
68 | }
69 | };
70 |
71 | return (
72 |
73 |
79 |
80 |
87 | The experience of delivering food quickly
88 |
89 |
96 | For the all time hungry person
97 |
98 | handleAuthentication("signup")}
108 | />
109 | handleDrawer("login", true)}
119 | />
120 |
126 |
127 | Login
128 |
129 |
136 | And enjoy food from your favourite restaurant
137 |
138 |
150 |
162 |
171 |
172 |
173 |
174 | );
175 | }
176 |
--------------------------------------------------------------------------------
/Hungry - Customer/src/Pages/CreateProduct.js:
--------------------------------------------------------------------------------
1 | import { Box, Typography } from "@mui/material";
2 | import React, { useReducer } from "react";
3 | import Appbar from "../Components/AppBar/Appbar";
4 | import IconCta from "../Elements/Cta/IconButton";
5 | import AppIcons from "../Configs/Icons";
6 | import { useNavigate, useParams } from "react-router-dom";
7 | import TextInput from "../Elements/Inputs/TextInput/TextInput";
8 | import SelectC from "../Elements/Select/SelectC";
9 | import CheckC from "../Elements/Checks/ChecksC";
10 | import RatingC from "../Elements/Rating/RatingC";
11 | import BasicCta from "../Elements/Cta/BasicCta";
12 | import axios from "axios";
13 |
14 | // STEPS TO USEREDUCER
15 | // 1. Create InitialState
16 | // 2. Create Reducer
17 | // 3. Create Instance of useReducer inside component
18 | const initialState = {
19 | name: "",
20 | picture: [
21 | "https://t1.gstatic.com/licensed-image?q=tbn:ANd9GcQPir0f1BHnKzF0oJ40_GjHM6Z0xD5ZfMcrB96lulVvf2dwYa8w3-Scmt3AZMVg5bXT",
22 | ],
23 | description: "",
24 | restaurantId: null,
25 | generalDetails: {
26 | cuisine: "",
27 | foodType: "",
28 | trending: false,
29 | averageRating: 0,
30 | },
31 | pricingDetails: {
32 | actualPrice: "",
33 | actualOfferPrice: "",
34 | },
35 | };
36 |
37 | const reducer = (state, action) => {
38 | switch (action.type) {
39 | case "generalDetails":
40 | return {
41 | ...state,
42 | generalDetails: {
43 | ...state.generalDetails,
44 | [action.id]: action.value,
45 | },
46 | };
47 | case "pricingDetails":
48 | return {
49 | ...state,
50 | pricingDetails: {
51 | ...state.pricingDetails,
52 | [action.id]: action.value,
53 | },
54 | };
55 | default:
56 | return {
57 | ...state,
58 | [action.id]: action.value,
59 | };
60 | }
61 | };
62 |
63 | export default function CreateProduct() {
64 | const [formState, dispatch] = useReducer(reducer, initialState);
65 | const params = useParams();
66 | const navigator = useNavigate();
67 |
68 | const handleInput = (e) => {
69 | if (e) {
70 | e.target.type && e.target.type === "checkbox"
71 | ? dispatch({
72 | type: e.target.name,
73 | id: e.target.id,
74 | value: !formState.generalDetails.trending,
75 | })
76 | : dispatch({
77 | type: e.target.name,
78 | id: e.target.id,
79 | value: e.target.value,
80 | });
81 | }
82 | };
83 |
84 | const handleSubmit = async (e) => {
85 | const response = await axios.post("http://localhost:5000/api/food/create", {
86 | ...formState,
87 | restaurantId: params["id"],
88 | });
89 | console.log(response);
90 | };
91 |
92 | return (
93 |
94 | navigator(-1)} Icon={AppIcons.back} />}
96 | content={
97 |
98 | Create Food
99 |
100 | }
101 | />
102 |
108 |
121 |
134 |
140 | General Details
141 |
142 |
158 |
172 |
188 |
193 |
194 | Trending Today?
195 |
196 |
197 |
204 |
210 |
211 | Restaurant Rating
212 |
213 |
214 |
220 |
227 |
228 |
234 | Pricing Details
235 |
236 |
249 |
262 |
271 |
272 |
273 | );
274 | }
275 |
--------------------------------------------------------------------------------