mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 17:31:14 -05:00
Refactor: Unify moderation queue for all entities
This commit is contained in:
@@ -250,58 +250,24 @@ export default function Parks() {
|
||||
}
|
||||
|
||||
try {
|
||||
if (isModerator()) {
|
||||
// Moderators can create parks directly
|
||||
const { error } = await supabase
|
||||
.from('parks')
|
||||
.insert({
|
||||
name: parkData.name,
|
||||
slug: parkData.slug,
|
||||
description: parkData.description || null,
|
||||
park_type: parkData.park_type,
|
||||
status: parkData.status,
|
||||
opening_date: parkData.opening_date || null,
|
||||
closing_date: parkData.closing_date || null,
|
||||
website_url: parkData.website_url || null,
|
||||
phone: parkData.phone || null,
|
||||
email: parkData.email || null,
|
||||
banner_image_url: parkData.banner_image_url || null,
|
||||
banner_image_id: parkData.banner_image_id || null,
|
||||
card_image_url: parkData.card_image_url || null,
|
||||
card_image_id: parkData.card_image_id || null,
|
||||
operator_id: parkData.operator_id || null,
|
||||
property_owner_id: parkData.property_owner_id || null
|
||||
});
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
toast({
|
||||
title: "Park Created",
|
||||
description: "The park has been created successfully.",
|
||||
// All users submit for moderation
|
||||
const { error } = await supabase
|
||||
.from('content_submissions')
|
||||
.insert({
|
||||
user_id: user.id,
|
||||
submission_type: 'park',
|
||||
status: 'pending',
|
||||
content: parkData
|
||||
});
|
||||
|
||||
setIsAddParkModalOpen(false);
|
||||
fetchParks();
|
||||
} else {
|
||||
// Regular users submit for moderation
|
||||
const { error } = await supabase
|
||||
.from('content_submissions')
|
||||
.insert({
|
||||
user_id: user.id,
|
||||
submission_type: 'park',
|
||||
status: 'pending',
|
||||
content: parkData
|
||||
});
|
||||
if (error) throw error;
|
||||
|
||||
if (error) throw error;
|
||||
toast({
|
||||
title: "Park Submitted",
|
||||
description: "Your park submission has been sent for moderation review.",
|
||||
});
|
||||
|
||||
toast({
|
||||
title: "Submission Sent",
|
||||
description: "Your park submission has been sent for moderation review.",
|
||||
});
|
||||
|
||||
setIsAddParkModalOpen(false);
|
||||
}
|
||||
setIsAddParkModalOpen(false);
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: "Submission Failed",
|
||||
@@ -477,7 +443,7 @@ export default function Parks() {
|
||||
<DialogHeader>
|
||||
<DialogTitle>Add New Park</DialogTitle>
|
||||
<DialogDescription>
|
||||
Add a new park to the database. {isModerator() ? 'The park will be added immediately.' : 'Your submission will be reviewed before being published.'}
|
||||
Add a new park to the database. Your submission will be reviewed before being published.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<ParkForm
|
||||
|
||||
Reference in New Issue
Block a user