(wip) - show repeating events in calendar (admin)
script to get jwt signature for Apple ID
This commit is contained in:
@ -17,7 +17,7 @@ import { MdToday } from 'react-icons/md';
|
||||
import { useSwipeable } from 'react-swipeable';
|
||||
import axiosInstance from '../../src/axiosSecure';
|
||||
// import { set, format, addDays } from 'date-fns';
|
||||
import { isEqual, isSameDay, getHours, getMinutes } from 'date-fns';
|
||||
// import { isEqual, isSameDay, getHours, getMinutes } from 'date-fns';
|
||||
import { filter } from 'jszip';
|
||||
import e from 'express';
|
||||
|
||||
@ -170,6 +170,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
|
||||
};
|
||||
const filterEvents = (evts, publisherId, startdate) => {
|
||||
setDate(startdate); // Assuming setDate is a function that sets some state or context
|
||||
const filterHHmm = new Date(startdate).getHours() * 100 + new Date(startdate).getMinutes();
|
||||
|
||||
// Filter events based on the publisher ID and the start date/time
|
||||
const existingEvents = evts?.filter(event => {
|
||||
@ -177,15 +178,15 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
|
||||
const isPublisherMatch = (event.publisher?.id || event.publisherId) === publisherId;
|
||||
|
||||
let isDateMatch;
|
||||
const eventDate = new Date(event.startTime);
|
||||
if (event.repeatWeekly && event.date) {
|
||||
// Compare only the time part
|
||||
const eventDate = new Date(event.startTime);
|
||||
const isSameHour = getHours(eventDate) === getHours(startdate);
|
||||
const isSameMinute = getMinutes(eventDate) === getMinutes(startdate);
|
||||
isDateMatch = isSameHour && isSameMinute;
|
||||
let evenStarttHHmm = eventDate.getHours() * 100 + eventDate.getMinutes();
|
||||
let eventEndHHmm = eventDate.getHours() * 100 + eventDate.getMinutes();
|
||||
isDateMatch = filterHHmm >= evenStarttHHmm && filterHHmm <= eventEndHHmm;
|
||||
} else if (event.date) {
|
||||
// Compare the full date
|
||||
isDateMatch = isSameDay(new Date(event.date), startdate);
|
||||
// Compare the full date. issameday is not working. do it manually
|
||||
isDateMatch = eventDate.setHours(0, 0, 0, 0) === new Date(startdate).setHours(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
return isPublisherMatch && isDateMatch;
|
||||
@ -203,7 +204,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
|
||||
maxTime.setHours(maxHour, 0, 0);
|
||||
const totalHours = maxHour - minHour;
|
||||
|
||||
const handleSelect = ({ start, end }) => {
|
||||
const handleSelect = ({ mode, start, end }) => {
|
||||
const startdate = typeof start === 'string' ? new Date(start) : start;
|
||||
const enddate = typeof end === 'string' ? new Date(end) : end;
|
||||
|
||||
@ -230,6 +231,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
|
||||
setDate(start);
|
||||
|
||||
// get exising events for the selected date
|
||||
//ToDo: properly fix this. filterEvents does not return the expcted results
|
||||
let existingEvents = filterEvents(evts, publisherId, startdate);
|
||||
// if existingEvents is empty - create new with the selected range
|
||||
if (existingEvents.length === 0) {
|
||||
|
Reference in New Issue
Block a user