Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 1d6fedd

Browse files
todo label added
1 parent d18c39b commit 1d6fedd

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

src/components/todo/TodoLabel.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { TODO_STATUS } from '../../helpers/constants';
3+
4+
export default function TodoLabel({ data }) {
5+
const [label, setLabel] = useState('');
6+
7+
useEffect(() => {
8+
if (data) {
9+
let obj = TODO_STATUS.find((status) => status.id === data.status);
10+
if (obj) {
11+
setLabel(obj.key);
12+
}
13+
}
14+
}, [data]);
15+
16+
return <div className="title-label">{label}</div>;
17+
}

src/components/todo/TodoList.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import { API } from '../../services';
3-
import { DeleteTodo, TodoBox } from '../todo';
4-
import _ from 'lodash';
3+
import { DeleteTodo, TodoBox, TodoLabel } from '../todo';
4+
import { mapValues, groupBy } from 'lodash';
55

66
export default function TodoList() {
77
const [todos, setTodos] = useState([]);
@@ -21,7 +21,7 @@ export default function TodoList() {
2121
console.log('response', response);
2222
setTodos(response.data);
2323

24-
let grouped = _.mapValues(_.groupBy(response.data, 'status'));
24+
let grouped = mapValues(groupBy(response.data, 'status'));
2525

2626
console.log('grouped', grouped);
2727
setGrouped(grouped);
@@ -52,6 +52,7 @@ export default function TodoList() {
5252
{grouped &&
5353
Object.entries(grouped).map(([key, values], i) => (
5454
<div key={i} className="kanban__group">
55+
<TodoLabel data={values[0]} />
5556
{values.map((data) => (
5657
<TodoBox key={data._id} data={data} />
5758
))}

src/components/todo/TodoStatusChange.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Menu, Dropdown, message } from 'antd';
33
import { API } from '../../services';
4-
import { STATUS } from '../../helpers/constants';
4+
import { TODO_STATUS } from '../../helpers/constants';
55

66
export default function TodoStatusChange({ data }) {
77
function handleStatusEdit(e) {
@@ -20,7 +20,7 @@ export default function TodoStatusChange({ data }) {
2020

2121
const menu = (
2222
<Menu onClick={handleStatusEdit}>
23-
{STATUS.map((data) => (
23+
{TODO_STATUS.map((data) => (
2424
<Menu.Item key={data.id}>{data.key}</Menu.Item>
2525
))}
2626
</Menu>

src/components/todo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export { default as DeleteTodo } from './DeleteTodo';
22
export { default as TodoActionControls } from './TodoActionControls';
33
export { default as TodoBox } from './TodoBox';
44
export { default as TodoDelete } from './TodoDelete';
5+
export { default as TodoLabel } from './TodoLabel';
56
export { default as TodoList } from './TodoList';
67
export { default as TodoStatusChange } from './TodoStatusChange';

src/helpers/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const USER_INFO_LOCAL_STORAGE_KEY = 'toDoUserInfo';
22

3-
export const STATUS = [
3+
export const TODO_STATUS = [
44
{ id: 1, key: 'New' },
55
{ id: 2, key: 'Inprogress' },
66
{ id: 3, key: 'Completed' },

src/styles/style.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,10 @@
6666
}
6767
}
6868
}
69+
70+
.title-label {
71+
text-align: center;
72+
text-transform: uppercase;
73+
font-weight: bold;
74+
font-size: 16px;
75+
}

0 commit comments

Comments
 (0)