mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
31 lines
799 B
TypeScript
31 lines
799 B
TypeScript
import { getSupabase } from './client';
|
|
import { toast } from 'react-toastify';
|
|
|
|
export async function supabaseSubmitFeedback(feedback: any) {
|
|
const supabase = getSupabase();
|
|
|
|
// Get the current user ID if available
|
|
const {
|
|
data: { user },
|
|
} = await supabase.auth.getUser();
|
|
const userId = user?.id || null;
|
|
|
|
// Insert feedback into the feedback table
|
|
const { data, error } = await supabase.from('feedback').insert({
|
|
user_id: userId,
|
|
description: feedback.description || feedback.text || JSON.stringify(feedback),
|
|
metadata: feedback,
|
|
});
|
|
|
|
if (error) {
|
|
console.error('Error submitting feedback to Supabase:', error);
|
|
toast.error('Failed to submit feedback');
|
|
|
|
return false;
|
|
}
|
|
|
|
console.log('Feedback submitted successfully:', data);
|
|
|
|
return true;
|
|
}
|