only use blocked date and no published date for blocking;

allow any date to be selected as block date - not only the end of the month
This commit is contained in:
Dobromir Popov
2024-09-17 23:18:51 +03:00
parent 1d4696f0f7
commit bab62816b0
7 changed files with 699 additions and 22 deletions

View File

@ -51,15 +51,15 @@ const messages = {
const AvCalendar = ({ publisherId, events, selectedDate, cartEvents, lastPublishedDate }) => {
const [editLockedBefore, setEditLockedBefore] = useState(new Date(lastPublishedDate));
const [isAdmin, setIsAdmin] = useState(false);
const [isPowerUser, setIsPowerUser] = useState(false);
const [currentUserId, setCurrentUserId] = useState(null);
// const [isPowerUser, setIsPowerUser] = useState(false);
// const [currentUserId, setCurrentUserId] = useState(null);
useEffect(() => {
(async () => {
try {
setIsAdmin(await ProtectedRoute.IsInRole(UserRole.ADMIN));
setIsPowerUser(await ProtectedRoute.IsInRole(UserRole.POWERUSER));
// Assuming you have a way to get the current user's ID
setCurrentUserId(await ProtectedRoute.GetCurrentUserId());
// setIsPowerUser(await ProtectedRoute.IsInRole(UserRole.POWERUSER));
// // Assuming you have a way to get the current user's ID
// setCurrentUserId(await ProtectedRoute.GetCurrentUserId());
} catch (error) {
console.error("Failed to check admin role:", error);
}
@ -262,9 +262,9 @@ const AvCalendar = ({ publisherId, events, selectedDate, cartEvents, lastPublish
if (!start || !end) return;
//readonly for past dates (ToDo: if not admin or current user)
const isCurrentUser = selectedEvents.some(event => event.userId === currentUserId);
//const isCurrentUser = selectedEvents.some(event => event.userId === currentUserId);
if (!isAdmin && !isCurrentUser) {
if (!isAdmin) {
if (startdate < new Date() || end < new Date() || startdate > end) return;
//or if schedule is published (lastPublishedDate)
if (editLockedBefore && startdate < editLockedBefore) {