Add organizerClerkId to events for proper organizer permission checks
This commit is contained in:
@@ -61,6 +61,7 @@ export const eventService = {
|
|||||||
organizer: {
|
organizer: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
clerkId: true,
|
||||||
username: true,
|
username: true,
|
||||||
firstName: true,
|
firstName: true,
|
||||||
lastName: true,
|
lastName: true,
|
||||||
@@ -79,6 +80,7 @@ export const eventService = {
|
|||||||
return events.map((event) => ({
|
return events.map((event) => ({
|
||||||
id: event.id,
|
id: event.id,
|
||||||
organizerId: event.organizerId,
|
organizerId: event.organizerId,
|
||||||
|
organizerClerkId: event.organizer.clerkId,
|
||||||
title: event.title,
|
title: event.title,
|
||||||
description: event.description,
|
description: event.description,
|
||||||
latitude: parseFloat(event.latitude.toString()),
|
latitude: parseFloat(event.latitude.toString()),
|
||||||
@@ -102,6 +104,7 @@ export const eventService = {
|
|||||||
organizer: {
|
organizer: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
clerkId: true,
|
||||||
username: true,
|
username: true,
|
||||||
firstName: true,
|
firstName: true,
|
||||||
lastName: true,
|
lastName: true,
|
||||||
@@ -121,6 +124,7 @@ export const eventService = {
|
|||||||
return {
|
return {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
organizerId: event.organizerId,
|
organizerId: event.organizerId,
|
||||||
|
organizerClerkId: event.organizer.clerkId,
|
||||||
title: event.title,
|
title: event.title,
|
||||||
description: event.description,
|
description: event.description,
|
||||||
latitude: parseFloat(event.latitude.toString()),
|
latitude: parseFloat(event.latitude.toString()),
|
||||||
|
|||||||
@@ -34,11 +34,8 @@ export function EventsPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedEvent && isSignedIn) {
|
if (selectedEvent && isSignedIn) {
|
||||||
checkRegistrationStatus(selectedEvent.id);
|
checkRegistrationStatus(selectedEvent.id);
|
||||||
// Check if current user is the organizer
|
// Check if current user is the organizer by comparing Clerk IDs
|
||||||
// Note: We're comparing Clerk user ID with organizerId
|
setIsOrganizer(user?.id === selectedEvent.organizerClerkId);
|
||||||
// In a real implementation, we'd need to fetch the organizer's Clerk ID
|
|
||||||
// For now, we'll use a simple check
|
|
||||||
setIsOrganizer(user?.id === selectedEvent.organizerId);
|
|
||||||
} else {
|
} else {
|
||||||
setIsOrganizer(false);
|
setIsOrganizer(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export interface Report {
|
|||||||
export interface CleanupEvent {
|
export interface CleanupEvent {
|
||||||
id: string;
|
id: string;
|
||||||
organizerId: string;
|
organizerId: string;
|
||||||
|
organizerClerkId?: string; // Clerk ID of the organizer for permission checks
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
latitude: number;
|
latitude: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user