@@ -7,10 +7,27 @@ import toast from "react-hot-toast";
7
7
import { useDispatch } from "react-redux" ;
8
8
import { updateTask } from "../../redux/tasks/operations.js" ;
9
9
import { useParams } from "react-router-dom" ;
10
+ import { DatePicker } from "@mui/x-date-pickers" ;
11
+ import { LocalizationProvider } from "@mui/x-date-pickers" ;
12
+ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs" ;
13
+ import { useState } from "react" ;
14
+ import dayjs from "dayjs" ;
15
+ import Stack from '@mui/material/Stack' ;
16
+ import IconButton from '@mui/material/IconButton' ;
17
+ import ChevronLeft from '@mui/icons-material/ChevronLeft' ;
18
+ import ChevronRight from '@mui/icons-material/ChevronRight' ;
19
+ import { styled } from '@mui/material/styles' ;
20
+ import Typography from '@mui/material/Typography' ;
21
+ import SvgIcon from '@mui/material/SvgIcon' ;
10
22
11
23
Modal . setAppElement ( "#root" ) ;
12
24
13
25
export const EditCard = ( { isOpen, isClose, task } ) => {
26
+ const [ selectedDate , setSelectedDate ] = useState ( dayjs ( task . deadline ) ) ;
27
+ const changeDate = ( valueDate ) => {
28
+ setSelectedDate ( valueDate )
29
+ }
30
+
14
31
const dispatch = useDispatch ( ) ;
15
32
const { deskId } = useParams ( ) ;
16
33
const taskModalValidation = Yup . object ( ) . shape ( {
@@ -26,11 +43,77 @@ export const EditCard = ({ isOpen, isClose, task }) => {
26
43
27
44
const taskEditNotify = ( ) => toast . success ( "You edited the task" ) ;
28
45
46
+ const CustomCalendarHeaderRoot = styled ( 'div' ) ( {
47
+ display : 'flex' ,
48
+ justifyContent : 'space-between' ,
49
+ alignItems : 'center' ,
50
+ borderBottom : '1px solid #000000' ,
51
+ backgroundColor : '#1F1F1F'
52
+ } ) ;
53
+
54
+ const CustomDatePicker = styled ( DatePicker ) ( {
55
+ '& .MuiInputBase-root' : {
56
+ display : 'flex' ,
57
+ alignItems : 'center' ,
58
+ backgroundColor : '#151515' ,
59
+ color : '#BEDBB0' ,
60
+ fontFamily : 'Poppins, sans-serif !important' ,
61
+ fontSize : '14px' ,
62
+ fontWeight : '500' ,
63
+ lineHeight : '21px' ,
64
+ letterSpacing : '-0.02em' ,
65
+ textAlign : 'left' ,
66
+ } ,
67
+ '& .MuiInputBase-input' : {
68
+ padding : '0' ,
69
+ width : 'auto' ,
70
+ } ,
71
+ '& .MuiOutlinedInput-notchedOutline' : {
72
+ border : 'none' ,
73
+ } ,
74
+ '&:hover .MuiOutlinedInput-notchedOutline' : {
75
+ borderColor : '#FFFFFF' ,
76
+ }
77
+ } ) ;
78
+
79
+
80
+ const calendarIcon = ( ) => {
81
+ return (
82
+ < SvgIcon >
83
+ < use className = { css . chevronIconDown } href = { svg + "#chevron-down-icon" } />
84
+ </ SvgIcon >
85
+ ) ;
86
+ }
87
+
88
+ function CustomCalendarHeader ( props ) {
89
+ const { currentMonth, onMonthChange } = props ;
90
+
91
+ const selectNextMonth = ( ) => onMonthChange ( currentMonth . add ( 1 , 'month' ) , 'left' ) ;
92
+ const selectPreviousMonth = ( ) =>
93
+ onMonthChange ( currentMonth . subtract ( 1 , 'month' ) , 'right' ) ;
94
+
95
+ return (
96
+ < CustomCalendarHeaderRoot >
97
+ < Stack spacing = { 1 } direction = "row" >
98
+ < IconButton onClick = { selectPreviousMonth } title = "Previous month" >
99
+ < ChevronLeft className = { css . chevron } />
100
+ </ IconButton >
101
+ </ Stack >
102
+ < Typography variant = "body2" className = { css . customTypography } > { currentMonth . format ( 'MMMM YYYY' ) } </ Typography >
103
+ < Stack spacing = { 1 } direction = "row" >
104
+ < IconButton onClick = { selectNextMonth } title = "Next month" >
105
+ < ChevronRight className = { css . chevron } />
106
+ </ IconButton >
107
+ </ Stack >
108
+ </ CustomCalendarHeaderRoot >
109
+ ) ;
110
+ }
111
+
29
112
const handleSubmit = ( values ) => {
30
113
const updatedTask = {
31
114
title : values . cardtitle ,
32
115
description : values . carddescription ,
33
- deadline : "2024-06-14T23:59:59.000+00:00" ,
116
+ deadline : selectedDate ,
34
117
priority : values . priority ,
35
118
} ;
36
119
dispatch (
@@ -138,6 +221,19 @@ export const EditCard = ({ isOpen, isClose, task }) => {
138
221
</ div >
139
222
</ label >
140
223
224
+ < div className = { css . createCardModalDateContainer } >
225
+ < p className = { css . deadlineText } > Deadline</ p >
226
+ < LocalizationProvider dateAdapter = { AdapterDayjs } >
227
+ < CustomDatePicker
228
+ value = { selectedDate }
229
+ onChange = { changeDate }
230
+ format = { dayjs ( selectedDate ) . format ( 'DD/MM/YYYY' ) === dayjs ( ) . format ( 'DD/MM/YYYY' ) ? 'Today, MMMM DD' : 'dddd, MMMM DD' }
231
+ slots = { { openPickerIcon : calendarIcon , calendarHeader : CustomCalendarHeader } }
232
+ minDate = { dayjs ( ) }
233
+ />
234
+ </ LocalizationProvider >
235
+ </ div >
236
+
141
237
< button type = "submit" className = { css . editCardModalSubmit } >
142
238
< span className = { css . editCardModalSpan } >
143
239
< svg
0 commit comments