Skip to content

Commit

Permalink
[MASTERDIET-12]
Browse files Browse the repository at this point in the history
  • Loading branch information
RafisSomeone committed Jun 13, 2020
1 parent c6ad160 commit e642fa2
Show file tree
Hide file tree
Showing 50 changed files with 453 additions and 92 deletions.
Empty file modified .circleci/config.yml
100644 → 100755
Empty file.
Empty file modified .dockerignore
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified Dockerfile
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
366 changes: 353 additions & 13 deletions package-lock.json
100644 → 100755

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@reach/slider": "^0.10.3",
"@shwilliam/react-rubber-slider": "^0.1.2",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"bootstrap": "^4.5.0",
"d3": "^5.16.0",
"formik": "^2.1.4",
"moment": "^2.26.0",
"react": "^16.13.1",
Expand Down
Empty file modified public/favicon.ico
100644 → 100755
Empty file.
Empty file modified public/index.html
100644 → 100755
Empty file.
Empty file modified public/logo192.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/logo512.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/manifest.json
100644 → 100755
Empty file.
Empty file modified public/robots.txt
100644 → 100755
Empty file.
Empty file modified src/app/App.css
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/app/App.test.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import { BrowserRouter } from 'react-router-dom'
import {BrowserRouter} from 'react-router-dom'

it('renders without crashing', () => {
const div = document.createElement('div')
Expand Down
Empty file modified src/common/AppHeader.css
100644 → 100755
Empty file.
36 changes: 18 additions & 18 deletions src/common/AppHeader.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import React, { Component } from 'react'
import { Link, NavLink } from 'react-router-dom'
import React, {Component} from 'react'
import {Link, NavLink} from 'react-router-dom'
import './AppHeader.css'

class AppHeader extends Component {
render () {
render() {
return (
<header className='app-header'>
<div className='container'>
<div className='app-branding'>
<Link to='/' className='app-title'>Master Diet</Link>
</div>
<div className='app-options'>
<nav className='app-nav'>
{this.props.authenticated ? (
<ul>
<li>
<NavLink to='/profile'>Profile</NavLink>
</li>
<li>
<NavLink to='/startForm'>Start Form</NavLink>
</li>
<header className='app-header'>
<div className='container'>
<div className='app-branding'>
<Link to='/' className='app-title'>Master Diet</Link>
</div>
<div className='app-options'>
<nav className='app-nav'>
{this.props.authenticated ? (
<ul>
<li>
<NavLink to='/profile'>Profile</NavLink>
</li>
<li>
<NavLink to='/startForm'>Start Form</NavLink>
</li>
<li>
<a onClick={this.props.onLogout}>Logout</a>
</li>
Expand Down
Empty file modified src/common/LoadingIndicator.js
100644 → 100755
Empty file.
Empty file modified src/common/NotFound.css
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/common/NotFound.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import React, {Component} from 'react'
import './NotFound.css'
import { Link } from 'react-router-dom'
import {Link} from 'react-router-dom'

class NotFound extends Component {
render () {
Expand Down
Empty file modified src/constants/index.js
100644 → 100755
Empty file.
21 changes: 18 additions & 3 deletions src/form/Start.css
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ img {
}
.child_div_1 {
width: 600px;
height: 800px;
height: 900px;
}
.child_div_2 {
height: 800px;
height: 900px;
}
.container {
text-align: center;
Expand All @@ -80,13 +80,28 @@ img {
.dateContainer {
width: 430px;
}

.block {
display: inline-block;
width: 143px;
}

.pad {
padding-right: 20px;
}
.container2 {

.container2 {
text-align: center;
}

.column {
float: left;
width: 33.33%;
padding: 5px;
}

.row::after {
content: "";
clear: both;
display: table;
}
67 changes: 35 additions & 32 deletions src/form/Start.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import moment from 'moment'
import gainGoalImg from '../img/activities/gain-active-img.jpg'
import loseGoalImg from '../img/activities/lose-goal-img.jpg'
import stayGoalImg from '../img/activities/stay-goal-img.jpg'
import fatPercentageImag from '../img/fatPercentage/fatPercentage.jpg'
import carbohydratesPercentageImag from '../img/fatPercentage/carbohydratesPercentage.jpg'
import {createPlan} from "../util/APIUtils";
import Alert from 'react-s-alert'

import RubberSlider from '@shwilliam/react-rubber-slider'
import '@shwilliam/react-rubber-slider/dist/styles.css'

class Start extends Component {
constructor(props) {
Expand Down Expand Up @@ -70,34 +73,11 @@ class StartForm extends Component {
}



marks = [
{
value: 0,
label: '0°C',
},
{
value: 20,
label: '20°C',
},
{
value: 37,
label: '37°C',
},
{
value: 100,
label: '100°C',
},
];

valuetext(value) {
return `${value}°C`;
}

state = {
startDate: new Date("01/01/1990"),
goal: "LOSE",
gender: "MALE"
gender: "MALE",
slider: 50
};

handleChange = date => {
Expand All @@ -110,15 +90,25 @@ class StartForm extends Component {
gender: data
});
};
PROM = 1000
MIN = 0.2
handleSlider = data => {
const fatPercentage = data / this.PROM + this.MIN
this.setState({
slider: fatPercentage
})
}

handleSubmit(values) {
handleSubmit(values, setSubmitting) {
values.userId = this.props.currentUser.id;
console.log(this.props.currentUser.id)
values.fatPreferencesPercentage = this.state.slider
createPlan(values)
.then(response => {
Alert.success('You\'re successfully created your first diet plan')
}).catch(error => {
Alert.error((error && error.message) || 'Oops! Something went wrong. Please try again!')
}).finally(response => {
setSubmitting(false)
})
}

Expand Down Expand Up @@ -162,9 +152,8 @@ class StartForm extends Component {
}}
onSubmit={(values, {setSubmitting}) => {
values.birthDate = this.getFormattedDate(this.state.startDate);
values.fatPreferencesPercentage =
this.handleSubmit(values)
setSubmitting(false)
values.fatPreferencesPercentage = this.state.slider;
this.handleSubmit(values, setSubmitting)
}}
>
{({touched, errors, isSubmitting}) => (
Expand Down Expand Up @@ -265,7 +254,21 @@ class StartForm extends Component {
<option value="LOSE">Weight lose</option>
</Field>
</div>

<div className={"form-group field"}>
<label htmlFor="slider">Which food do you prefer to eat more?</label>
</div>
<div className={"row "}>
<div className={"column"}>
<img src={carbohydratesPercentageImag} width={100} alt={"Carbohydrates"}/>
</div>
<div className={"column"}>
<RubberSlider width={140} value={this.state.slider} onChange={
this.handleSlider}/>
</div>
<div className={"column"}>
<img src={fatPercentageImag} width={100} alt={"Fats"}/>
</div>
</div>
<button
type="submit"
className="btn btn-primary btn-block"
Expand Down
Empty file modified src/home/Home.css
100644 → 100755
Empty file.
Empty file modified src/img/activities/active-active-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/bmr-active-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/error-active-img.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/gain-active-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/light-active-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/lose-goal-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/moderate-active-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/sedentary-active-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/stay-goal-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/activities/very_active-active-img.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/fatPercentage/carbohydratesPercentage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/fatPercentage/fatPercentage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/fb-logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/github-logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/img/google-logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/index.css
100644 → 100755
Empty file.
Empty file modified src/logo.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/registerServiceWorker.js
100644 → 100755
Empty file.
Empty file modified src/serviceWorker.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/setupTests.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect'
import '@testing-library/jest-dom/extend-expect'
Empty file modified src/user/login/Login.css
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions src/user/oauth2/OAuth2RedirectHandler.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { Component } from 'react'
import { ACCESS_TOKEN } from '../../constants'
import { Redirect } from 'react-router-dom'
import React, {Component} from 'react'
import {ACCESS_TOKEN} from '../../constants'
import {Redirect} from 'react-router-dom'

class OAuth2RedirectHandler extends Component {
getUrlParameter (name) {
getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
const regex = new RegExp('[\\?&]' + name + '=([^&#]*)')

Expand Down
Empty file modified src/user/profile/Profile.css
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/user/profile/Profile.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import React, {Component} from 'react'
import './Profile.css'

class Profile extends Component {
Expand Down
Empty file modified src/user/signup/Signup.css
100644 → 100755
Empty file.
34 changes: 17 additions & 17 deletions src/user/signup/Signup.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import React, { Component } from 'react'
import React, {Component} from 'react'
import './Signup.css'
import { Link, Redirect } from 'react-router-dom'
import { GOOGLE_AUTH_URL, FACEBOOK_AUTH_URL, GITHUB_AUTH_URL } from '../../constants'
import { signup } from '../../util/APIUtils'
import {Link, Redirect} from 'react-router-dom'
import {FACEBOOK_AUTH_URL, GITHUB_AUTH_URL, GOOGLE_AUTH_URL} from '../../constants'
import {signup} from '../../util/APIUtils'
import fbLogo from '../../img/fb-logo.png'
import googleLogo from '../../img/google-logo.png'
import githubLogo from '../../img/github-logo.png'
import Alert from 'react-s-alert'

class Signup extends Component {
render () {
if (this.props.authenticated) {
return <Redirect
to={{
pathname: '/',
state: { from: this.props.location }
}}
/>
}
render() {
if (this.props.authenticated) {
return <Redirect
to={{
pathname: '/',
state: {from: this.props.location}
}}
/>
}

return (
<div className='signup-container'>
<div className='signup-content'>
<h1 className='signup-title'>Signup with Master Diet</h1>
return (
<div className='signup-container'>
<div className='signup-content'>
<h1 className='signup-title'>Signup with Master Diet</h1>
<SocialSignup/>
<div className='or-separator'>
<span className='or-text'>OR</span>
Expand Down

0 comments on commit e642fa2

Please sign in to comment.