Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-stale-condition-to-tasks-list
Browse files Browse the repository at this point in the history
  • Loading branch information
Undeadlol1 committed Nov 6, 2020
2 parents 9b13804 + f528429 commit 3609ea4
Show file tree
Hide file tree
Showing 42 changed files with 2,417 additions and 5,179 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: npm test
name: run tests

on:
pull_request:
Expand All @@ -12,7 +12,7 @@ on:
- unlocked

jobs:
build:
test:
runs-on: ubuntu-latest

steps:
Expand Down
6,963 changes: 2,066 additions & 4,897 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
"@storybook/react": "^6.0.28",
"@types/babel__core": "^7.1.12",
"@types/classnames": "^2.2.11",
"@types/concurrently": "^4.1.0",
"@types/debug": "^4.1.5",
"@types/eslint": "^7.2.4",
"@types/eslint-plugin-prettier": "^3.1.0",
"@types/faker": "^5.1.4",
"@types/jest": "^26.0.15",
"@types/lodash": "^4.14.164",
"@types/lodash": "^4.14.165",
"@types/node": "^14.14.6",
"@types/prettier": "1.18.2",
"@types/prettier": "2.1.5",
"@types/prop-types": "^15.7.3",
"@types/ramda": "^0.26.34",
"@types/reach__window-size": "^0.1.1",
"@types/react": "^16.9.55",
"@types/react": "^16.9.56",
"@types/react-countup": "^4.0.1",
"@types/react-dom": "^16.9.9",
"@types/react-joyride": "^2.0.5",
Expand All @@ -38,24 +37,24 @@
"@types/react-test-renderer": "^16.9.1",
"@types/yup": "^0.29.9",
"array-move": "^3.0.1",
"chromatic": "^5.2.0",
"chromatic": "^5.3.0",
"classnames": "^2.2.6",
"clsx": "^1.0.4",
"date-fns": "^2.16.1",
"debug": "^4.2.0",
"firebase": "^8.0.0",
"firebase-tools": "^8.14.1",
"firebase": "^8.0.1",
"firebase-tools": "^8.15.1",
"firebaseui": "^4.7.1",
"formik": "^2.1.5",
"formik": "^2.2.2",
"i18next": "^19.8.3",
"i18next-browser-languagedetector": "^6.0.1",
"lodash": "^4.17.15",
"lorem-ipsum": "^2.0.3",
"material-ui-chip-input": "^1.1.0",
"nanoid": "^3.1.16",
"pretty-error": "^2.1.1",
"pretty-error": "^2.1.2",
"prop-types": "^15.7.2",
"query-string": "^6.13.6",
"query-string": "^6.13.7",
"ramda": "^0.27.1",
"react": "^16.14.0",
"react-compound-timer": "^1.1.15",
Expand Down Expand Up @@ -132,7 +131,7 @@
"@storybook/node-logger": "^6.0.28",
"@storybook/preset-create-react-app": "^3.1.4",
"@testing-library/jest-dom": "^5.11.5",
"@types/enzyme": "^3.10.3",
"@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",
Expand All @@ -144,12 +143,12 @@
"customize-cra": "^1.0.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^6.6.0",
"eslint": "^7.12.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.5.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^23.0.2",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.21.5",
Expand Down
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { createFirestoreInstance } from 'redux-firestore';
import './App.css';
import { BrowserRouter } from 'react-router-dom';
import RouterAndDataLoader from './RouterAndDataLoader';
import { initializeI18n, useDebouncedWindowSize } from './services';
import { initializeI18n } from './services';
import { useDebouncedWindowSize } from './hooks/useDebouncedWindowSize';
import store from './store';
import { Theme } from './Theme';

Expand Down
15 changes: 7 additions & 8 deletions src/components/rewards/RewardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import findLast from 'ramda/es/findLast';
import React, { memo } from 'react';
import { useDispatch } from 'react-redux';
import { useTypedTranslate } from '../../services/index';
import { Profile, useTypedSelector, claimReward } from '../../store';

import { useTypedSelector, claimReward } from '../../store';
import { Profile } from '../../entities/Profile';
import { Reward } from '../../store/rewardsSlice';
import { toggleRewardModal } from '../../store/uiSlice';
import RewardCard from './RewardCard';
Expand All @@ -20,18 +20,18 @@ interface Props {
className?: string;
}

const RewardModal: React.FC<Props> = props => {
const RewardModal: React.FC<Props> = (props) => {
const dispatch = useDispatch();
const t = useTypedTranslate();
const { profile }: { profile: Profile } = useTypedSelector(
s => s.firestore.data,
(s) => s.firestore.data,
);
const userPoints = get(profile, 'points', 0);
const rewards = useTypedSelector(
s => s.firestore.ordered.rewards as Reward[],
(s) => s.firestore.ordered.rewards as Reward[],
);
const unlockedReward = findLast(
i => i.points <= userPoints,
(i) => i.points <= userPoints,
rewards || [],
) as Reward;

Expand All @@ -53,8 +53,7 @@ const RewardModal: React.FC<Props> = props => {
onClose={toggleModal}
>
<DialogTitle id="alert-dialog-title">
{t('you unlocked a reward')}
!
{t('you unlocked a reward')}!
</DialogTitle>
<DialogContent>
<RewardCard isRaised reward={unlockedReward} />
Expand Down
9 changes: 7 additions & 2 deletions src/components/tasks/DayliTasksStreak.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ export default {
export const Demos = () => (
<>
Done yesterday:
{' '}
<br />
(meaning user is working on a streak, it is not yet broken)
<DayliTasksStreak streak={streaks.doneTasksYesterday} />
<hr />
Done today:
<hr />
<DayliTasksStreak streak={streaks.doneTasksToday} />
<hr />
Few days:
<hr />
<DayliTasksStreak streak={streaks.doneTasksFewDays} />
<hr />
Noting will be shown if streak is broken:
<hr />
<DayliTasksStreak streak={streaks.streakIsBroken} />
</>
);
);
46 changes: 26 additions & 20 deletions src/components/tasks/DayliTasksStreak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,36 @@ const log = debug(componentName);

interface Props {
streak: IDayliStreak;
isUpdateAnimationDisabled?: boolean;
}

const DayliTasksStreak = memo(({ streak }: Props) => {
const t = useTypedTranslate();
const DayliTasksStreak = memo(
({ streak, isUpdateAnimationDisabled }: Props) => {
const t = useTypedTranslate();

let daysInARow = DailyStreak.daysInARow(streak) + 1;
const daysSinceUpdate = DailyStreak.daysSinceUpdate(streak);
let daysInARow = DailyStreak.daysInARow(streak);
const daysSinceUpdate = DailyStreak.daysSinceUpdate(streak);

log('streak.startsAt: ', new Date(streak?.startsAt as number));
log('streak.updatedAt: ', new Date(streak?.updatedAt as number));
log('daysInARow: ', daysInARow);
log('daysSinceUpdate: ', daysSinceUpdate);
log('streak.startsAt: ', new Date(streak?.startsAt as number));
log('streak.updatedAt: ', new Date(streak?.updatedAt as number));
log('daysInARow: ', daysInARow);
log('daysSinceUpdate: ', daysSinceUpdate);

if (daysSinceUpdate === undefined || daysSinceUpdate > 1) {
daysInARow = 0;
}
return (
<Typography variant="h6">
<Box fontWeight={100}>
{t('won_days_in_a_row')}:{' '}
<NumbersAnimatedOnUpdate value={daysInARow} />
</Box>
</Typography>
);
});
if (daysSinceUpdate === undefined || daysSinceUpdate > 1) {
daysInARow = 0;
}
return (
<Typography variant="h6">
<Box fontWeight={100}>
{t('won_days_in_a_row')}:{' '}
<NumbersAnimatedOnUpdate
value={daysInARow}
isAnimationDisabled={isUpdateAnimationDisabled}
/>
</Box>
</Typography>
);
},
);

export default memo(DayliTasksStreak);
2 changes: 1 addition & 1 deletion src/components/tasks/DayliTasksStreakForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Card, CardContent, TextField } from '@material-ui/core';
import React, { ChangeEvent, memo } from 'react';
import { upsertProfile } from '../../store';
import { profileSelector } from '../../store/selectors';
import debug from 'debug';
import Snackbar from '../../services/Snackbar';
import { useSelector } from 'react-redux';
import { upsertProfile } from '../../repositories/upsertProfile';

const log = debug('DayliTasksStreakForm');

Expand Down
6 changes: 4 additions & 2 deletions src/components/tasks/HardChoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
showSnackbar,
useTypedTranslate,
} from '../../services/index';
import { addPoints, Task, useTypedSelector } from '../../store/index';
import { useTypedSelector } from '../../store/index';
import { Task } from '../../entities/Task';
import { addPointsToUser } from '../../repositories/addPointsToUser';
import { authSelector } from '../../store/selectors';
import Collapsible from '../ui/Collapsible';
import CreateSubtask from './CreateSubtask/CreateSubtask';
Expand Down Expand Up @@ -43,7 +45,7 @@ const HardChoices = (
const taskNote = get(task, 'note');
const auth = useTypedSelector(authSelector);
const addPointsOnSuccess = (points = 10) => {
addPoints(auth.uid, points);
addPointsToUser(auth.uid, points);
showSnackbar(
t('youAreCloserToYourGoal', {
points,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import {
handleErrors,
showSnackbar,
useTypedTranslate,
} from '../../../services/index';
import { addPointsWithSideEffects } from '../../../store/index';
} from '../../services/index';
import { addPointsWithSideEffects } from '../../store/index';
import {
authSelector,
pinnedTaskSelector,
} from '../../../store/selectors';
import CreateSubtask from '../CreateSubtask/CreateSubtask';
import SubtasksList from '../SubtasksList';
} from '../../store/selectors';
import CreateSubtask from './CreateSubtask/CreateSubtask';
import SubtasksList from './SubtasksList';

let taskId = '';
const log = debug('Pinnedtask');
Expand Down
3 changes: 2 additions & 1 deletion src/components/tasks/RandomTaskButton/RandomTaskButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { useSelector } from 'react-redux';
import { useFirestore } from 'react-redux-firebase';
import { Link } from 'react-router-dom';
import { Theme } from '@material-ui/core';
import { Task, useTypedSelector } from '../../../store/index';
import { useTypedSelector } from '../../../store/index';
import { Task } from '../../../entities/Task';
import {
activeTaskSelector,
tasksSelector,
Expand Down
7 changes: 4 additions & 3 deletions src/components/tasks/SubtasksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import {
useTypedTranslate,
} from '../../services/index';
import Snackbar from '../../services/Snackbar';
import { deleteSubtask, Subtask } from '../../store';
import { deleteSubtask } from '../../repositories/deleteSubtask';
import { addPointsWithSideEffects } from '../../store/index';
import { authSelector } from '../../store/selectors';
import { Subtask } from '../../entities/Subtask';

const useStyles = makeStyles((theme: Theme) => {
const color = theme.palette.text.primary;
Expand Down Expand Up @@ -124,7 +125,7 @@ export default function SubtasksList({ documents, ...props }: Props) {

if (!documents || isEmpty(documents)) return null;

const onSortEnd = ({ oldIndex, newIndex }: any) => {
const updateSubtasks = ({ oldIndex, newIndex }: any) => {
const taskId = documents[0].parentId;
const updatedSubtasks = arrayMove(documents, oldIndex, newIndex);
setSubtasksStub(updatedSubtasks);
Expand All @@ -140,7 +141,7 @@ export default function SubtasksList({ documents, ...props }: Props) {
useDragHandle
lockAxis="y"
items={subtasksStub || documents}
onSortEnd={onSortEnd}
onSortEnd={updateSubtasks}
/>
</Paper>
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/tasks/TaskChoices/TaskChoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
useTypedTranslate,
} from '../../../services/index';
import Snackbar from '../../../services/Snackbar';
import { Subtask, Task } from '../../../store/index';
import { Task } from '../../../entities/Task';
import { Subtask } from '../../../entities/Subtask';

const useStyles = makeStyles((theme: Theme) => ({
container: {
Expand All @@ -43,7 +44,7 @@ const TaskChoices = (props: Props) => {
const t = useTypedTranslate();
const classes = useStyles();
const activeSubtasks =
filter(props.task.subtasks, i => !i.isDone) || [];
filter(props.task.subtasks, (i) => !i.isDone) || [];
const hasSubtasks = Boolean(activeSubtasks.length);
const commonButtonProps: ButtonProps = {
fullWidth: true,
Expand Down
8 changes: 7 additions & 1 deletion src/components/tasks/TasksDoneToday.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export interface TasksDoneTodayProps {
tasksPerDay: number;
tasksToday: number;
dailyStreak: IDayliStreak;
isUpdateAnimationDisabled?: boolean;
}

function TasksDoneToday({
tasksToday,
tasksPerDay,
isUpdateAnimationDisabled,
...props
}: TasksDoneTodayProps) {
const classes = useStyles();
Expand All @@ -68,6 +70,7 @@ function TasksDoneToday({
>
<NumbersAnimatedOnUpdate
value={completedTasksInpercentages}
isAnimationDisabled={isUpdateAnimationDisabled}
/>
{`${completedTasksInpercentages > 0 ? '%' : ''}`}
</span>
Expand All @@ -91,7 +94,10 @@ function TasksDoneToday({
}
/>
<Box mt={2}>
<DayliTasksStreak streak={props.dailyStreak} />
<DayliTasksStreak
streak={props.dailyStreak}
isUpdateAnimationDisabled={isUpdateAnimationDisabled}
/>
</Box>
</CardContent>
</Card>
Expand Down
Loading

0 comments on commit 3609ea4

Please sign in to comment.