Fix Ts errors and deletion failure message
This commit is contained in:
parent
4b7016d3d3
commit
a94b968303
|
@ -39,6 +39,11 @@ export function canEventBeEdited({
|
|||
} | null;
|
||||
};
|
||||
}) {
|
||||
// I am the creator of the event.
|
||||
if (eventType.userId === user.id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if he is the owner of the team to which event belongs
|
||||
if (eventType.team) {
|
||||
return eventType.team.members
|
||||
|
@ -48,7 +53,5 @@ export function canEventBeEdited({
|
|||
.map((member) => member.userId)
|
||||
.includes(user.id);
|
||||
}
|
||||
|
||||
// Fallback case for Events with creatorId default value
|
||||
return eventType.userId === user.id || eventType.users.find((user) => user.id === user.id);
|
||||
return eventType.users.find((user) => user.id === user.id);
|
||||
}
|
||||
|
|
|
@ -189,10 +189,17 @@ export const EventTypeList = ({ group, groupIndex, types, profile }: EventTypeLi
|
|||
showToast(t("event_type_deleted_successfully"), "success");
|
||||
},
|
||||
onError: (err) => {
|
||||
let message: string;
|
||||
if (err instanceof HttpError) {
|
||||
const message = `${err.statusCode}: ${err.message}`;
|
||||
showToast(message, "error");
|
||||
message = `${err.statusCode}: ${err.message}`;
|
||||
}
|
||||
|
||||
if (err.data?.code === "UNAUTHORIZED") {
|
||||
message = `${err.data.code}: You are not able to delete this event`;
|
||||
} else {
|
||||
message = "Some Error Occurred";
|
||||
}
|
||||
showToast(message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -240,7 +240,6 @@ const loggedInViewerRouter = createProtectedRouter()
|
|||
};
|
||||
metadata: {
|
||||
membershipCount: number;
|
||||
readonly: boolean;
|
||||
};
|
||||
eventTypes: (typeof user.eventTypes[number] & { $disabled?: boolean; readOnly?: boolean })[];
|
||||
};
|
||||
|
|
|
@ -117,7 +117,7 @@ export const eventTypesRouter = createProtectedRouter()
|
|||
|
||||
const data: Prisma.EventTypeCreateInput = {
|
||||
...rest,
|
||||
userId: teamId ? undefined : userId,
|
||||
userId: userId,
|
||||
users: {
|
||||
connect: {
|
||||
id: userId,
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "creatorId" INTEGER;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventType" ADD CONSTRAINT "EventType_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
Loading…
Reference in New Issue
Block a user