mirror of
https://github.com/polaroi8d/cactoide.git
synced 2026-03-22 14:15:28 +00:00
feat: add public/private event types
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
|
||||
<nav class="relative z-50 backdrop-blur-md">
|
||||
<div class="container mx-auto px-4">
|
||||
<div class="flex h-16 items-center justify-between">
|
||||
<div class="mt-4 flex h-16 flex-col items-center justify-between">
|
||||
<!-- Logo/Brand -->
|
||||
<div class="flex items-center">
|
||||
<button
|
||||
@@ -34,6 +34,13 @@
|
||||
Home
|
||||
</button>
|
||||
|
||||
<button
|
||||
on:click={() => navigateTo('/discover')}
|
||||
class={isActive('/discover') ? 'text-violet-400' : 'cursor-pointer'}
|
||||
>
|
||||
Discover
|
||||
</button>
|
||||
|
||||
<button
|
||||
on:click={() => navigateTo('/create')}
|
||||
class={isActive('/create') ? 'text-violet-400' : 'cursor-pointer'}
|
||||
@@ -45,7 +52,7 @@
|
||||
on:click={() => navigateTo('/event')}
|
||||
class={isActive('/event') ? 'text-violet-400' : 'cursor-pointer'}
|
||||
>
|
||||
List
|
||||
My Events
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,6 +28,7 @@ function convertDatabaseEvent(dbEvent: DatabaseEvent): Event {
|
||||
location: dbEvent.location,
|
||||
type: dbEvent.type,
|
||||
attendee_limit: dbEvent.attendee_limit,
|
||||
visibility: dbEvent.visibility,
|
||||
user_id: dbEvent.user_id,
|
||||
created_at: dbEvent.created_at,
|
||||
updated_at: dbEvent.updated_at
|
||||
@@ -63,6 +64,7 @@ export const eventsStore = {
|
||||
location: eventData.location,
|
||||
type: eventData.type,
|
||||
attendee_limit: eventData.attendee_limit,
|
||||
visibility: eventData.visibility,
|
||||
user_id: userId,
|
||||
created_at: now,
|
||||
updated_at: now
|
||||
@@ -279,6 +281,35 @@ export const eventsStore = {
|
||||
}
|
||||
},
|
||||
|
||||
// Get public events
|
||||
getPublicEvents: async (): Promise<Event[]> => {
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('events')
|
||||
.select('*')
|
||||
.eq('visibility', 'public')
|
||||
.order('created_at', { ascending: false });
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
const publicEvents = data?.map(convertDatabaseEvent) || [];
|
||||
|
||||
// Update local store
|
||||
publicEvents.forEach((event) => {
|
||||
events.update((currentEvents) => {
|
||||
const newMap = new Map(currentEvents);
|
||||
newMap.set(event.id, event);
|
||||
return newMap;
|
||||
});
|
||||
});
|
||||
|
||||
return publicEvents;
|
||||
} catch (error) {
|
||||
console.error('Error fetching public events:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
// Delete event (only by the user who created it)
|
||||
deleteEvent: async (eventId: string, userId: string): Promise<boolean> => {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export type EventType = 'limited' | 'unlimited';
|
||||
export type EventVisibility = 'public' | 'private';
|
||||
|
||||
export interface Event {
|
||||
id: string;
|
||||
@@ -8,6 +9,7 @@ export interface Event {
|
||||
location: string;
|
||||
type: EventType;
|
||||
attendee_limit?: number;
|
||||
visibility: EventVisibility;
|
||||
user_id: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
@@ -28,6 +30,7 @@ export interface CreateEventData {
|
||||
location: string;
|
||||
type: EventType;
|
||||
attendee_limit?: number;
|
||||
visibility: EventVisibility;
|
||||
}
|
||||
|
||||
export interface DatabaseEvent {
|
||||
@@ -38,6 +41,7 @@ export interface DatabaseEvent {
|
||||
location: string;
|
||||
type: EventType;
|
||||
attendee_limit?: number;
|
||||
visibility: EventVisibility;
|
||||
user_id: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
|
||||
Reference in New Issue
Block a user