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

Andrew Fryer Front end Task #28

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add filter for important todos
Andrew-Fryer committed Feb 13, 2020
commit 78e8c4a1fba82683a9b9125307e501c1a8bdf9b8
5 changes: 3 additions & 2 deletions src/components/todoApp.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import {observer} from 'mobx-react';
import TodoEntry from './todoEntry';
import TodoOverview from './todoOverview';
import TodoFooter from './todoFooter';
import { ALL_TODOS, ACTIVE_TODOS, COMPLETED_TODOS } from '../constants';
import { ALL_TODOS, ACTIVE_TODOS, COMPLETED_TODOS, IMPORTANT_TODOS } from '../constants';

import DevTool from 'mobx-react-devtools';

@@ -33,7 +33,8 @@ export default class TodoApp extends React.Component {
var router = Router({
'/': function() { viewStore.todoFilter = ALL_TODOS; },
'/active': function() { viewStore.todoFilter = ACTIVE_TODOS; },
'/completed': function() { viewStore.todoFilter = COMPLETED_TODOS; }
'/completed': function() { viewStore.todoFilter = COMPLETED_TODOS; },
'/important': function() { viewStore.todoFilter = IMPORTANT_TODOS; },
});
router.init('/');
}
3 changes: 2 additions & 1 deletion src/components/todoFooter.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import {observer} from 'mobx-react';
import {action} from 'mobx';
import {pluralize} from '../utils';
import { ALL_TODOS, ACTIVE_TODOS, COMPLETED_TODOS } from '../constants';
import { ALL_TODOS, ACTIVE_TODOS, COMPLETED_TODOS, IMPORTANT_TODOS } from '../constants';

@observer
export default class TodoFooter extends React.Component {
@@ -23,6 +23,7 @@ export default class TodoFooter extends React.Component {
{this.renderFilterLink(ALL_TODOS, "", "All")}
{this.renderFilterLink(ACTIVE_TODOS, "active", "Active")}
{this.renderFilterLink(COMPLETED_TODOS, "completed", "Completed")}
{this.renderFilterLink(IMPORTANT_TODOS, "important", "Important")}
</ul>
{ todoStore.completedCount === 0
? null
4 changes: 3 additions & 1 deletion src/components/todoOverview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {observer} from 'mobx-react';
import { ACTIVE_TODOS, COMPLETED_TODOS } from '../constants';
import { ACTIVE_TODOS, COMPLETED_TODOS, IMPORTANT_TODOS } from '../constants';

import TodoItem from './todoItem';

@@ -39,6 +39,8 @@ export default class TodoOverview extends React.Component {
return !todo.completed;
case COMPLETED_TODOS:
return todo.completed;
case IMPORTANT_TODOS:
return todo.important;
default:
return true;
}
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const ALL_TODOS = 'all';
export const ACTIVE_TODOS = 'active';
export const COMPLETED_TODOS = 'completed';
export const IMPORTANT_TODOS = 'important';