fix: add CoreProvider to AdminLayout to fix QueryClient error on all admin pages
This commit is contained in:
46
fix_all_pages.sh
Normal file
46
fix_all_pages.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Fix all admin pages by adding CoreProvider wrapper
|
||||
|
||||
cd /Users/christopheramaya/Downloads/spark/frontend/src/pages/admin
|
||||
|
||||
# List of files to fix (from user's list)
|
||||
files=(
|
||||
"collections/avatar-variants.astro"
|
||||
"collections/spintax-dictionaries.astro"
|
||||
"collections/cartesian-patterns.astro"
|
||||
"collections/campaign-masters.astro"
|
||||
"collections/content-fragments.astro"
|
||||
"collections/headline-inventory.astro"
|
||||
"collections/offer-blocks.astro"
|
||||
"collections/generation-jobs.astro"
|
||||
"seo/articles/index.astro"
|
||||
"leads/index.astro"
|
||||
"settings.astro"
|
||||
"content/work_log.astro"
|
||||
"media/templates.astro"
|
||||
"content-factory.astro"
|
||||
"index.astro"
|
||||
"sites/jumpstart.astro"
|
||||
)
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
echo "Fixing $file..."
|
||||
|
||||
# Add import if not present
|
||||
if ! grep -q "CoreProvider" "$file"; then
|
||||
# Add import after the last import line
|
||||
sed -i '' '/^import.*from/a\
|
||||
import { CoreProvider } from '\''@/components/providers/CoreProviders'\'';
|
||||
' "$file"
|
||||
|
||||
echo " ✅ Added CoreProvider import"
|
||||
fi
|
||||
else
|
||||
echo " ⚠️ File not found: $file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "✅ All files processed!"
|
||||
echo "⚠️ Note: Component wrapping must be done manually for each file"
|
||||
84
fix_query_provider.py
Normal file
84
fix_query_provider.py
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Add CoreProvider wrapper to all Astro admin pages that use React components
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
# Pages to fix
|
||||
pages_dir = Path("/Users/christopheramaya/Downloads/spark/frontend/src/pages/admin")
|
||||
|
||||
def fix_astro_page(file_path):
|
||||
"""Add CoreProvider wrapper to an Astro page"""
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Skip if already has CoreProvider
|
||||
if 'CoreProvider' in content:
|
||||
print(f" ⏭️ {file_path.name} (already has CoreProvider)")
|
||||
return False
|
||||
|
||||
# Skip if no client:load or client:only
|
||||
if 'client:load' not in content and 'client:only' not in content:
|
||||
print(f" ⏭️ {file_path.name} (no React components)")
|
||||
return False
|
||||
|
||||
# Add import
|
||||
import_pattern = r'(---\n)(import.*?from.*?;\n)'
|
||||
if re.search(import_pattern, content):
|
||||
# Add after existing imports
|
||||
content = re.sub(
|
||||
r'(import.*?from.*?;\n)(\n---)',
|
||||
r'\1import { CoreProvider } from \'@/components/providers/CoreProviders\';\n\2',
|
||||
content,
|
||||
count=1
|
||||
)
|
||||
|
||||
# Find all React components with client directives
|
||||
# Pattern: <ComponentName client:load /> or client:only="react"
|
||||
component_pattern = r'<(\w+)\s+(client:(?:load|only(?:="react")?)\s*/?>)'
|
||||
|
||||
matches = list(re.finditer(component_pattern, content))
|
||||
|
||||
if not matches:
|
||||
print(f" ⏭️ {file_path.name} (no matching components)")
|
||||
return False
|
||||
|
||||
# Wrap all components in CoreProvider
|
||||
# Find the first component
|
||||
first_match = matches[0]
|
||||
first_component_start = first_match.start()
|
||||
|
||||
# Find the last component
|
||||
last_match = matches[-1]
|
||||
last_component_end = last_match.end()
|
||||
|
||||
# Insert CoreProvider before first component
|
||||
before = content[:first_component_start]
|
||||
components = content[first_component_start:last_component_end]
|
||||
after = content[last_component_end:]
|
||||
|
||||
# Add proper indentation
|
||||
indent = ' ' # Assuming 4-space indent
|
||||
|
||||
# Wrap components
|
||||
wrapped = f'{indent}<CoreProvider client:load>\n{indent} {components}\n{indent}</CoreProvider>'
|
||||
|
||||
new_content = before + wrapped + after
|
||||
|
||||
# Write back
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(new_content)
|
||||
|
||||
print(f" ✅ {file_path.name}")
|
||||
return True
|
||||
|
||||
# Process all .astro files
|
||||
fixed_count = 0
|
||||
for astro_file in pages_dir.rglob('*.astro'):
|
||||
if astro_file.is_file():
|
||||
if fix_astro_page(astro_file):
|
||||
fixed_count += 1
|
||||
|
||||
print(f"\n✅ Fixed {fixed_count} pages")
|
||||
@@ -8,7 +8,7 @@ const currentPath = Astro.url.pathname;
|
||||
|
||||
import SystemStatus from '@/components/admin/SystemStatus';
|
||||
import SystemStatusBar from '@/components/admin/SystemStatusBar';
|
||||
import { GlobalToaster } from '@/components/providers/CoreProviders';
|
||||
import { GlobalToaster, CoreProvider } from '@/components/providers/CoreProviders';
|
||||
|
||||
|
||||
const navGroups = [
|
||||
@@ -225,7 +225,9 @@ function isActive(href: string) {
|
||||
</header>
|
||||
|
||||
<main class="p-8 pb-24">
|
||||
<slot />
|
||||
<CoreProvider client:load>
|
||||
<slot />
|
||||
</CoreProvider>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import Layout from '@/layouts/AdminLayout.astro';
|
||||
import GeoIntelligenceManager from '@/components/admin/intelligence/GeoIntelligenceManager';
|
||||
import { CoreProvider } from '@/components/providers/CoreProviders';
|
||||
---
|
||||
<Layout title="Geo Intelligence | Spark Platform">
|
||||
<div class="p-8 space-y-6">
|
||||
@@ -13,6 +14,8 @@ import GeoIntelligenceManager from '@/components/admin/intelligence/GeoIntellige
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<GeoIntelligenceManager client:only="react" />
|
||||
<CoreProvider client:load>
|
||||
<GeoIntelligenceManager client:only="react" />
|
||||
</CoreProvider>
|
||||
</div>
|
||||
</Layout>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
---
|
||||
import Layout from '@/layouts/AdminLayout.astro';
|
||||
import AvatarIntelligenceManager from '@/components/admin/intelligence/AvatarIntelligenceManager';
|
||||
import { CoreProvider } from '@/components/providers/CoreProviders';
|
||||
---
|
||||
<Layout title="Avatar Intelligence">
|
||||
<div class="p-8">
|
||||
@@ -9,6 +10,8 @@ import AvatarIntelligenceManager from '@/components/admin/intelligence/AvatarInt
|
||||
<h1 class="text-3xl font-bold text-white mb-2">🎭 Avatar Intelligence</h1>
|
||||
<p class="text-gray-400">Manage your base avatars, variants, and target personas. Each avatar represents a unique customer profile.</p>
|
||||
</div>
|
||||
<AvatarIntelligenceManager client:load />
|
||||
<CoreProvider client:load>
|
||||
<AvatarIntelligenceManager client:load />
|
||||
</CoreProvider>
|
||||
</div>
|
||||
</Layout>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import Layout from '@/layouts/AdminLayout.astro';
|
||||
import SitesManager from '@/components/admin/sites/SitesManager';
|
||||
import { CoreProvider } from '@/components/providers/CoreProviders';
|
||||
---
|
||||
|
||||
<Layout title="Sites | Spark Launchpad">
|
||||
@@ -14,6 +15,8 @@ import SitesManager from '@/components/admin/sites/SitesManager';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SitesManager client:only="react" />
|
||||
<CoreProvider client:load>
|
||||
<SitesManager client:only="react" />
|
||||
</CoreProvider>
|
||||
</div>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user