The scheduler does not conform to the outside parent div no matter what I try, the second issue is that when I change the viewType, from day to week or month, the entire scheduler expands outside the div and will not look functional.
If I rerender the component it reshapes itself back to a normal size, but its still not conforming to the outside div.
None have worked so far, from my understanding it seems that the resource table have a dynamic width that increases its size dependent on the width rather than the events table.
What could it be and what should I be trying? I would really like this to work in my application.
const schedulerParentRef = useRef();
var today = new Date();
var date = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate();
let schedulerData = new SchedulerData(
date,
ViewType.Day, // Change the status of daily, weekly or monthly
false,
false,
{
eventItemPopoverPlacement: "bottomRightMousePosition",
responsiveByParent: true,
besidesWidth: window.innerWidth <= 1600 ? 100 : 350,
startResizable: false,
endResizable: false,
schedulerContentHeight: "100%",
weekCellWidth: 80,
dayCellWidth: 40,
}
);
schedulerData.setResources([]);
schedulerData.setEvents([]);
useEffect(() => {
dispatch(initialiseViewModel(schedulerData));
return () => dispatch(reInitialiseViewModel());
}, [date, dispatch, initialiseViewModel, reInitialiseViewModel]);
const changeDate = (e) => {
setDateState(e);
};
const getResources = useCallback(() => {
getAuthorization()
.get(`company/get_companyschedule_recources?assigned_to=${DropDownValue}`)
.then((res) => {
setResources(res.data.message ? [] : res.data);
dispatch(setAPIDetailsUser(res.data.message ? [] : res.data));
getEvents(); // Get events after resources have been set
})
.catch((err) => {
console.log("Error in getting schedule", err);
});
}, [dispatch, DropDownValue]);
const getEvents = useCallback(() => {
getAuthorization()
.get(`company/get_companyschedule_events?assigned_to=${DropDownValue}`)
.then((res) => {
setEvents(res.data.message ? [] : res.data);
dispatch(setAPIDetailsUserEvents(res.data.message ? [] : res.data));
setDataLoaded(true); // Set dataLoaded to true after both resources and events are set
})
.catch((err) => {
console.log("Error in getting schedule", err);
});
}, [dispatch, DropDownValue]);
//Set Scheduler Data
useEffect(() => {
if (dataLoaded) {
viewModel.setResources(Resources);
viewModel.setEvents(Events);
dispatch(setViewModel(viewModel));
setDataLoaded(false); // Reset after processing the loaded data
}
}, [dataLoaded, Resources, Events, DropDownValue]);
useEffect(() => {
setDataLoaded(false); // Reset the dataLoaded state before fetching
getResources();
}, [DropDownValue, getResources]);
const prevClick = (schedulerData) => {
schedulerData.prev();
schedulerData.setEvents(Events);
dispatch(setViewModel(schedulerData));
};
const nextClick = (schedulerData) => {
schedulerData.next();
schedulerData.setEvents(Events);
dispatch(setViewModel(schedulerData));
};
const onViewChange = (schedulerData, view) => {
schedulerData.setViewType(view.viewType, view.showAgenda, view.isEventPerspective);
schedulerData.setEvents(Events);
dispatch(setViewModel(schedulerData));
};
const onSelectDate = (schedulerData, date) => {
schedulerData.setDate(date);
schedulerData.setEvents(Events);
dispatch(setViewModel(schedulerData));
};
const eventClicked = (schedulerData, event) => {
setOpen(true);
getAuthorization()
.get(`company/schedule_view/${event.id}/`)
.then((res) => {
setScheduleDetails(res.data);
setDateState([new Date(`${res.data.start_date}`), new Date(`${res.data.end_date}`)]);
})
.catch((err) => {
console.log("Error in getting schedule details", err);
});
};
const ops1 = (schedulerData, event) => {
setOpen(true);
getAuthorization()
.get(`company/schedule_detail/${event.id}/`)
.then((res) => {
setScheduleDetails(res.data);
})
.catch((err) => {
console.log("Error in getting schedule details", err);
});
// alert(
// `You just executed ops1 to event: {id: ${event.id}, title: ${
// event.title
// }}`
// );
};
return (
<div className="w-full" ref={schedulerParentRef}>
{displayTimeline && (
<div className="-mt-4" style={{ marginLeft: "auto" }}>
<Scheduler
parentRef={schedulerParentRef}
schedulerData={viewModel}
prevClick={prevClick}
nextClick={nextClick}
onSelectDate={onSelectDate}
onViewChange={onViewChange}
eventItemClick={eventClicked}
viewEventClick={ops1}
viewEventText="Details"
/>
</div>
)}