mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:11:13 -05:00
Implement plan to remove public toggle
This commit is contained in:
@@ -41,7 +41,7 @@ import { Input } from '@/components/ui/input';
|
|||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { DatePicker } from '@/components/ui/date-picker';
|
import { DatePicker } from '@/components/ui/date-picker';
|
||||||
import { Switch } from '@/components/ui/switch';
|
|
||||||
import { Loader2, Trash } from 'lucide-react';
|
import { Loader2, Trash } from 'lucide-react';
|
||||||
import { useAuth } from '@/hooks/useAuth';
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
@@ -129,14 +129,12 @@ export function TimelineEventEditorDialog({
|
|||||||
to_entity_id: existingEvent.to_entity_id || '',
|
to_entity_id: existingEvent.to_entity_id || '',
|
||||||
from_location_id: existingEvent.from_location_id || '',
|
from_location_id: existingEvent.from_location_id || '',
|
||||||
to_location_id: existingEvent.to_location_id || '',
|
to_location_id: existingEvent.to_location_id || '',
|
||||||
is_public: existingEvent.is_public,
|
|
||||||
} : {
|
} : {
|
||||||
event_type: 'milestone',
|
event_type: 'milestone',
|
||||||
event_date: new Date(),
|
event_date: new Date(),
|
||||||
event_date_precision: 'day',
|
event_date_precision: 'day',
|
||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
is_public: true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -386,27 +384,6 @@ export function TimelineEventEditorDialog({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="is_public"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel className="text-base">Public Event</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Make this event visible to all users
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<DialogFooter className="gap-3 sm:gap-0">
|
<DialogFooter className="gap-3 sm:gap-0">
|
||||||
{isEditing && existingEvent?.approved_by === null && (
|
{isEditing && existingEvent?.approved_by === null && (
|
||||||
<AlertDialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
|
<AlertDialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
|
||||||
|
|||||||
@@ -968,7 +968,7 @@ export async function submitTimelineEvent(
|
|||||||
to_entity_id: data.to_entity_id,
|
to_entity_id: data.to_entity_id,
|
||||||
from_location_id: data.from_location_id,
|
from_location_id: data.from_location_id,
|
||||||
to_location_id: data.to_location_id,
|
to_location_id: data.to_location_id,
|
||||||
is_public: data.is_public ?? true,
|
is_public: true, // All timeline events are public
|
||||||
};
|
};
|
||||||
|
|
||||||
const { error: itemError } = await supabase
|
const { error: itemError } = await supabase
|
||||||
@@ -1057,7 +1057,7 @@ export async function submitTimelineEventUpdate(
|
|||||||
to_entity_id: data.to_entity_id,
|
to_entity_id: data.to_entity_id,
|
||||||
from_location_id: data.from_location_id,
|
from_location_id: data.from_location_id,
|
||||||
to_location_id: data.to_location_id,
|
to_location_id: data.to_location_id,
|
||||||
is_public: data.is_public ?? true,
|
is_public: true, // All timeline events are public
|
||||||
};
|
};
|
||||||
|
|
||||||
const { error: itemError } = await supabase
|
const { error: itemError } = await supabase
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export interface TimelineEvent {
|
|||||||
to_location_id?: string;
|
to_location_id?: string;
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
is_public: boolean;
|
|
||||||
display_order: number;
|
display_order: number;
|
||||||
created_by?: string;
|
created_by?: string;
|
||||||
approved_by?: string;
|
approved_by?: string;
|
||||||
@@ -73,8 +72,6 @@ export interface TimelineEventFormData {
|
|||||||
to_entity_id?: string;
|
to_entity_id?: string;
|
||||||
from_location_id?: string;
|
from_location_id?: string;
|
||||||
to_location_id?: string;
|
to_location_id?: string;
|
||||||
|
|
||||||
is_public?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -899,7 +899,7 @@ async function createTimelineEvent(
|
|||||||
to_entity_id: data.to_entity_id,
|
to_entity_id: data.to_entity_id,
|
||||||
from_location_id: data.from_location_id,
|
from_location_id: data.from_location_id,
|
||||||
to_location_id: data.to_location_id,
|
to_location_id: data.to_location_id,
|
||||||
is_public: data.is_public ?? true,
|
is_public: true, // All timeline events are public
|
||||||
created_by: submitterId,
|
created_by: submitterId,
|
||||||
approved_by: approvingUserId,
|
approved_by: approvingUserId,
|
||||||
submission_id: submissionId,
|
submission_id: submissionId,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
-- Ensure all existing timeline events are public
|
||||||
|
UPDATE entity_timeline_events
|
||||||
|
SET is_public = true
|
||||||
|
WHERE is_public = false;
|
||||||
|
|
||||||
|
-- Add check constraint to enforce all events are public
|
||||||
|
ALTER TABLE entity_timeline_events
|
||||||
|
ADD CONSTRAINT timeline_events_must_be_public
|
||||||
|
CHECK (is_public = true);
|
||||||
|
|
||||||
|
-- Add comment to document this requirement
|
||||||
|
COMMENT ON COLUMN entity_timeline_events.is_public IS
|
||||||
|
'All timeline events are public. This column is kept for potential future use but must always be true.';
|
||||||
Reference in New Issue
Block a user