diff --git a/apps/admin/src/hooks/useAuditedSupabase.ts b/apps/admin/src/hooks/useAuditedSupabase.ts index f6d58b4..c21a571 100644 --- a/apps/admin/src/hooks/useAuditedSupabase.ts +++ b/apps/admin/src/hooks/useAuditedSupabase.ts @@ -20,6 +20,7 @@ type AuditAction = 'INSERT' | 'UPDATE' | 'DELETE'; async function logAction( tableName: string, action: AuditAction, + recordId: string | null, oldValues?: Record | null, newValues?: Record | null ): Promise { @@ -29,6 +30,7 @@ async function logAction( const { error } = await supabase.rpc('log_admin_action', { p_table_name: tableName, p_action: action, + p_record_id: recordId, p_old_values: oldValues || null, p_new_values: newValues || null, }); @@ -72,7 +74,7 @@ export const auditedSupabase = { if (!error && data) { // Log each inserted record for (const record of data as T[]) { - await logAction(table, 'INSERT', null, record as Record); + await logAction(table, 'INSERT', record.id, null, record as Record); } } @@ -106,7 +108,7 @@ export const auditedSupabase = { .single(); if (!error && data) { - await logAction(table, 'UPDATE', oldValues, data as Record); + await logAction(table, 'UPDATE', id, oldValues, data as Record); } return { data: data as T | null, error }; @@ -140,7 +142,7 @@ export const auditedSupabase = { // Log each updated record for (const record of data as T[]) { const oldRecord = oldRecords.find(r => r.id === record.id); - await logAction(table, 'UPDATE', oldRecord || null, record as Record); + await logAction(table, 'UPDATE', record.id, oldRecord || null, record as Record); } } @@ -171,7 +173,7 @@ export const auditedSupabase = { .eq('id', id); if (!error) { - await logAction(table, 'DELETE', oldValues, null); + await logAction(table, 'DELETE', id, oldValues, null); } return { error }; @@ -202,7 +204,7 @@ export const auditedSupabase = { if (!error) { // Log each deletion for (const record of oldRecords) { - await logAction(table, 'DELETE', record, null); + await logAction(table, 'DELETE', record.id as string, record, null); } } @@ -234,7 +236,7 @@ export const auditedSupabase = { .eq(field, value); if (!error && oldValues) { - await logAction(table, 'DELETE', oldValues, null); + await logAction(table, 'DELETE', (oldValues.id as string) || null, oldValues, null); } return { error }; diff --git a/apps/admin/src/lib/openai.ts b/apps/admin/src/lib/openai.ts index 7ba4edd..b163380 100644 --- a/apps/admin/src/lib/openai.ts +++ b/apps/admin/src/lib/openai.ts @@ -312,21 +312,26 @@ Mix distinct symmetric and asymmetric proposals.`; export async function generateCategory(): Promise<{ name: string; description: string; icon: string }> { const openai = getOpenAI(); - const prompt = `Generate a unique category for organizing question packs in a couples' intimacy/connection app. - - Return a JSON object with: - - name: Category name (1-3 words, e.g., "Romance", "Adventure", "Communication") - - description: Brief description of what packs in this category explore (1 sentence) - - icon: A single emoji that represents this category - - Be creative and think of categories that help couples explore different aspects of their relationship.`; + const prompt = `Generate a unique category for organizing activity packs in a couples' intimacy/connection app. + +This is an ACTIVITY-FOCUSED app where couples swipe on activity proposals. +Each partner independently swipes Like/Dislike/Maybe, and when both swipe positively they "match". +Categories organize collections of activity packs (date ideas, intimate experiences, adventures, challenges, etc.). +This is NOT a Q&A app - it's about discovering shared interests in activities. + +Return a JSON object with: +- name: Category name (1-3 words, e.g., "Romance", "Adventure", "Date Nights") +- description: Brief description of what activity packs in this category contain (1 sentence) +- icon: A single emoji that represents this category + +Be creative and think of categories that help couples explore different types of activities together.`; const response = await openai.chat.completions.create({ model: getModel('generate'), messages: [ { role: 'system', - content: 'You are a creative content organizer for a couples relationship app. Generate engaging category ideas. Always respond with valid JSON only.', + content: 'You are a creative content organizer for a couples activity/intimacy app. The app helps couples discover shared interests by swiping on activity proposals. Generate engaging category ideas for organizing activity packs. Always respond with valid JSON only.', }, { role: 'user', content: prompt }, ],