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 11import React , { useState , useEffect } from 'react' ;
22import { 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
66export 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 ) ) }
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { Menu , Dropdown , message } from 'antd' ;
33import { API } from '../../services' ;
4- import { STATUS } from '../../helpers/constants' ;
4+ import { TODO_STATUS } from '../../helpers/constants' ;
55
66export 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 >
Original file line number Diff line number Diff line change @@ -2,5 +2,6 @@ export { default as DeleteTodo } from './DeleteTodo';
22export { default as TodoActionControls } from './TodoActionControls' ;
33export { default as TodoBox } from './TodoBox' ;
44export { default as TodoDelete } from './TodoDelete' ;
5+ export { default as TodoLabel } from './TodoLabel' ;
56export { default as TodoList } from './TodoList' ;
67export { default as TodoStatusChange } from './TodoStatusChange' ;
Original file line number Diff line number Diff line change 11export 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' } ,
Original file line number Diff line number Diff line change 6666 }
6767 }
6868}
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