Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/-focus-mode-(#110
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Undeadlol1 committed Nov 16, 2020
2 parents 4e6b3f5 + b558370 commit 534c6ab
Show file tree
Hide file tree
Showing 24 changed files with 631 additions and 644 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
Expand Down
417 changes: 147 additions & 270 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"@types/babel__core": "^7.1.12",
"@types/classnames": "^2.2.11",
"@types/debug": "^4.1.5",
"@types/eslint": "^7.2.4",
"@types/eslint": "^7.2.5",
"@types/eslint-plugin-prettier": "^3.1.0",
"@types/faker": "^5.1.4",
"@types/jest": "^26.0.15",
"@types/lodash": "^4.14.165",
"@types/node": "^14.14.6",
"@types/node": "^14.14.7",
"@types/prettier": "2.1.5",
"@types/prop-types": "^15.7.3",
"@types/ramda": "^0.27.32",
Expand All @@ -42,10 +42,10 @@
"clsx": "^1.0.4",
"date-fns": "^2.16.1",
"debug": "^4.2.0",
"firebase": "^8.0.1",
"firebase-tools": "^8.15.1",
"firebase": "^8.0.2",
"firebase-tools": "^8.16.2",
"firebaseui": "^4.7.1",
"formik": "^2.2.3",
"formik": "^2.2.5",
"i18next": "^19.8.3",
"i18next-browser-languagedetector": "^6.0.1",
"lodash": "^4.17.15",
Expand All @@ -61,7 +61,7 @@
"react-countup": "^4.2.3",
"react-dom": "^16.14.0",
"react-firebaseui-localized": "^1.0.8",
"react-hook-form": "^6.11.0",
"react-hook-form": "^6.11.2",
"react-i18next": "^11.7.3",
"react-if": "^4.0.1",
"react-joyride": "^2.1.1",
Expand Down Expand Up @@ -91,15 +91,15 @@
"start:nofirebase": "react-scripts start",
"start": "concurrently \"npx cross-env DEBUG_HIDE_DATE=true PORT=3001 react-scripts start\" \"firebase emulators:start --only firestore\"",
"build": "react-scripts build",
"test": "react-scripts test",
"test": "react-scripts test --runInBand",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"deploy": "npm run build && firebase deploy",
"analyze": "npm run build && source-map-explorer 'build/static/js/*.js'",
"component": "npx plop",
"chromatic": "npx chromatic --allow-console-errors -t '$CHROMATIC_TOKEN'",
"find_ts_errors": "npx typescript",
"find_ts_errors": "node ./node_modules/typescript/bin/tsc",
"lint": "eslint --ext .js,.jsx,.ts,.tsx src/**"
},
"engines": {
Expand Down Expand Up @@ -130,13 +130,13 @@
"@storybook/addon-essentials": "^6.0.28",
"@storybook/node-logger": "^6.0.28",
"@storybook/preset-create-react-app": "^3.1.5",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/jest-dom": "^5.11.6",
"@types/enzyme": "^3.10.8",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"babel-loader": "^8.2.1",
"babel-plugin-import": "^1.13.1",
"babel-plugin-lodash": "^3.3.4",
"concurrently": "^5.0.0",
Expand All @@ -148,7 +148,7 @@
"eslint-config-prettier": "^6.15.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.21.5",
Expand Down
3 changes: 1 addition & 2 deletions src/RouterAndDataLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ export default memo((props: { children?: JSX.Element }) => {
const yesterday = subHours(today, getHours(today)).getTime();

// Refetch data every hour.
const dataRefetchInterval = 1000 * 60 * 60;
useInterval(() => {
console.log('Refetching data every hour...');
setToday(Date.now());
}, dataRefetchInterval);
}, 1000 * 60 * 60);

// Store userId in localStorage to improve loading times on startup
const userId =
Expand Down
19 changes: 19 additions & 0 deletions src/components/dataMocks.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
import { random } from 'faker';
import subDays from 'date-fns/esm/subDays';
import { IDayliStreak } from '../entities/IDayliStreak';
import { TasksDoneTodayProps } from './tasks/TasksDoneToday';
import { Task } from '../entities/Task';

const perDay = 3;
const today = new Date().getTime();
const yesterday = subDays(today, 1).getTime();

export const tasksMock = Array(25)
.fill('')
.map(
(i, index) =>
({
id: random.uuid(),
name: random.boolean() ? random.word() : random.words(10),
subtasks: random.boolean()
? [
{
name: 'This is a name of subtask.',
},
]
: undefined,
} as Task),
);

export const streaks = {
doneTasksYesterday: {
perDay,
Expand Down
59 changes: 50 additions & 9 deletions src/components/tasks/HardChoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Typography, {
} from '@material-ui/core/Typography';
import get from 'lodash/get';
import React from 'react';
import { Theme } from '@material-ui/core';
import { Box, Button, ButtonProps, Theme } from '@material-ui/core';
import { TaskPageGridWidth } from '../../pages/TaskPage';
import {
showSnackbar,
Expand All @@ -21,6 +21,7 @@ import UpsertTask from './CreateTask/UpsertTask';
import SubtasksList from './SubtasksList';
import UpsertNote from './UpsertNote/UpsertNote';
import TagsForm from './TagsForm';
import { deleteTaskArguments } from '../../pages/TaskPage/TaskPageContainer';

const useStyles = makeStyles((theme: Theme) => ({
form: {
Expand All @@ -33,28 +34,68 @@ const paragraphProps: TypographyProps = {
color: 'textSecondary',
};

const HardChoices = (
props: Partial<{
task: Task;
taskId: string;
}>,
) => {
const HardChoices = (props: {
task: Task;
taskId: string;
deleteTask: (options?: deleteTaskArguments) => Promise<void>;
}) => {
const t = useTypedTranslate();
const classes = useStyles();
const { task, taskId } = props;
const taskNote = get(task, 'note');
const auth = useTypedSelector(authSelector);
const addPointsOnSuccess = (points = 10) => {

const commonButtonProps: ButtonProps = {
fullWidth: true,
color: 'primary',
variant: 'contained',
};

function destroy() {
const pointsToAdd = 10;
props.deleteTask({
pointsToAdd,
snackbarMessage: t('getRidOfUnimportant', {
points: pointsToAdd,
}),
});
}

function addPointsOnSuccess(points = 10) {
addPointsToUser(auth.uid, points);
showSnackbar(
t('youAreCloserToYourGoal', {
points,
}),
);
};
}

return (
<Grid item container {...TaskPageGridWidth} justify="center">
<Grid item xs={12}>
<Collapsible
title={t('reject_the_task')}
isOpen={Boolean(get(task, 'subtasks.length'))}
>
<>
<Grid item xs={12}>
<Typography paragraph>
{t('dont_hesitate_to_push_this_button')}
</Typography>
<Typography paragraph>
{t('only_20_percent_gives_results')}
</Typography>
</Grid>
<Grid item xs={12}>
<Box mb={2}>
<Button {...commonButtonProps} onClick={destroy}>
{t('notImportant')}
</Button>
</Box>
</Grid>
</>
</Collapsible>
</Grid>
<Grid item xs={12}>
<Collapsible
title={t('Add subtasks')}
Expand Down
25 changes: 5 additions & 20 deletions src/components/tasks/TasksList/TasksList.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { random } from 'faker';
import { addDecorator } from '@storybook/react';
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { addDecorator } from '@storybook/react';
import { TasksList } from './TasksList';
import { sections } from '../../storybookContants';
import { Task } from '../../../store/index';
import { TasksList } from './TasksList';
import { tasksMock } from '../../dataMocks';

type DecoratorFunction = Parameters<typeof addDecorator>[0];

Expand All @@ -17,31 +16,17 @@ export interface StoryMetadata {
const metaData: StoryMetadata = {
component: TasksList,
title: `${sections.tasks}TasksList`,
decorators: [storyFn => <Router>{storyFn()}</Router>],
decorators: [(storyFn) => <Router>{storyFn()}</Router>],
};

export default metaData;

const props = {
loading: false,
tasks: tasksMock,
deleteTask() {
console.log('"deleteTask" clicked');
},
tasks: Array(25)
.fill('')
.map(
(i, index) => ({
id: random.uuid(),
name: random.boolean() ? random.word() : random.words(10),
subtasks: random.boolean()
? [
{
name: 'This is a subtask.',
},
]
: undefined,
} as Task),
),
};

export const withItems = () => <TasksList {...props} />;
Expand Down
Loading

0 comments on commit 534c6ab

Please sign in to comment.