I am using the syncfusion to do the Scheduler calendar in the react code to block specific time intervals or days. Below the code is worked to block specific time intervals or days following by Subject, Doctor,StartTime, EndTime,RecurrenceRule and IsBlock
in the return value, But this method just can follow each Doctor
to block the date or time.
May I know how to block all doctors following by Subject, Doctor(This one how can choose all the doctor together),StartTime, EndTime,RecurrenceRule and IsBlock
in my existing code? I set all doctor's values as dash -
.
Below is my existing code to block specific time intervals or days following by Subject, Doctor,StartTime, EndTime,RecurrenceRule and IsBlock
in the return value:
const getOrganizer = useCallback(() => {
getSchedulerOrganizerList().then((response) => {
var data = response.data;
setOrganizerList(
data.map((schedulerBlock) => {
var startDate = new Date(
formatDateStringAsDate2(schedulerBlock.startDate)
);
var endDate = new Date(
formatDateStringAsDate2(schedulerBlock.stopDate)
);
var count = null;
var repeatType = schedulerBlock.repeatType.toUpperCase();
if (repeatType === "DAILY") {
var Difference_In_Days = getDayDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Days;
} else if (repeatType === "WEEKLY") {
var Difference_In_Weeks = getWeekDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Weeks;
} else if (repeatType === "MONTHLY") {
var Difference_In_Months = getMonthDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Months;
} else if (repeatType === "YEARLY") {
var Difference_In_Years = getYearDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Years;
} else if (repeatType === "ONE TIME") {
repeatType = "ONE TIME";
}
var formatStopDate = moment(schedulerBlock.stopDate).format("YYYY-MM-DD");
var formatStopTime = moment(schedulerBlock.stopTime).format("HH:mm:ss");
var stopTimeValue = formatStopDate + "T" + formatStopTime;
var recurrenceRule = repeatType === "ONE TIME" ? null : "FREQ=" + repeatType + count;
var endTimeValue = repeatType === "ONE TIME" ? formatDateTimeStringAsDateTime(stopTimeValue) : formatDateTimeStringAsDateTime(schedulerBlock.stopTime);
return {
Id: schedulerBlock.id,
Subject: schedulerBlock.reason,
Doctor: schedulerBlock.doctor,
StartTime: formatDateTimeStringAsDateTime(schedulerBlock.startDate),
EndTime: endTimeValue,
RecurrenceRule: recurrenceRule,
IsBlock: true,
};
})
);
});
}, []);
Below is my sample return value for Dr X:
{
"Id": 19,
"Subject": "Test",
"Doctor": "Dr X",
"StartTime": "15 Aug 2022 09:00 PM",
"EndTime": "15 Aug 2022 11:00 PM",
"RecurrenceRule": "FREQ=WEEKLY;COUNT=8",
"IsBlock": true
}
Below are my current code results, in the calendar view I have 3 doctors which are Dr X, Dr Y, and Dr Z. I have blocked the Dr X at 9PM - 11 PM (August 15, 2022).
Now I am trying to do to block all doctors following by Subject, Doctor(This one how can choose all the doctor together),StartTime, EndTime,RecurrenceRule and IsBlock
in my existing code I set all doctor's values as dash -
, below coding is what I am trying, I try to hardcode the value -
to test, but it doesn't work.
const getOrganizer = useCallback(() => {
getSchedulerOrganizerList().then((response) => {
var data = response.data;
setOrganizerList(
data.map((schedulerBlock) => {
var startDate = new Date(
formatDateStringAsDate2(schedulerBlock.startDate)
);
var endDate = new Date(
formatDateStringAsDate2(schedulerBlock.stopDate)
);
var count = null;
var repeatType = schedulerBlock.repeatType.toUpperCase();
if (repeatType === "DAILY") {
var Difference_In_Days = getDayDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Days;
} else if (repeatType === "WEEKLY") {
var Difference_In_Weeks = getWeekDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Weeks;
} else if (repeatType === "MONTHLY") {
var Difference_In_Months = getMonthDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Months;
} else if (repeatType === "YEARLY") {
var Difference_In_Years = getYearDiff(startDate, endDate) + 1;
count = ";COUNT=" + Difference_In_Years;
} else if (repeatType === "ONE TIME") {
repeatType = "ONE TIME";
}
var formatStopDate = moment(schedulerBlock.stopDate).format("YYYY-MM-DD");
var formatStopTime = moment(schedulerBlock.stopTime).format("HH:mm:ss");
var stopTimeValue = formatStopDate + "T" + formatStopTime;
var recurrenceRule = repeatType === "ONE TIME" ? null : "FREQ=" + repeatType + count;
var endTimeValue = repeatType === "ONE TIME" ? formatDateTimeStringAsDateTime(stopTimeValue) : formatDateTimeStringAsDateTime(schedulerBlock.stopTime);
var schedulerBlockDoctor = schedulerBlock.doctor;
if (schedulerBlockDoctor === "-"){
var schedulerBlockDoctor = " ";
}
return {
Id: schedulerBlock.id,
Subject: schedulerBlock.reason,
Doctor: schedulerBlockDoctor,
StartTime: formatDateTimeStringAsDateTime(schedulerBlock.startDate),
EndTime: endTimeValue,
RecurrenceRule: recurrenceRule,
IsBlock: true,
};
})
);
});
}, []);
I want the expected result like below the picture if I choose all doctors to need to block at the same time and date (all doctors value is put dash -
to declare),
Hope anyone can guide me on how to solve this problem, is possible to get a simple way to edit my existing code? Thanks.