Skip to content

Commit de50db1

Browse files
authored
Merge pull request #26 from Naetffy/Juanes
Juanes
2 parents 545f4e9 + 169648c commit de50db1

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/pages/Calendar/Calendar.css

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,27 @@
2525
}
2626

2727
.highlight {
28-
background-color: #E1E6F0 !important;
29-
border-radius: 50%;
28+
background-color: #E1E6F0 !important;
29+
border-radius: 50%;
3030
}
3131

3232
.react-calendar__tile--active {
3333
background-color: #007bff;
34-
color: #fff;
34+
color: #fff;
3535
}
3636

3737
.react-calendar__tile--active:enabled:focus,
3838
.react-calendar__tile--active:enabled:hover,
3939
.react-calendar__tile--active:enabled:active {
40-
background-color: #86654b;
40+
background-color: #86654b;
4141
}
4242

4343
.react-calendar__tile--now {
4444
background-color: #A4826D;
45-
color: #333;
45+
color: #333;
4646
}
4747

4848
.highlight-today {
4949
background-color: #FFE4B5 !important;
5050
border-radius: 50%;
5151
}
52-
53-
54-
55-
56-

src/pages/Calendar/Calendar.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ import apiClient from '../../services/apiClient';
1010
const CalendarPage = () => {
1111
const [date, setDate] = useState(new Date());
1212
const [outfitDates, setOutfitDates] = useState([]);
13-
14-
const onChange = (date) => {
15-
setDate(date);
16-
};
13+
const [todayHasOutfit, setTodayHasOutfit] = useState(false);
1714

1815
useEffect(() => {
1916
const fetchOutfitDates = async () => {
2017
try {
21-
const response = await apiClient.get('/outfit/dates'); // Cambia la ruta según tu API
22-
setOutfitDates(response.data);
18+
const response = await apiClient.get('/day/all');
19+
const datesWithOutfit = response.data.filter(day => day.outfitId !== null).map(day => new Date(day.date));
20+
setOutfitDates(datesWithOutfit);
21+
22+
const todayDateString = new Date().toISOString().split('T')[0];
23+
const todayHasOutfit = datesWithOutfit.some(date => date.toISOString().split('T')[0] === todayDateString);
24+
setTodayHasOutfit(todayHasOutfit);
2325
} catch (error) {
2426
console.error('Error fetching outfit dates:', error);
2527
}
@@ -28,15 +30,24 @@ const CalendarPage = () => {
2830
fetchOutfitDates();
2931
}, []);
3032

33+
const onChange = (date) => {
34+
setDate(date);
35+
};
36+
3137
const tileClassName = ({ date, view }) => {
38+
if (view === 'month' && date.toDateString() === new Date().toDateString()) {
39+
return todayHasOutfit ? 'highlight-today' : null;
40+
}
3241
if (view === 'month') {
3342
const dateString = date.toISOString().split('T')[0];
34-
if (outfitDates.includes(dateString)) {
43+
if (outfitDates.some(outfitDate => outfitDate.toISOString().split('T')[0] === dateString)) {
3544
return 'highlight';
3645
}
3746
}
3847
return null;
3948
};
49+
50+
4051

4152
return (
4253
<div className='col-12'>
@@ -68,3 +79,5 @@ const CalendarPage = () => {
6879

6980
export default CalendarPage;
7081

82+
83+

0 commit comments

Comments
 (0)