import { createAsyncThunk } from '@reduxjs/toolkit';

/**
 * Fetch Sage Builder Dashboard HTML
 */
export const getSageBuilderDashboard = createAsyncThunk(
  'sageBuilder/getDashboard',
  async (): Promise<string> => {
    try {
      const response = await fetch(
        'https://api.sage-ai-studio.webexpr.dev/api/embed/artifact/968ba24a-47d4-4ac4-b838-f1f7a60c310d?mode=light&theme=dataven',
        {
          headers: {
            'Authorization': 'Bearer sk_live_bef70d4dd6bc671fd815d21104d5dce8'
          }
        }
      );
      
      if (!response.ok) {
        throw new Error('Erreur de chargement du dashboard');
      }
      
      return await response.text();
    } catch (err) {
      throw err;
    }
  }
);