Calendar Events Getting Day Month And Year

master
Pedram Keshavarzi 3 years ago
parent fe22886ea0
commit bf4d7a1ec7
  1. 2
      src/App.css
  2. 27
      src/components/Calendar/CalendarComponents/components/DaysList.js
  3. 20
      src/components/Calendar/index.js

@ -3,5 +3,5 @@ body{
} }
*{ *{
font-family: iranSansX; font-family: 'iranSans';
} }

@ -159,6 +159,7 @@ const DaysList = ({
const customDayItemClassName = customDaysClassName.find((day) => const customDayItemClassName = customDaysClassName.find((day) =>
isSameDay(dayItem, day) isSameDay(dayItem, day)
); );
const classNames = '' const classNames = ''
.concat(isToday && !isSelected ? ` -today ${calendarTodayClassName}` : '') .concat(isToday && !isSelected ? ` -today ${calendarTodayClassName}` : '')
.concat(!dayItem.isStandard ? ' -blank' : '') .concat(!dayItem.isStandard ? ' -blank' : '')
@ -254,23 +255,23 @@ const DaysList = ({
isOnActiveSlide, isOnActiveSlide,
isStandard, isStandard,
}); });
const specialDay = (sDay) => { const specialDate = (sDay, sMonth, sYear) => {
var eventDate;
for (var i = 0; i < events.length; i++) { for (var i = 0; i < events.length; i++) {
if (sDay == events[i].day) { if (sDay == events[i].day && sMonth == events[i].month && sYear == events[i].year) {
return sDay;
return (sDay, sMonth, sYear);
} }
} }
}; };
const showEventDescription = (sDay) => {
var eventDate;
const showEventDescription = (sDay , sMonth, sYear) => {
for (var i = 0; i < events.length; i++) { for (var i = 0; i < events.length; i++) {
if (sDay == events[i].day) { if (sDay == events[i].day && sMonth == events[i].month && sYear == events[i].year) {
return (events[i].description); return(events[i].description);
} }
} }
@ -288,8 +289,10 @@ const DaysList = ({
className={`Calendar__day -${isRtl ? 'rtl' : 'ltr'} ${additionalClass}`} className={`Calendar__day -${isRtl ? 'rtl' : 'ltr'} ${additionalClass}`}
onClick={() => { onClick={() => {
handleDayPress({ ...dayItem, isDisabled }); handleDayPress({ ...dayItem, isDisabled });
console.log(specialDay(day)); console.log(specialDate(day));
showEvent(showEventDescription(day)) console.log(showEventDescription(day))
showEvent(showEventDescription(day, month, year))
console.log(month)
}} }}
onKeyDown={({ key }) => { onKeyDown={({ key }) => {
/* istanbul ignore else */ /* istanbul ignore else */
@ -307,7 +310,7 @@ const DaysList = ({
data-is-default-selectable={shouldEnableKeyboardNavigation} data-is-default-selectable={shouldEnableKeyboardNavigation}
> >
{!isStandard ? '' : getLanguageDigits(day)} {!isStandard ? '' : getLanguageDigits(day)}
{specialDay(day) == day ? <span>.</span> : ' '} {specialDate(day, month, year) == (day, month, year) ? <span>.</span> : ' '}
</div> </div>
); );
}; };

@ -31,8 +31,8 @@ const eventsList = [
type: "global", type: "global",
isHoliday: true, isHoliday: true,
date: "2022-01-04T00:00:00.000Z", date: "2022-01-04T00:00:00.000Z",
year: 2022, year: 1400,
month: 1, month: 10,
day: 2 day: 2
}, },
{ {
@ -41,8 +41,8 @@ const eventsList = [
type: "global", type: "global",
isHoliday: true, isHoliday: true,
date: "2022-01-12T00:00:00.000Z", date: "2022-01-12T00:00:00.000Z",
year: 2022, year: 1400,
month: 1, month: 10,
day: 1 day: 1
}, },
{ {
@ -52,8 +52,8 @@ const eventsList = [
userId: "5", userId: "5",
date: "2022-01-12T00:00:00.000Z", date: "2022-01-12T00:00:00.000Z",
categoryId: 1, categoryId: 1,
year: 2022, year: 1400,
month: 1, month: 11,
day: 3 day: 3
}, },
{ {
@ -63,8 +63,8 @@ const eventsList = [
userId: "5", userId: "5",
date: "2022-01-08T00:00:00.000Z", date: "2022-01-08T00:00:00.000Z",
categoryId: 3, categoryId: 3,
year: 2022, year: 1400,
month: 1, month: 11,
day: 6 day: 6
}, },
{ {
@ -74,8 +74,8 @@ const eventsList = [
userId: "5", userId: "5",
date: "2022-01-12T00:00:00.000Z", date: "2022-01-12T00:00:00.000Z",
categoryId: 1, categoryId: 1,
year: 2022, year: 1400,
month: 1, month: 10,
day: 3 day: 3
} }
]; ];

Loading…
Cancel
Save