This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +32
-6
lines changed Expand file tree Collapse file tree 6 files changed +32
-6
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 1
1
import React , { useState , useEffect } from 'react' ;
2
2
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' ;
5
5
6
6
export default function TodoList ( ) {
7
7
const [ todos , setTodos ] = useState ( [ ] ) ;
@@ -21,7 +21,7 @@ export default function TodoList() {
21
21
console . log ( 'response' , response ) ;
22
22
setTodos ( response . data ) ;
23
23
24
- let grouped = _ . mapValues ( _ . groupBy ( response . data , 'status' ) ) ;
24
+ let grouped = mapValues ( groupBy ( response . data , 'status' ) ) ;
25
25
26
26
console . log ( 'grouped' , grouped ) ;
27
27
setGrouped ( grouped ) ;
@@ -52,6 +52,7 @@ export default function TodoList() {
52
52
{ grouped &&
53
53
Object . entries ( grouped ) . map ( ( [ key , values ] , i ) => (
54
54
< div key = { i } className = "kanban__group" >
55
+ < TodoLabel data = { values [ 0 ] } />
55
56
{ values . map ( ( data ) => (
56
57
< TodoBox key = { data . _id } data = { data } />
57
58
) ) }
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { Menu , Dropdown , message } from 'antd' ;
3
3
import { API } from '../../services' ;
4
- import { STATUS } from '../../helpers/constants' ;
4
+ import { TODO_STATUS } from '../../helpers/constants' ;
5
5
6
6
export default function TodoStatusChange ( { data } ) {
7
7
function handleStatusEdit ( e ) {
@@ -20,7 +20,7 @@ export default function TodoStatusChange({ data }) {
20
20
21
21
const menu = (
22
22
< Menu onClick = { handleStatusEdit } >
23
- { STATUS . map ( ( data ) => (
23
+ { TODO_STATUS . map ( ( data ) => (
24
24
< Menu . Item key = { data . id } > { data . key } </ Menu . Item >
25
25
) ) }
26
26
</ Menu >
Original file line number Diff line number Diff line change @@ -2,5 +2,6 @@ export { default as DeleteTodo } from './DeleteTodo';
2
2
export { default as TodoActionControls } from './TodoActionControls' ;
3
3
export { default as TodoBox } from './TodoBox' ;
4
4
export { default as TodoDelete } from './TodoDelete' ;
5
+ export { default as TodoLabel } from './TodoLabel' ;
5
6
export { default as TodoList } from './TodoList' ;
6
7
export { default as TodoStatusChange } from './TodoStatusChange' ;
Original file line number Diff line number Diff line change 1
1
export const USER_INFO_LOCAL_STORAGE_KEY = 'toDoUserInfo' ;
2
2
3
- export const STATUS = [
3
+ export const TODO_STATUS = [
4
4
{ id : 1 , key : 'New' } ,
5
5
{ id : 2 , key : 'Inprogress' } ,
6
6
{ id : 3 , key : 'Completed' } ,
Original file line number Diff line number Diff line change 66
66
}
67
67
}
68
68
}
69
+
70
+ .title-label {
71
+ text-align : center ;
72
+ text-transform : uppercase ;
73
+ font-weight : bold ;
74
+ font-size : 16px ;
75
+ }
You can’t perform that action at this time.
0 commit comments