fix(brand): sincronizacion bidireccional de linkedin_strategy_url y precarga automatica de campos b2b
This commit is contained in:
@@ -113,6 +113,7 @@ export async function GET(req: NextRequest) {
|
|||||||
const proObj = cs.prohibitions || {};
|
const proObj = cs.prohibitions || {};
|
||||||
const voiObj = cs.voice || {};
|
const voiObj = cs.voice || {};
|
||||||
const visObj = cs.visual || {};
|
const visObj = cs.visual || {};
|
||||||
|
const liObj = cs.linkedin || {};
|
||||||
|
|
||||||
current = {
|
current = {
|
||||||
...current,
|
...current,
|
||||||
@@ -142,6 +143,14 @@ export async function GET(req: NextRequest) {
|
|||||||
emoji_policy: current.emoji_policy || proObj.emoji_policy || '',
|
emoji_policy: current.emoji_policy || proObj.emoji_policy || '',
|
||||||
testimonials_policy: current.testimonials_policy || proObj.testimonials_policy || '',
|
testimonials_policy: current.testimonials_policy || proObj.testimonials_policy || '',
|
||||||
competitors_never_mention: current.competitors_never_mention?.length ? current.competitors_never_mention : (proObj.competitors_never_mention || []),
|
competitors_never_mention: current.competitors_never_mention?.length ? current.competitors_never_mention : (proObj.competitors_never_mention || []),
|
||||||
|
linkedin_themes: current.linkedin_themes?.length ? current.linkedin_themes : (liObj.linkedin_themes || []),
|
||||||
|
linkedin_formats: current.linkedin_formats?.length ? current.linkedin_formats : (liObj.linkedin_formats || []),
|
||||||
|
thought_leadership: current.thought_leadership?.length ? current.thought_leadership : (liObj.thought_leadership || []),
|
||||||
|
buyer_roles: current.buyer_roles?.length ? current.buyer_roles : (liObj.buyer_roles || []),
|
||||||
|
case_study_angles: current.case_study_angles?.length ? current.case_study_angles : (liObj.case_study_angles || []),
|
||||||
|
linkedin_cta: current.linkedin_cta?.length ? current.linkedin_cta : (liObj.linkedin_cta || []),
|
||||||
|
abm_notes: current.abm_notes || liObj.abm_notes || '',
|
||||||
|
linkedin_strategy_url: current.linkedin_strategy_url || liObj.strategy_url || '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,6 +332,17 @@ export async function PUT(req: NextRequest) {
|
|||||||
testimonials_policy: book.testimonials_policy || existingStyle.prohibitions?.testimonials_policy || '',
|
testimonials_policy: book.testimonials_policy || existingStyle.prohibitions?.testimonials_policy || '',
|
||||||
competitors_never_mention: book.competitors_never_mention?.length ? book.competitors_never_mention : existingStyle.prohibitions?.competitors_never_mention || [],
|
competitors_never_mention: book.competitors_never_mention?.length ? book.competitors_never_mention : existingStyle.prohibitions?.competitors_never_mention || [],
|
||||||
},
|
},
|
||||||
|
linkedin: {
|
||||||
|
...(existingStyle.linkedin || {}),
|
||||||
|
linkedin_themes: book.linkedin_themes?.length ? book.linkedin_themes : existingStyle.linkedin?.linkedin_themes || [],
|
||||||
|
linkedin_formats: book.linkedin_formats?.length ? book.linkedin_formats : existingStyle.linkedin?.linkedin_formats || [],
|
||||||
|
thought_leadership: book.thought_leadership?.length ? book.thought_leadership : existingStyle.linkedin?.thought_leadership || [],
|
||||||
|
buyer_roles: book.buyer_roles?.length ? book.buyer_roles : existingStyle.linkedin?.buyer_roles || [],
|
||||||
|
case_study_angles: book.case_study_angles?.length ? book.case_study_angles : existingStyle.linkedin?.case_study_angles || [],
|
||||||
|
linkedin_cta: book.linkedin_cta?.length ? book.linkedin_cta : existingStyle.linkedin?.linkedin_cta || [],
|
||||||
|
abm_notes: book.abm_notes || existingStyle.linkedin?.abm_notes || '',
|
||||||
|
strategy_url: book.linkedin_strategy_url || existingStyle.linkedin?.strategy_url || '',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
await admin
|
await admin
|
||||||
|
|||||||
@@ -246,11 +246,17 @@ export default function BrandZone({
|
|||||||
const r = await fetch(`/api/brandbook${query}`);
|
const r = await fetch(`/api/brandbook${query}`);
|
||||||
const j = await r.json();
|
const j = await r.json();
|
||||||
if (!r.ok) throw new Error(j.error || 'No se pudo cargar');
|
if (!r.ok) throw new Error(j.error || 'No se pudo cargar');
|
||||||
setBook(j.brandbook || emptyBrandbook(tenantLabel));
|
const currentBook = j.brandbook || emptyBrandbook(tenantLabel);
|
||||||
|
setBook(currentBook);
|
||||||
setSlug(j.slug || tenantSlug || '');
|
setSlug(j.slug || tenantSlug || '');
|
||||||
setScore(j.completeness?.score ?? 0);
|
setScore(j.completeness?.score ?? 0);
|
||||||
setMissing(j.completeness?.missing || []);
|
setMissing(j.completeness?.missing || []);
|
||||||
setExists(!!j.exists);
|
setExists(!!j.exists);
|
||||||
|
if (currentBook.linkedin_strategy_url) {
|
||||||
|
setB2bStrategyUrl(currentBook.linkedin_strategy_url);
|
||||||
|
} else if (j.slug === 'bps' || (tenantLabel && tenantLabel.toLowerCase().includes('parrot'))) {
|
||||||
|
setB2bStrategyUrl('https://4ventures.es/bps/estrategia-linkedin-bps.html');
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setErr(e instanceof Error ? e.message : 'Error');
|
setErr(e instanceof Error ? e.message : 'Error');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -418,6 +424,7 @@ export default function BrandZone({
|
|||||||
case_study_angles: b2bAnalysisResult.case_study_angles,
|
case_study_angles: b2bAnalysisResult.case_study_angles,
|
||||||
linkedin_cta: b2bAnalysisResult.linkedin_cta,
|
linkedin_cta: b2bAnalysisResult.linkedin_cta,
|
||||||
abm_notes: b2bAnalysisResult.abm_notes || book.abm_notes,
|
abm_notes: b2bAnalysisResult.abm_notes || book.abm_notes,
|
||||||
|
linkedin_strategy_url: b2bStrategyUrl.trim() || book.linkedin_strategy_url,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
patch({
|
patch({
|
||||||
@@ -428,6 +435,7 @@ export default function BrandZone({
|
|||||||
case_study_angles: mergeUnique(book.case_study_angles, b2bAnalysisResult.case_study_angles),
|
case_study_angles: mergeUnique(book.case_study_angles, b2bAnalysisResult.case_study_angles),
|
||||||
linkedin_cta: mergeUnique(book.linkedin_cta, b2bAnalysisResult.linkedin_cta),
|
linkedin_cta: mergeUnique(book.linkedin_cta, b2bAnalysisResult.linkedin_cta),
|
||||||
abm_notes: (book.abm_notes ? book.abm_notes + '\n\n' : '') + b2bAnalysisResult.abm_notes,
|
abm_notes: (book.abm_notes ? book.abm_notes + '\n\n' : '') + b2bAnalysisResult.abm_notes,
|
||||||
|
linkedin_strategy_url: b2bStrategyUrl.trim() || book.linkedin_strategy_url,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2577,7 +2585,10 @@ export default function BrandZone({
|
|||||||
placeholder="https://4ventures.es/halal/estrategia-linkedin-halal.html"
|
placeholder="https://4ventures.es/halal/estrategia-linkedin-halal.html"
|
||||||
className="flex-1 rounded-lg border border-gray-300 bg-white px-3 py-2 text-xs text-gray-900 shadow-xs focus:border-brand-500 focus:outline-hidden focus:ring-1 focus:ring-brand-500"
|
className="flex-1 rounded-lg border border-gray-300 bg-white px-3 py-2 text-xs text-gray-900 shadow-xs focus:border-brand-500 focus:outline-hidden focus:ring-1 focus:ring-brand-500"
|
||||||
value={b2bStrategyUrl}
|
value={b2bStrategyUrl}
|
||||||
onChange={(e) => setB2bStrategyUrl(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setB2bStrategyUrl(e.target.value);
|
||||||
|
patch({ linkedin_strategy_url: e.target.value });
|
||||||
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ export type Brandbook = {
|
|||||||
abm_notes: string;
|
abm_notes: string;
|
||||||
case_study_angles: string[];
|
case_study_angles: string[];
|
||||||
linkedin_cta: string[];
|
linkedin_cta: string[];
|
||||||
|
linkedin_strategy_url?: string;
|
||||||
/** Blog */
|
/** Blog */
|
||||||
blog_themes: string[];
|
blog_themes: string[];
|
||||||
blog_seo_keywords: string[];
|
blog_seo_keywords: string[];
|
||||||
@@ -442,6 +443,7 @@ export function emptyBrandbook(label = ''): Brandbook {
|
|||||||
abm_notes: '',
|
abm_notes: '',
|
||||||
case_study_angles: [],
|
case_study_angles: [],
|
||||||
linkedin_cta: [],
|
linkedin_cta: [],
|
||||||
|
linkedin_strategy_url: '',
|
||||||
blog_themes: [],
|
blog_themes: [],
|
||||||
blog_seo_keywords: [],
|
blog_seo_keywords: [],
|
||||||
blog_cadence: '',
|
blog_cadence: '',
|
||||||
@@ -1833,6 +1835,7 @@ export function parseBrandbook(raw: unknown): Brandbook | null {
|
|||||||
buyer_roles: arr(partial.buyer_roles),
|
buyer_roles: arr(partial.buyer_roles),
|
||||||
case_study_angles: arr(partial.case_study_angles),
|
case_study_angles: arr(partial.case_study_angles),
|
||||||
linkedin_cta: arr(partial.linkedin_cta),
|
linkedin_cta: arr(partial.linkedin_cta),
|
||||||
|
linkedin_strategy_url: str(partial.linkedin_strategy_url),
|
||||||
blog_themes: arr(partial.blog_themes),
|
blog_themes: arr(partial.blog_themes),
|
||||||
blog_seo_keywords: arr(partial.blog_seo_keywords),
|
blog_seo_keywords: arr(partial.blog_seo_keywords),
|
||||||
content_clusters: arr(partial.content_clusters),
|
content_clusters: arr(partial.content_clusters),
|
||||||
|
|||||||
Reference in New Issue
Block a user