diff --git a/src/controllers/case.controller.ts b/src/controllers/case.controller.ts index 95a9900..a70df27 100644 --- a/src/controllers/case.controller.ts +++ b/src/controllers/case.controller.ts @@ -6,12 +6,16 @@ export const createCase = async (req: AuthenticatedRequest, res: Response) => { try { const userId = req.user?.id; const title = String(req.body?.title || 'Yeni Sohbet').slice(0, 200); + // kind ayrımı: 'case' = Dava Dosyaları'nda listelenen gerçek dosyalar, + // 'chat' = Sohbet ekranındaki "Yeni Sohbet" ile açılan, dosya olmayan konuşmalar. + // Dava Dosyaları listesi sadece kind='case' olanları gösteriyor. + const kind = req.body?.kind === 'chat' ? 'chat' : 'case'; // requireAuth doğrudan kullanıcının kendi id'sini set ediyor; başkasının hesabına // dosya oluşturulamaz. Yazma frontend'in anon client'ı yerine burada (service_role // ile) yapılıyor, cases için de RLS engeli yaşanmasın diye. const { data, error } = await supabase .from('cases') - .insert([{ title, user_id: userId }]) + .insert([{ title, user_id: userId, kind }]) .select('id, title') .single(); if (error) throw error;