├── jest.setup.js ├── __mock__ └── fileMock.js ├── src ├── Images │ ├── Dao.PNG │ ├── Kirksey.PNG │ ├── Rennie.PNG │ ├── Yeung.PNG │ └── Esposito.PNG ├── scss │ ├── variables.scss │ ├── navVariables.scss │ ├── App.scss │ ├── index.scss │ ├── _loading.scss │ ├── _contact.scss │ ├── _login.scss │ ├── Navbar.module.scss │ └── _signup.scss ├── index.js └── components │ ├── Iframe.jsx │ ├── LoadingCube.jsx │ ├── App.jsx │ ├── ContactCard.jsx │ ├── Dashboard.jsx │ ├── Contact.jsx │ ├── Navbar.jsx │ ├── Signup.jsx │ └── Login.jsx ├── public └── gifs │ ├── register.gif │ ├── customize.gif │ └── installation.gif ├── .babelrc ├── index.html ├── server ├── database │ └── db.config.js ├── models │ └── userModel.js ├── routes │ └── userRoutes.js ├── server.js ├── controllers │ ├── userController.js │ ├── dashboardController.js │ └── installController.js └── dashJSONfiles │ └── dashboardTemplating.json ├── .gitignore ├── jest.config.js ├── prometheus-grafana.yaml ├── .eslintrc.json ├── LICENSE ├── webpack.config.js ├── __tests__ └── react │ ├── Navbar.test.js │ ├── App.test.js │ ├── Signup.test.js │ └── Login.test.js ├── package.json ├── README.md └── logs.txt /jest.setup.js: -------------------------------------------------------------------------------- 1 | import '@testing-library/jest-dom'; 2 | -------------------------------------------------------------------------------- /__mock__/fileMock.js: -------------------------------------------------------------------------------- 1 | module.exports = "test-file-stub"; -------------------------------------------------------------------------------- /src/Images/Dao.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/src/Images/Dao.PNG -------------------------------------------------------------------------------- /src/Images/Kirksey.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/src/Images/Kirksey.PNG -------------------------------------------------------------------------------- /src/Images/Rennie.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/src/Images/Rennie.PNG -------------------------------------------------------------------------------- /src/Images/Yeung.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/src/Images/Yeung.PNG -------------------------------------------------------------------------------- /public/gifs/register.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/public/gifs/register.gif -------------------------------------------------------------------------------- /src/Images/Esposito.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/src/Images/Esposito.PNG -------------------------------------------------------------------------------- /public/gifs/customize.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/public/gifs/customize.gif -------------------------------------------------------------------------------- /public/gifs/installation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/KuView/HEAD/public/gifs/installation.gif -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env", "@babel/preset-react"], 3 | "plugins": ["babel-plugin-styled-components"] 4 | } 5 | -------------------------------------------------------------------------------- /src/scss/variables.scss: -------------------------------------------------------------------------------- 1 | // //UTILS 2 | $primary: #121212; 3 | 4 | // // MEDIA QUERIES 5 | @mixin mobile { 6 | @media screen and (max-width: 480px) { 7 | @content; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | KuView 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /server/database/db.config.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | 3 | const mongoose = require('mongoose'); 4 | 5 | async function connectToDb() { 6 | try { 7 | await mongoose.connect(process.env.MONGO_URI); 8 | console.log('DB connection complete'); 9 | } catch (err) { 10 | console.log(err); 11 | } 12 | } 13 | 14 | module.exports = connectToDb; 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | pnpm-debug.log* 6 | lerna-debug.log* 7 | 8 | node_modules 9 | build 10 | dist 11 | dist-ssr 12 | *.local 13 | .env 14 | # Editor directories and files 15 | .vscode/* 16 | !.vscode/extensions.json 17 | .idea 18 | .DS_Store 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | package-lock.json 25 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | collectCoverage: false, 3 | collectCoverageFrom: ['src/**/*.{js,jsx}'], 4 | coverageDirectory: '__tests__', 5 | testEnvironment: 'jsdom', 6 | setupFilesAfterEnv: ['/jest.setup.js'], 7 | moduleNameMapper: { 8 | '\\.scss$': 'identity-obj-proxy', 9 | "\\.(PNG|png|jpg|jpeg|gif|svg)$": "/__mock__/fileMock.js", 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { createRoot } from 'react-dom/client'; 3 | import App from './components/App.jsx'; 4 | import styles from './scss/App.scss'; 5 | import { BrowserRouter } from 'react-router-dom'; 6 | 7 | // react render 8 | const root = createRoot(document.getElementById('root')); 9 | root.render( 10 | 11 | 12 | 13 | ); 14 | -------------------------------------------------------------------------------- /src/components/Iframe.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Iframe = (props) => { 4 | // console.log('prop in iframe', props); 5 | return ( 6 |
7 | 12 |
13 | ); 14 | }; 15 | 16 | export default Iframe; 17 | -------------------------------------------------------------------------------- /prometheus-grafana.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: prometheus-grafana 5 | namespace: default 6 | labels: 7 | app.kubernetes.io/instance: prometheus 8 | app.kubernetes.io/managed-by: Helm 9 | app.kubernetes.io/name: grafana 10 | app.kubernetes.io/version: 10.0.1 11 | helm.sh/chart: grafana-6.58.2 12 | data: 13 | grafana.ini: 14 | "[security] \nallow_embedding = true\n[auth.anonymous] \nenabled = true \norg_role 15 | = Admin\n[users] \ndefault_org_role = Admin" 16 | -------------------------------------------------------------------------------- /src/scss/navVariables.scss: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Handjet&display=swap'); 2 | 3 | $Handjet-font: 'Handjet', cursive; 4 | 5 | $bg: rgb(255, 255, 255); 6 | $bg2: rgb(0, 0, 0); 7 | $text: rgb(15, 15, 15); 8 | $text2: rgb(240, 240, 240); 9 | $primary: #5069ff; 10 | 11 | $spacing-sm: 8px; 12 | $spacing-md: 16px; 13 | $spacing-lg: 32px; 14 | 15 | $header-height: 72px; 16 | 17 | $sm: 37.5em; 18 | $md: 48em; 19 | $lg: 64em; 20 | $x1: 75em; 21 | 22 | @mixin breakpoint($point) { 23 | @if $point == md { 24 | @media (min-width: $md) { 25 | @content; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/components/LoadingCube.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const LoadingCube = () => { 4 | return ( 5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |

Loading Metrics...

18 |
19 |
20 | ); 21 | }; 22 | 23 | export default LoadingCube; 24 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "jest/globals": true 6 | }, 7 | "extends": [ 8 | "plugin:react/recommended", 9 | "plugin:jest/recommended", 10 | "airbnb", 11 | "prettier" 12 | ], 13 | "parserOptions": { 14 | "ecmaFeatures": { 15 | "jsx": true 16 | }, 17 | "ecmaVersion": "latest", 18 | "sourceType": "module" 19 | }, 20 | "plugins": ["react", "jest"], 21 | "rules": { 22 | "no-underscore-dangle": 0, 23 | "import/extensions": [ 24 | "error", 25 | "ignorePackages", 26 | { 27 | "js": "always", 28 | "jsx": "always" 29 | } 30 | ] 31 | } 32 | } -------------------------------------------------------------------------------- /src/scss/App.scss: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600&display=swap'); 2 | @import '_loading'; 3 | @import '_login'; 4 | @import '_signup'; 5 | @import 'variables.scss'; 6 | @import 'navVariables.scss'; 7 | @import '_contact.scss'; 8 | 9 | * { 10 | margin: 0; 11 | padding: 0; 12 | box-sizing: border-box; 13 | text-decoration: none; 14 | } 15 | 16 | html { 17 | font-size: 100%; 18 | } 19 | body { 20 | background-color: $bg2; 21 | height: 100%; 22 | font-family: 'Montserrat', sans-serif, system-ui, -apple-system, 23 | BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 24 | 'Open Sans', 'Helvetica Neue', sans-serif; 25 | } 26 | 27 | .iframe-container { 28 | width: 100%; 29 | height: 100vh; 30 | iframe { 31 | margin-top: 4.55em; 32 | width: 100%; 33 | height: 100%; 34 | border: none; 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /server/models/userModel.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const SALT_WORK_FACTOR = 10; 5 | const bcrypt = require('bcryptjs'); 6 | 7 | const userSchema = new Schema({ 8 | username: { type: String, required: true, unique: true }, 9 | email: { type: String, required: true, unique: true }, 10 | password: { type: String, required: true }, 11 | grafid: { type: String }, 12 | }); 13 | 14 | userSchema.pre('save', function (next) { 15 | // within this context, 'this' refers to the document about to be save 16 | // in our case, it should have properties username and password 17 | bcrypt.hash(this.password, SALT_WORK_FACTOR, (err, hash) => { 18 | if (err) return next(err); 19 | // reassign the document's password to it's hashed version 20 | this.password = hash; 21 | //this next call makes mongoose move on to saving the doc 22 | return next(); 23 | }); 24 | }); 25 | 26 | const User = mongoose.model('User', userSchema); 27 | 28 | module.exports = User; 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 OSLabs Beta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/scss/index.scss: -------------------------------------------------------------------------------- 1 | @import './navVariables.scss'; 2 | 3 | *, 4 | *::before, 5 | *::after { 6 | margin: 0; 7 | box-sizing: border-box; 8 | } 9 | 10 | body { 11 | font-family: $Handjet-font; 12 | color: $text; 13 | // height: 200vh; 14 | } 15 | 16 | main { 17 | height: calc(100vh - #{$header-height}); 18 | display: flex; 19 | justify-content: center; 20 | align-items: center; 21 | 22 | .dash { 23 | font-size: 38px; 24 | text-align: center; 25 | font-weight: 700; 26 | color: $text2; 27 | padding: $spacing-md $spacing-lg; 28 | background: $bg2; 29 | border-radius: $spacing-sm; 30 | box-shadow: 0 0 10px $primary; 31 | margin: 0 $spacing-md; 32 | 33 | margin-top: -$header-height; 34 | 35 | &__focus { 36 | color: $primary; 37 | } 38 | 39 | @include breakpoint(md) { 40 | font-size: 42px; 41 | } 42 | } 43 | } 44 | 45 | button { 46 | // reset to default 47 | font-family: inherit; 48 | outline: none; 49 | border: none; 50 | background: none; 51 | letter-spacing: inherit; 52 | color: inherit; 53 | font-size: inherit; 54 | text-align: inherit; 55 | padding: 0; 56 | } 57 | -------------------------------------------------------------------------------- /src/components/App.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import Login from './Login'; 3 | import Navbar from './Navbar'; 4 | import { Route, Routes } from 'react-router-dom'; 5 | import Signup from './Signup'; 6 | import Dashboard from './Dashboard'; 7 | import Contact from './Contact'; 8 | 9 | function App() { 10 | // useState hook to pass callback down to child component 11 | // update user state name to something that is more of a reference to grafid 12 | // Here, user represents the user's grafid cookie 13 | const [user, setUser] = useState(''); 14 | // creating function to pass down to child components to update user grafid in state 15 | function funcSetUser(str) { 16 | setUser(str); 17 | return; 18 | } 19 | // 20 | return ( 21 |
22 | 23 | 24 | } /> 25 | } /> 26 | } 29 | /> 30 | } /> 31 | } /> 32 | 33 |
34 | ); 35 | } 36 | 37 | export default App; 38 | -------------------------------------------------------------------------------- /server/routes/userRoutes.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const userController = require('../controllers/userController.js'); 4 | const dashboardController = require('../controllers/dashboardController.js'); 5 | const installController = require('../controllers/installController.js'); 6 | 7 | router.post('/signup', userController.createUser, (req, res) => { 8 | return res.status(200).json(res.locals.user); 9 | }); 10 | 11 | router.post('/login', userController.getUser, (req, res, next) => { 12 | return res.status(200).json(res.locals.user); 13 | }); 14 | 15 | // handles automatic instilation, port forwarding and creates a grafana dashboard for the user. 16 | router.post( 17 | '/sendgraf', 18 | installController.installFunc, 19 | installController.portFoward, 20 | dashboardController.createDashboard, 21 | dashboardController.updateUID, 22 | (req, res) => { 23 | return res.status(200).json(res.locals.updatedUser); 24 | } 25 | ); 26 | // router.delete('/:user', userController.deleteUser, (req, res) => { 27 | // console.log('Hello from userRoutes delete'); 28 | // return res.status(200).json(res.locals.user); 29 | // }); 30 | 31 | // router.put('/:email/:password', userController.updateUser, (req, res) => { 32 | // console.log('hello from userRoutes update'); 33 | // return res.status; 34 | // (200).json(res.locals.user); 35 | // }); 36 | 37 | module.exports = router; 38 | -------------------------------------------------------------------------------- /src/components/ContactCard.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; 3 | import { faGithub, faLinkedin } from '@fortawesome/free-brands-svg-icons'; 4 | 5 | export const ContactCard = ({ 6 | imgSource, 7 | imgAlt, 8 | name, 9 | linkedin, 10 | github, 11 | }) => { 12 | 13 | const newStyle = {}; 14 | 15 | if (name === 'Cameron Kirksey' || 'Eric Rennie' || 'Richard Dao') { 16 | newStyle.marginTop = '4.5%'; 17 | } 18 | const [first, last] = name.split(' ') 19 | return ( 20 | 21 |
22 | {imgAlt} 25 | 26 |
27 | 28 |

{first}

29 |

{last}

30 | 31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
41 | 42 |
43 | 44 |
45 | ) 46 | } -------------------------------------------------------------------------------- /server/server.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | const express = require('express'); 3 | const app = express(); 4 | const path = require('path'); 5 | const cors = require('cors'); 6 | const userRoutes = require('./routes/userRoutes.js'); 7 | const cookieParser = require('cookie-parser'); 8 | 9 | const db = require('./database/db.config.js'); 10 | db(); 11 | 12 | app.use(cors()); 13 | app.use(express.urlencoded({ extended: true })); 14 | app.use(express.json()); 15 | app.use(cookieParser()); 16 | 17 | //to the user routes 18 | app.use('/users', userRoutes); 19 | 20 | // statically serve everything in the build folder on the route '/build' 21 | app.use(express.static(path.join(__dirname, '../build'))); 22 | 23 | // serve index.html on the route '/' 24 | app.get('/', (req, res) => { 25 | return res.status(200).sendFile(path.join(__dirname, '../index.html')); 26 | }); 27 | 28 | // Always send the index.html for all other routes 29 | app.get('*', (req, res) => { 30 | res.sendFile(path.join(__dirname, '../build', 'index.html')); 31 | }); 32 | 33 | //global express error handler 34 | app.use((err, req, res, next) => { 35 | const defaultErr = { 36 | log: 'Express error handler caught unknown middleware error', 37 | status: 500, 38 | message: { err: 'An error occurred' }, 39 | }; 40 | const errorObj = Object.assign({}, defaultErr, err); 41 | return res.status(errorObj.status).json(errorObj.message); 42 | }); 43 | 44 | app.listen(process.env.PORT, () => { 45 | console.log(`Listening on port ${process.env.PORT}`); 46 | }); 47 | 48 | module.exports = app; 49 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | //we require html plugin so we can add html to app (mpn install it first tho) 3 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | const Dotenv = require('dotenv-webpack'); 5 | const dotenv = require('dotenv'); 6 | dotenv.config(); 7 | module.exports = { 8 | //entry is where webpack starts to build dependency graph 9 | mode: process.env.NODE_ENV, 10 | entry: path.resolve(__dirname, 'src/index.js'), 11 | //output is where Webpack saves our bundle 12 | output: { 13 | path: path.resolve(__dirname, 'build'), 14 | filename: 'bundle.js', 15 | publicPath: '/' 16 | }, 17 | 18 | plugins: [ 19 | new HtmlWebpackPlugin({ 20 | template: path.resolve(__dirname, 'index.html'), 21 | }), 22 | new Dotenv(), 23 | ], 24 | 25 | mode: process.env.NODE_ENV, 26 | resolve: { 27 | extensions: ['.js', '.jsx'], 28 | }, 29 | module: { 30 | rules: [ 31 | { 32 | test: /\.(js|jsx)$/, 33 | exclude: /node_modules/, 34 | use: { 35 | loader: 'babel-loader', 36 | }, 37 | }, 38 | { 39 | test: /\.(sa|sc|c)ss$/, 40 | use: ['style-loader', 'css-loader', 'sass-loader'], 41 | }, 42 | { 43 | test: /\.(?:ico|gif|png|jpg|jpeg)$/i, 44 | type: 'asset/resource' 45 | }, 46 | ], 47 | }, 48 | 49 | devServer: { 50 | host: 'localhost', 51 | port: '8080', 52 | static: { 53 | directory: path.resolve(__dirname, 'build'), 54 | publicPath: '/', 55 | }, 56 | historyApiFallback: true, 57 | proxy: { 58 | '/api': 'http://localhost:' + process.env.PORT, 59 | }, 60 | }, 61 | }; 62 | -------------------------------------------------------------------------------- /server/controllers/userController.js: -------------------------------------------------------------------------------- 1 | const User = require('../models/userModel'); 2 | const bcrypt = require('bcryptjs'); 3 | 4 | const UserController = { 5 | async createUser(req, res, next) { 6 | try { 7 | const { username, email, password } = req.body; 8 | const newUser = await User.create({ 9 | username, 10 | email, 11 | password, 12 | }); 13 | res.locals.user = newUser; 14 | return next(); 15 | } catch (err) { 16 | return next({ 17 | log: 'An error occurred within the createUser found in userController', 18 | status: 400, 19 | message: { 20 | err: 'An error occurred while trying to create a new user.', 21 | }, 22 | }); 23 | } 24 | }, 25 | 26 | async getUser(req, res, next) { 27 | try { 28 | const { username, password } = req.body; 29 | const foundUser = await User.findOne({ 30 | username, 31 | }); 32 | console.log('foundUser: ', foundUser); 33 | // compare passwords 34 | const hashedPass = foundUser.password; 35 | // boolean to check if string is equal to hashed password 36 | const passOk = await bcrypt.compare(password, hashedPass); 37 | if (passOk) { 38 | res.locals.user = foundUser; 39 | return next(); 40 | } else { 41 | return next({ 42 | log: 'Failed credentials', 43 | status: 400, 44 | message: { err: 'Failed matching user credentials' }, 45 | }); 46 | } 47 | } catch { 48 | return next({ 49 | log: 'An error occurred within the getUser controller found in userController.js.', 50 | status: 400, 51 | message: { err: 'An error occurred when trying to find user.' }, 52 | }); 53 | } 54 | }, 55 | }; 56 | 57 | module.exports = UserController; 58 | -------------------------------------------------------------------------------- /src/components/Dashboard.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import LoadingCube from './LoadingCube'; 3 | import { useNavigate } from 'react-router-dom'; 4 | import { useState, useEffect } from 'react'; 5 | import Iframe from './Iframe'; 6 | import Cookies from 'js-cookie'; 7 | 8 | const Dashboard = (props) => { 9 | // fake simulation of loading and then displaying data afterwards 10 | const navigate = useNavigate(); 11 | const [isLoading, setIsLoading] = useState(true); 12 | const URL = 'http://localhost:4000/users/sendgraf'; 13 | useEffect(() => { 14 | const fetchData = async () => { 15 | // console.log(props.login); 16 | 17 | try { 18 | const res = await fetch(URL, { 19 | method: 'POST', 20 | mode: 'cors', 21 | headers: { 22 | 'Content-Type': 'application/json', 23 | }, 24 | body: JSON.stringify(props.user), 25 | }); 26 | if (res.ok) { 27 | const objUser = await res.json(); 28 | // props.setUser(objUser); 29 | Cookies.set('grafid', objUser.grafid, { expires: 1 }); 30 | // console.log('stopping loading'); 31 | setIsLoading(false); 32 | } 33 | } catch (err) { 34 | console.log(err); 35 | } 36 | }; 37 | if (Cookies.get('grafid') !== undefined) { 38 | setTimeout(() => { 39 | setIsLoading(false); 40 | }, 3000); 41 | } else if (props.user !== '') { 42 | fetchData(); 43 | } else { 44 | navigate('/'); 45 | } 46 | }, []); 47 | 48 | return ( 49 |
50 | {isLoading ? ( 51 | 52 | ) : ( 53 |
54 |