Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Redirect calculator on save (minor)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Cuadra committed Sep 5, 2018
1 parent 5b43138 commit a873adc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 48 deletions.
22 changes: 11 additions & 11 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Roadmap

- [ ] failsafe on stackoverflow
- [ ] snackbar is clipped by drawer
- [ ] lock specific menu items
- [ ] add FAQs
- [ ] WSP2
- [ ] add AFL
- [ ] increase tolerance when stackoverflow
- [ ] add unit tests
- [ ] add unit tests snapshots for calculations
- [ ] fix macro calc protein30%
- [ ] enable kg
- [ ] fix import/export torrent
- [ ] newsletter - https://app.tinyletter.com/

## Plan

## Forms
## Low Priority

- [ ] fix import/export torrent
- [ ] enable kg
- [ ] add FAQs
- [ ] newsletter - https://app.tinyletter.com/
- [ ] validate inputs

## Calculator

- [ ] fix macro calc protein30%
- [ ] WSP2
- [ ] add AFL
- http://calc.kinobody.com/wsp.html
- http://run.plnkr.co/plunks/p1p1tI/#/kinobody_ggp/lean_bulk/macros_09p_25f/180_lbs

Expand Down
45 changes: 8 additions & 37 deletions src/calculator/Calculator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import Link from 'next/link';
import Router from 'next/router';

import { Formik, Form } from 'formik';
import * as yup from 'yup';
import { Button } from 'rmwc/Button';
Expand All @@ -18,7 +20,7 @@ import Preview from './Preview';
class Calculator extends React.Component {
state = { isSaved: false };
render() {
const { handleCalculatorSave, settings = {} } = this.props;
const { handleCalculatorSave, settings = {}, recipes } = this.props;
return (
<Formik
initialValues={{
Expand Down Expand Up @@ -55,7 +57,11 @@ class Calculator extends React.Component {
macrosWorkout,
});

this.setState({ isSaved: true }, () => setSubmitting(false));
if (recipes.size > 0) {
Router.push('/plan');
} else {
Router.push('/recipes');
}
}}
render={({
errors,
Expand Down Expand Up @@ -184,22 +190,6 @@ class Calculator extends React.Component {
</GridCell>
</Grid>

<div
className={`banner text-center${
this.state.isSaved ? ' banner-open' : ''
}`}
>
<Typography use="body1" theme="onPrimary">
Saved! Now continue to{' '}
<Link href="/recipes">
<Button>Recipes</Button>
</Link>{' '}
or{' '}
<Link href="/plan">
<Button>Meal Plan</Button>
</Link>
</Typography>
</div>
<footer className="flex justify-end mt-4 mb-8 pr-4">
<Button className="mr-4" onClick={handleReset}>
reset
Expand Down Expand Up @@ -232,25 +222,6 @@ class Calculator extends React.Component {

<ListDivider />
</Form>

<style jsx>{`
.banner {
background-color: var(--mdc-theme-secondary);
opacity: 0;
height: 0;
padding: 0;
margin: 0;
}
.banner-open {
transition: all 0.3s ease-in;
opacity: 1;
height: auto;
padding: 1rem;
}
.max {
max-width: 400px;
}
`}</style>
</div>
);
}}
Expand Down

0 comments on commit a873adc

Please sign in to comment.