* [#497 & #517] updated event editability in the calendar grid to prevent accidental editing and editing event we are not organizer of
This commit is contained in:
@@ -693,7 +693,9 @@ export default function CalendarApp({
|
|||||||
events={eventToFullCalendarFormat(
|
events={eventToFullCalendarFormat(
|
||||||
filteredEvents,
|
filteredEvents,
|
||||||
filteredTempEvents,
|
filteredTempEvents,
|
||||||
userId
|
userId,
|
||||||
|
userData?.email,
|
||||||
|
isPending
|
||||||
)}
|
)}
|
||||||
eventOrder={(a: any, b: any) =>
|
eventOrder={(a: any, b: any) =>
|
||||||
a.extendedProps.priority - b.extendedProps.priority
|
a.extendedProps.priority - b.extendedProps.priority
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ export function formatEventChipTitle(e: CalendarEvent, t: Function) {
|
|||||||
export const eventToFullCalendarFormat = (
|
export const eventToFullCalendarFormat = (
|
||||||
filteredEvents: CalendarEvent[],
|
filteredEvents: CalendarEvent[],
|
||||||
filteredTempEvents: CalendarEvent[],
|
filteredTempEvents: CalendarEvent[],
|
||||||
userId: string | undefined
|
userId: string | undefined,
|
||||||
|
userAddress: string | undefined,
|
||||||
|
pending: boolean
|
||||||
) => {
|
) => {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
return filteredEvents
|
return filteredEvents
|
||||||
@@ -76,14 +78,17 @@ export const eventToFullCalendarFormat = (
|
|||||||
.map((e) => {
|
.map((e) => {
|
||||||
const eventTimezone = e.timezone || "Etc/UTC";
|
const eventTimezone = e.timezone || "Etc/UTC";
|
||||||
const isAllDay = e.allday ?? false;
|
const isAllDay = e.allday ?? false;
|
||||||
const isPersonnalEvent = extractEventBaseUuid(e.calId) === userId;
|
const isOrganiser = e.organizer
|
||||||
|
? e.organizer.cal_address?.toLowerCase() === userAddress?.toLowerCase()
|
||||||
|
: true; // if there are no organizer in the event we assume it was organized by the owner
|
||||||
|
const isPersonnalEvent =
|
||||||
|
extractEventBaseUuid(e.calId) === userId && isOrganiser;
|
||||||
const convertedEvent: any = {
|
const convertedEvent: any = {
|
||||||
...e,
|
...e,
|
||||||
title: formatEventChipTitle(e, t),
|
title: formatEventChipTitle(e, t),
|
||||||
colors: e.color,
|
colors: e.color,
|
||||||
editable: isPersonnalEvent,
|
editable: isPersonnalEvent,
|
||||||
priority: isPersonnalEvent ? 1 : 0,
|
priority: isPersonnalEvent && !pending ? 1 : 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isAllDay && e.start && eventTimezone) {
|
if (!isAllDay && e.start && eventTimezone) {
|
||||||
|
|||||||
Reference in New Issue
Block a user