Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add daily goals #149

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
"@hookform/resolvers": "^1.0.1",
"@material-ui/core": "^4.7.0",
"@material-ui/icons": "^4.5.1",
"@material-ui/lab": "^4.0.0-alpha.35",
"@reach/window-size": "^0.11.2",
Expand Down Expand Up @@ -39,6 +39,7 @@
"array-move": "^3.0.1",
"chromatic": "^5.3.0",
"classnames": "^2.2.6",
"formik-material-ui": "^3.0.0",
"clsx": "^1.0.4",
"date-fns": "^2.16.1",
"debug": "^4.2.0",
Expand Down
11 changes: 11 additions & 0 deletions src/components/ui/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import MailTo from 'react-mailto.js';
import { getFirebase } from 'react-redux-firebase';
import { useHistory } from 'react-router-dom';
import useWebShare from 'react-use-web-share';
import PlaylistAddCheckIcon from '@material-ui/icons/PlaylistAddCheck';
import {
handleErrors,
toggleSidebar,
Expand Down Expand Up @@ -99,6 +100,16 @@ const Sidebar: React.FC<{
classes={{ paper: cx.backgroundColor }}
onClose={toggleSidebar}
>
<ListItem
button
onClick={redirectAndCloseSidebar('/streaks')}
>
<ListItemIcon>
<PlaylistAddCheckIcon />
</ListItemIcon>
{/* TODO: i18n */}
<StyledListText primary={'GOALS'} />
</ListItem>
<List>
<ListItem button onClick={redirectAndCloseSidebar('/faq')}>
<ListItemIcon>
Expand Down
56 changes: 36 additions & 20 deletions src/components/unsorted/UpsertDailyGoal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Box, TextField, Theme } from '@material-ui/core';
import { makeStyles } from '@material-ui/styles';
import { Box, Grid, Theme, Button } from '@material-ui/core';
import classNames from 'classnames';
import { Formik } from 'formik';
import React, { memo } from 'react';
import { Field, Form, Formik } from 'formik';
import { TextField } from 'formik-material-ui';
import { makeStyles } from '@material-ui/styles';

const useStyles = makeStyles((theme: Theme) => ({ root: {} }));

Expand All @@ -18,10 +19,11 @@ const UpsertDailyGoal = memo((props: Props) => {
<Box className={rootClasses}>
<Formik
initialValues={{ title: '' }}
validate={values => {
validate={(values) => {
const errors: Partial<{ title: string }> = {};
if (!values.title) {
errors.title = 'Required';
if (!values.title?.trim()) {
// TODO i18n
errors.title = 'Обязательно';
}
return errors;
}}
Expand All @@ -32,20 +34,34 @@ const UpsertDailyGoal = memo((props: Props) => {
}, 400);
}}
>
{({
values, handleChange, handleBlur, handleSubmit,
}) => (
<form onSubmit={handleSubmit}>
<TextField
fullWidth
name="title"
value={values.title}
variant="outlined"
label="Title"
onChange={handleChange}
onBlur={handleBlur}
/>
</form>
{({ values, handleChange, handleBlur, handleSubmit }) => (
<Form onSubmit={handleSubmit}>
<Grid container>
<Grid item xs>
<Field
fullWidth
name="title"
// TODO: i18n
label="Название"
variant="outlined"
value={values.title}
component={TextField}
onBlur={handleBlur}
onChange={handleChange}
/>
</Grid>
<Grid item xs={3}>
<Button
type="submit"
color="primary"
variant="contained"
>
{/* TODO: i18n */}
Сохранить
</Button>
</Grid>
</Grid>
</Form>
)}
</Formik>
</Box>
Expand Down