Skip to content

Commit 42e9459

Browse files
authored
Merge pull request #117 from AnWhiteM/column-modals
add calendar in editCardModal
2 parents 39c4595 + a9fb4a5 commit 42e9459

File tree

2 files changed

+130
-1
lines changed

2 files changed

+130
-1
lines changed

src/components/EditCardModal/EditCardModal.jsx

+97-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,27 @@ import toast from "react-hot-toast";
77
import { useDispatch } from "react-redux";
88
import { updateTask } from "../../redux/tasks/operations.js";
99
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';
1022

1123
Modal.setAppElement("#root");
1224

1325
export const EditCard = ({ isOpen, isClose, task }) => {
26+
const [selectedDate, setSelectedDate] = useState(dayjs(task.deadline));
27+
const changeDate = (valueDate) => {
28+
setSelectedDate(valueDate)
29+
}
30+
1431
const dispatch = useDispatch();
1532
const { deskId } = useParams();
1633
const taskModalValidation = Yup.object().shape({
@@ -26,11 +43,77 @@ export const EditCard = ({ isOpen, isClose, task }) => {
2643

2744
const taskEditNotify = () => toast.success("You edited the task");
2845

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+
29112
const handleSubmit = (values) => {
30113
const updatedTask = {
31114
title: values.cardtitle,
32115
description: values.carddescription,
33-
deadline: "2024-06-14T23:59:59.000+00:00",
116+
deadline: selectedDate,
34117
priority: values.priority,
35118
};
36119
dispatch(
@@ -138,6 +221,19 @@ export const EditCard = ({ isOpen, isClose, task }) => {
138221
</div>
139222
</label>
140223

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+
141237
<button type="submit" className={css.editCardModalSubmit}>
142238
<span className={css.editCardModalSpan}>
143239
<svg

src/components/EditCardModal/EditCardModal.module.css

+33
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,39 @@ input[type="radio"]:checked {
7777
margin-bottom: 20px;
7878
}
7979

80+
.createCardModalDateContainer {
81+
display: flex;
82+
flex-direction: column;
83+
margin-bottom: 30px;
84+
}
85+
86+
.deadlineText {
87+
font-family: 'Poppins', sans-serif;
88+
font-size: 12px;
89+
font-weight: 400;
90+
line-height: 18px;
91+
letter-spacing: -0.02em;
92+
color: #FFFFFF80;
93+
}
94+
95+
.calendar {
96+
width: 233px;
97+
height: 254px;
98+
}
99+
100+
.customTypography {
101+
font-family: 'Poppins', sans-serif !important;
102+
color: #FFFFFF;
103+
}
104+
105+
.chevron {
106+
fill: #FFFFFF !important;
107+
}
108+
109+
.chevronIconDown {
110+
stroke: #BEDBB0 !important;
111+
}
112+
80113
@media print {
81114
input[type="radio"] {
82115
-webkit-appearance: auto;

0 commit comments

Comments
 (0)