ALwrity + Wix + Wordpress + GSC integration + Production API calls fixes
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
readPrefs
|
||||
} from './utils/linkedInWriterUtils';
|
||||
import { PostHITL, ArticleHITL, CarouselHITL, VideoScriptHITL, CommentResponseHITL } from './components';
|
||||
import { apiClient } from '../../api/client';
|
||||
|
||||
const useCopilotActionTyped = useCopilotAction as any;
|
||||
|
||||
@@ -25,22 +26,14 @@ const RegisterLinkedInActions: React.FC = () => {
|
||||
],
|
||||
handler: async (args: any) => {
|
||||
try {
|
||||
const response = await fetch('/api/linkedin/generate-image-prompts', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
content_type: args.content_type,
|
||||
topic: args.topic,
|
||||
industry: args.industry,
|
||||
content: args.content
|
||||
})
|
||||
const response = await apiClient.post('/api/linkedin/generate-image-prompts', {
|
||||
content_type: args.content_type,
|
||||
topic: args.topic,
|
||||
industry: args.industry,
|
||||
content: args.content
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to generate image prompts: ${response.status}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
const result = response.data;
|
||||
return {
|
||||
success: true,
|
||||
prompts: result,
|
||||
@@ -66,21 +59,13 @@ const RegisterLinkedInActions: React.FC = () => {
|
||||
],
|
||||
handler: async (args: any) => {
|
||||
try {
|
||||
const response = await fetch('/api/linkedin/generate-image', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
prompt: args.prompt,
|
||||
content_context: args.content_context,
|
||||
aspect_ratio: args.aspect_ratio || '1:1'
|
||||
})
|
||||
const response = await apiClient.post('/api/linkedin/generate-image', {
|
||||
prompt: args.prompt,
|
||||
content_context: args.content_context,
|
||||
aspect_ratio: args.aspect_ratio || '1:1'
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to generate image: ${response.status}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
const result = response.data;
|
||||
if (result.success) {
|
||||
return {
|
||||
success: true,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import { usePlatformPersonaContext } from '../../shared/PersonaContext/PlatformPersonaProvider';
|
||||
import { apiClient } from '../../../api/client';
|
||||
|
||||
// Define the cache data type
|
||||
interface BrainstormCacheData {
|
||||
@@ -201,33 +202,22 @@ const BrainstormFlow: React.FC<BrainstormFlowProps> = ({
|
||||
// First: run grounded search for the seed prompt
|
||||
let results: any[] = [];
|
||||
try {
|
||||
const sr = await fetch('/api/brainstorm/search', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ prompt: finalSeed })
|
||||
});
|
||||
if (sr.ok) {
|
||||
const data = await sr.json();
|
||||
results = data?.results || [];
|
||||
}
|
||||
const sr = await apiClient.post('/api/brainstorm/search', { prompt: finalSeed });
|
||||
results = sr.data?.results || [];
|
||||
} catch {}
|
||||
setSearchResults(results);
|
||||
|
||||
// Then: request persona-aware brainstorm ideas using the search results
|
||||
try {
|
||||
const ir = await fetch('/api/brainstorm/ideas', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
seed: finalSeed,
|
||||
persona: corePersona || null,
|
||||
platformPersona: platformPersona || null,
|
||||
results,
|
||||
count: 5
|
||||
})
|
||||
const ir = await apiClient.post('/api/brainstorm/ideas', {
|
||||
seed: finalSeed,
|
||||
persona: corePersona || null,
|
||||
platformPersona: platformPersona || null,
|
||||
results,
|
||||
count: 5
|
||||
});
|
||||
if (ir.ok) {
|
||||
const data = await ir.json();
|
||||
if (ir.data) {
|
||||
const data = ir.data;
|
||||
const list = Array.isArray(data?.ideas) ? data.ideas : [];
|
||||
setIdeas(list);
|
||||
setAiSearchPrompts(list.map((x: any) => x.prompt));
|
||||
@@ -477,19 +467,9 @@ const BrainstormFlow: React.FC<BrainstormFlowProps> = ({
|
||||
onClick={async () => {
|
||||
// Use existing Google grounding flow via backend LinkedInService
|
||||
try {
|
||||
const resp = await fetch('/api/brainstorm/search', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ prompt: selectedPrompt })
|
||||
});
|
||||
if (resp.ok) {
|
||||
const data = await resp.json();
|
||||
setSearchResults(data?.results || []);
|
||||
setBrainstormStage('results');
|
||||
} else {
|
||||
setSearchResults([]);
|
||||
setBrainstormStage('results');
|
||||
}
|
||||
const resp = await apiClient.post('/api/brainstorm/search', { prompt: selectedPrompt });
|
||||
setSearchResults(resp.data?.results || []);
|
||||
setBrainstormStage('results');
|
||||
} catch {
|
||||
setSearchResults([]);
|
||||
setBrainstormStage('results');
|
||||
|
||||
Reference in New Issue
Block a user