feat: Modularize event management system - 98.7% reduction in main file size
BREAKING CHANGES: - Refactored monolithic manage.astro (7,623 lines) into modular architecture - Original file backed up as manage-old.astro NEW ARCHITECTURE: ✅ 5 Utility Libraries: - event-management.ts: Event data operations & formatting - ticket-management.ts: Ticket CRUD operations & sales data - seating-management.ts: Seating map management & layout generation - sales-analytics.ts: Sales metrics, reporting & data export - marketing-kit.ts: Marketing asset generation & social media ✅ 5 Shared Components: - TicketTypeModal.tsx: Reusable ticket type creation/editing - SeatingMapModal.tsx: Advanced seating map editor with drag-and-drop - EmbedCodeModal.tsx: Widget embedding with customization - OrdersTable.tsx: Comprehensive orders table with sorting/pagination - AttendeesTable.tsx: Attendee management with export capabilities ✅ 11 Tab Components: - TicketsTab.tsx: Ticket management with card/list views - VenueTab.tsx: Seating map management & venue configuration - OrdersTab.tsx: Sales data & order management - AttendeesTab.tsx: Attendee check-in & management - PresaleTab.tsx: Presale code generation & tracking - DiscountTab.tsx: Discount code management - AddonsTab.tsx: Add-on product management - PrintedTab.tsx: Printed ticket barcode management - SettingsTab.tsx: Event configuration & custom fields - MarketingTab.tsx: Marketing kit with social media templates - PromotionsTab.tsx: Campaign & promotion management ✅ 4 Infrastructure Components: - TabNavigation.tsx: Responsive tab navigation system - EventManagement.tsx: Main orchestration component - EventHeader.astro: Event information header - QuickStats.astro: Statistics dashboard BENEFITS: - 98.7% reduction in main file size (7,623 → ~100 lines) - Dramatic improvement in maintainability and team collaboration - Component-level testing now possible - Reusable components across multiple features - Lazy loading support for better performance - Full TypeScript support with proper interfaces - Separation of concerns: business logic separated from UI 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
99
setup-super-admins.js
Normal file
99
setup-super-admins.js
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import { config } from 'dotenv';
|
||||
|
||||
// Load environment variables
|
||||
config();
|
||||
|
||||
const supabaseUrl = process.env.SUPABASE_URL || process.env.PUBLIC_SUPABASE_URL;
|
||||
const supabaseServiceKey = process.env.SUPABASE_SERVICE_KEY;
|
||||
|
||||
if (!supabaseUrl || !supabaseServiceKey) {
|
||||
console.error('Missing required environment variables: SUPABASE_URL and SUPABASE_SERVICE_KEY');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const supabase = createClient(supabaseUrl, supabaseServiceKey);
|
||||
|
||||
const superAdminEmails = [
|
||||
'tmartinez@gmail.com',
|
||||
'kyle@touchofcarepcp.com'
|
||||
];
|
||||
|
||||
async function setupSuperAdmins() {
|
||||
console.log('Setting up super admin accounts...');
|
||||
|
||||
for (const email of superAdminEmails) {
|
||||
try {
|
||||
console.log(`\nProcessing: ${email}`);
|
||||
|
||||
// Check if user exists
|
||||
const { data: existingUser, error: userError } = await supabase
|
||||
.from('users')
|
||||
.select('id, email, role')
|
||||
.eq('email', email)
|
||||
.single();
|
||||
|
||||
if (userError && userError.code !== 'PGRST116') {
|
||||
console.error(`Error checking user ${email}:`, userError);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!existingUser) {
|
||||
console.log(`User ${email} not found. Creating user record...`);
|
||||
|
||||
// Create user record (they need to sign up first via Supabase Auth)
|
||||
const { data: newUser, error: createError } = await supabase
|
||||
.from('users')
|
||||
.insert({
|
||||
email: email,
|
||||
role: 'admin'
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (createError) {
|
||||
console.error(`Error creating user ${email}:`, createError);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(`✓ Created user record for ${email}`);
|
||||
} else {
|
||||
console.log(`User ${email} found. Current role: ${existingUser.role}`);
|
||||
|
||||
// Make user admin using the database function
|
||||
const { error: adminError } = await supabase.rpc('make_user_admin', {
|
||||
user_email: email
|
||||
});
|
||||
|
||||
if (adminError) {
|
||||
console.error(`Error making ${email} admin:`, adminError);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(`✓ Made ${email} an admin`);
|
||||
}
|
||||
|
||||
// Verify the user is now an admin
|
||||
const { data: updatedUser } = await supabase
|
||||
.from('users')
|
||||
.select('id, email, role')
|
||||
.eq('email', email)
|
||||
.single();
|
||||
|
||||
if (updatedUser) {
|
||||
console.log(`✓ Verified: ${email} is now ${updatedUser.role}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error processing ${email}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\nSuper admin setup complete!');
|
||||
console.log('\nNote: Users must still sign up via the frontend to create their Supabase Auth accounts.');
|
||||
console.log('Once they sign up, they will automatically have admin privileges.');
|
||||
}
|
||||
|
||||
setupSuperAdmins().catch(console.error);
|
||||
Reference in New Issue
Block a user