Initial commit: CMS completo com gerenciamento de leads e personalização de tema

This commit is contained in:
Erik
2025-11-26 14:09:21 -03:00
commit aaa1709e41
106 changed files with 26268 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import { useState, useEffect } from 'react';
interface PageContentData {
id: string;
slug: string;
content: any;
updatedAt: string;
}
export function usePageContent(slug: string) {
const [content, setContent] = useState<any>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const fetchContent = async () => {
try {
const response = await fetch(`/api/pages/${slug}`);
if (response.ok) {
const data: PageContentData = await response.json();
setContent(data.content);
} else if (response.status === 404) {
// Página ainda não foi configurada no admin
setContent(null);
} else {
throw new Error('Erro ao carregar conteúdo');
}
} catch (err) {
setError(err instanceof Error ? err.message : 'Erro desconhecido');
} finally {
setLoading(false);
}
};
fetchContent();
}, [slug]);
return { content, loading, error };
}

View File

@@ -0,0 +1,36 @@
"use client";
import { useState, useCallback } from 'react';
interface Toast {
id: number;
message: string;
type: 'success' | 'error' | 'warning' | 'info';
}
export function useToast() {
const [toasts, setToasts] = useState<Toast[]>([]);
const showToast = useCallback((message: string, type: Toast['type'] = 'info') => {
const id = Date.now();
setToasts((prev) => [...prev, { id, message, type }]);
}, []);
const removeToast = useCallback((id: number) => {
setToasts((prev) => prev.filter((toast) => toast.id !== id));
}, []);
const success = useCallback((message: string) => showToast(message, 'success'), [showToast]);
const error = useCallback((message: string) => showToast(message, 'error'), [showToast]);
const warning = useCallback((message: string) => showToast(message, 'warning'), [showToast]);
const info = useCallback((message: string) => showToast(message, 'info'), [showToast]);
return {
toasts,
removeToast,
success,
error,
warning,
info,
};
}