@foxpixel/react 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context/FoxPixelContext.tsx","../src/client/http.ts","../src/context/AuthContext.tsx","../src/components/ProtectedRoute.tsx","../src/components/GuestOnlyRoute.tsx","../src/components/withAuth.tsx","../src/hooks/useServices.ts","../src/hooks/useLeadCapture.ts","../src/hooks/useContactCapture.ts"],"sourcesContent":["/**\n * React Context for FoxPixel SDK\n * Provides HTTP client and configuration to all hooks\n */\n\nimport React, { createContext, useContext, useMemo, ReactNode } from 'react';\nimport { FoxPixelHttpClient } from '../client/http';\nimport { FoxPixelConfig } from '../types';\n\ninterface FoxPixelContextValue {\n client: FoxPixelHttpClient;\n config: FoxPixelConfig;\n}\n\nconst FoxPixelContext = createContext<FoxPixelContextValue | null>(null);\n\nexport interface FoxPixelProviderProps {\n children: ReactNode;\n config?: FoxPixelConfig;\n}\n\n/**\n * FoxPixelProvider - Wraps your app and provides SDK functionality\n * \n * IMPORTANT: API Key should NEVER be passed from client-side.\n * Use server-side proxy (Next.js API routes) for API Key authentication.\n * \n * @example\n * ```tsx\n * // Client-side (no API Key)\n * <FoxPixelProvider>\n * <App />\n * </FoxPixelProvider>\n * \n * // Server-side proxy (Next.js API route)\n * // pages/api/foxpixel/[...path].ts\n * export default async function handler(req, res) {\n * const apiKey = process.env.FOXPIXEL_API_KEY;\n * // Proxy request with API Key\n * }\n * ```\n */\nexport function FoxPixelProvider({ children, config = {} }: FoxPixelProviderProps) {\n const client = useMemo(() => {\n return new FoxPixelHttpClient(config);\n }, [config.apiUrl, config.apiKey, config.tenantId]);\n\n const value = useMemo(() => ({\n client,\n config,\n }), [client, config]);\n\n return (\n <FoxPixelContext.Provider value={value}>\n {children}\n </FoxPixelContext.Provider>\n );\n}\n\n/**\n * Hook to access FoxPixel context\n * @throws Error if used outside FoxPixelProvider\n */\nexport function useFoxPixelContext(): FoxPixelContextValue {\n const context = useContext(FoxPixelContext);\n \n if (!context) {\n throw new Error('useFoxPixelContext must be used within FoxPixelProvider');\n }\n \n return context;\n}\n","/**\n * HTTP client for FoxPixel API\n * Handles authentication and request/response transformation\n */\n\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosError } from 'axios';\nimport { FoxPixelConfig, ApiError } from '../types';\n\nexport class FoxPixelHttpClient {\n private client: AxiosInstance;\n private apiKey?: string;\n private tenantId?: string;\n private endUserToken?: string;\n\n constructor(config: FoxPixelConfig) {\n const apiUrl = config.apiUrl || process.env.NEXT_PUBLIC_FOXPIXEL_API_URL || 'https://api.foxpixel.com';\n \n this.client = axios.create({\n baseURL: apiUrl,\n headers: {\n 'Content-Type': 'application/json',\n },\n withCredentials: true, // Important for httpOnly cookies (End User auth)\n });\n\n this.apiKey = config.apiKey || process.env.FOXPIXEL_API_KEY;\n this.tenantId = config.tenantId;\n\n // Setup request interceptor\n this.client.interceptors.request.use(\n (config) => {\n // If end user is logged in, use their token\n // Otherwise, use API Key (server-side only)\n if (this.endUserToken) {\n // End user token is sent via httpOnly cookie automatically\n // No need to set Authorization header\n } else if (this.apiKey) {\n // API Key should only be used server-side\n // In production, this should be proxied through Next.js API routes\n config.headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n return config;\n },\n (error) => Promise.reject(error)\n );\n\n // Setup response interceptor for error handling\n this.client.interceptors.response.use(\n (response) => response,\n (error: AxiosError) => {\n const apiError: ApiError = {\n message: 'An error occurred',\n status: error.response?.status,\n };\n\n if (error.response?.data) {\n const data = error.response.data as any;\n apiError.message = data.message || data.error || apiError.message;\n apiError.code = data.code;\n }\n\n // Mark 401 on /me endpoint as \"expected\" (not an error)\n // 401 is expected when checking if user is logged in (no cookie = not logged in)\n // The hook (useAuth) will handle this gracefully by ignoring 401\n const requestUrl = error.config?.url || '';\n const isMeEndpoint = requestUrl.includes('/auth/end-user/me');\n const isUnauthorized = error.response?.status === 401;\n\n if (isMeEndpoint && isUnauthorized) {\n // Mark as expected error (hook will handle silently)\n apiError.expected = true;\n }\n\n return Promise.reject(apiError);\n }\n );\n }\n\n /**\n * Set API Key (server-side only)\n */\n setApiKey(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n /**\n * Set tenant ID\n */\n setTenantId(tenantId: string) {\n this.tenantId = tenantId;\n }\n\n /**\n * Set end user token (for client-side auth)\n * Note: In practice, end user auth uses httpOnly cookies\n */\n setEndUserToken(token: string) {\n this.endUserToken = token;\n }\n\n /**\n * Clear end user token (logout)\n */\n clearEndUserToken() {\n this.endUserToken = undefined;\n }\n\n /**\n * Get underlying axios instance\n */\n getInstance(): AxiosInstance {\n return this.client;\n }\n\n /**\n * Make GET request\n */\n async get<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.get<T>(url, config);\n return response.data;\n }\n\n /**\n * Make POST request\n */\n async post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.post<T>(url, data, config);\n return response.data;\n }\n\n /**\n * Make PUT request\n */\n async put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.put<T>(url, data, config);\n return response.data;\n }\n\n /**\n * Make DELETE request\n */\n async delete<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.delete<T>(url, config);\n return response.data;\n }\n}\n","/**\n * Global Authentication Context\n * Manages authentication state across the entire application\n * Automatically handles session restoration on page reload\n */\n\nimport React, { createContext, useContext, useEffect, useState, useCallback, ReactNode } from 'react';\nimport { useFoxPixelContext } from './FoxPixelContext';\nimport { EndUser, EndUserLoginRequest, ApiError } from '../types';\n\ninterface AuthContextValue {\n user: EndUser | null;\n isLoading: boolean;\n isAuthenticated: boolean;\n error: ApiError | null;\n login: (credentials: EndUserLoginRequest) => Promise<void>;\n logout: () => Promise<void>;\n register: (data: { email: string; password: string; fullName: string; phone?: string }) => Promise<void>;\n updateProfile: (data: { fullName?: string; phone?: string }) => Promise<void>;\n refetch: () => Promise<void>;\n}\n\nconst AuthContext = createContext<AuthContextValue | null>(null);\n\nexport interface AuthProviderProps {\n children: ReactNode;\n /**\n * Redirect path when user is not authenticated\n * Default: '/login'\n */\n loginPath?: string;\n /**\n * Redirect path after successful login\n * Default: '/account'\n */\n accountPath?: string;\n}\n\n/**\n * AuthProvider - Manages authentication state globally\n * \n * Automatically:\n * - Restores session on mount (checks httpOnly cookie)\n * - Manages user state across the app\n * - Handles login/logout transparently\n * \n * @example\n * ```tsx\n * // In _app.tsx\n * <FoxPixelProvider>\n * <AuthProvider>\n * <Component {...pageProps} />\n * </AuthProvider>\n * </FoxPixelProvider>\n * ```\n */\nexport function AuthProvider({ \n children, \n loginPath = '/login',\n accountPath = '/account'\n}: AuthProviderProps) {\n const { client } = useFoxPixelContext();\n const [user, setUser] = useState<EndUser | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n /**\n * Fetch current user from backend\n * Automatically called on mount to restore session\n */\n const fetchCurrentUser = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.get<EndUser>('/api/v1/auth/end-user/me');\n setUser(response);\n } catch (err) {\n const apiError = err as ApiError;\n \n // 401 is expected when not logged in (no cookie)\n // Don't treat it as an error\n if (apiError.status !== 401 && !apiError.expected) {\n setError(apiError);\n }\n \n setUser(null);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Login with email and password\n * Token is automatically stored in httpOnly cookie by backend\n */\n const login = useCallback(async (credentials: EndUserLoginRequest) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.post<{ user: EndUser; message: string }>(\n '/api/v1/auth/end-user/login',\n credentials\n );\n\n setUser(response.user);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n setUser(null);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Register new user\n * Automatically logs in after registration (backend sets cookie)\n */\n const register = useCallback(async (data: { \n email: string; \n password: string; \n fullName: string; \n phone?: string \n }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.post<{ user: EndUser; message: string }>(\n '/api/v1/auth/end-user/register',\n data\n );\n\n // Backend automatically logs in after registration (cookie is set)\n setUser(response.user);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n setUser(null);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Update user profile (fullName, phone)\n * Automatically refreshes user data after update\n */\n const updateProfile = useCallback(async (data: { fullName?: string; phone?: string }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.put<EndUser>(\n '/api/v1/auth/end-user/me',\n data\n );\n\n // Update user state with new data\n setUser(response);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Logout (removes httpOnly cookie)\n */\n const logout = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n await client.post('/api/v1/auth/end-user/logout', {});\n setUser(null);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n // Even if logout fails, clear user state\n setUser(null);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n // Restore session on mount (check if user is already logged in)\n useEffect(() => {\n fetchCurrentUser();\n }, [fetchCurrentUser]);\n\n const value: AuthContextValue = {\n user,\n isLoading,\n isAuthenticated: user !== null,\n error,\n login,\n logout,\n register,\n updateProfile,\n refetch: fetchCurrentUser,\n };\n\n return (\n <AuthContext.Provider value={value}>\n {children}\n </AuthContext.Provider>\n );\n}\n\n/**\n * Hook to access authentication context\n * @throws Error if used outside AuthProvider\n */\nexport function useAuth(): AuthContextValue {\n const context = useContext(AuthContext);\n \n if (!context) {\n throw new Error('useAuth must be used within AuthProvider');\n }\n \n return context;\n}\n","/**\n * ProtectedRoute - Automatically protects pages/routes\n * Redirects to login if user is not authenticated\n *\n * Does NOT use next/router (useRouter) to avoid \"NextRouter was not mounted\"\n * during SSR. Uses window.location for redirect instead.\n *\n * Usage:\n * ```tsx\n * export default function Dashboard() {\n * return (\n * <ProtectedRoute>\n * <YourContent />\n * </ProtectedRoute>\n * );\n * }\n * ```\n */\n\nimport { ReactNode, useEffect, useState } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface ProtectedRouteProps {\n children: ReactNode;\n /**\n * Redirect path when not authenticated\n * Default: '/login'\n */\n loginPath?: string;\n /**\n * Show loading spinner while checking auth\n */\n loadingComponent?: ReactNode;\n}\n\nexport function ProtectedRoute({\n children,\n loginPath = '/login',\n loadingComponent,\n}: ProtectedRouteProps) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (!isLoading && !isAuthenticated) {\n const returnUrl = window.location.pathname + window.location.search;\n const url = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;\n window.location.href = url;\n }\n }, [isMounted, isLoading, isAuthenticated, loginPath]);\n\n // SSR or loading: show placeholder (no useRouter)\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (!isAuthenticated) {\n return null;\n }\n\n return <>{children}</>;\n}\n","/**\n * GuestOnlyRoute - For login/register pages\n * If user is already authenticated, redirects to account (or returnUrl).\n * Otherwise renders children (login/register form).\n *\n * Does NOT use next/router (avoids SSR issues). Uses window.location.\n *\n * Usage:\n * ```tsx\n * export default function Login() {\n * return (\n * <GuestOnlyRoute>\n * <LoginForm />\n * </GuestOnlyRoute>\n * );\n * }\n * ```\n */\n\nimport { ReactNode, useEffect, useState } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface GuestOnlyRouteProps {\n children: ReactNode;\n /**\n * Where to redirect when already authenticated.\n * Default: '/account'\n */\n redirectTo?: string;\n /**\n * Show this while checking auth or redirecting.\n */\n loadingComponent?: ReactNode;\n}\n\n/** Base path for account area. returnUrl must start with this to be trusted. */\nconst ACCOUNT_PREFIX = '/account';\n\nfunction isSafeRedirect(url: string): boolean {\n if (!url || url.startsWith('//') || url.includes(':')) return false;\n return url.startsWith('/') && url.startsWith(ACCOUNT_PREFIX);\n}\n\nexport function GuestOnlyRoute({\n children,\n redirectTo = '/account',\n loadingComponent,\n}: GuestOnlyRouteProps) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (isLoading) return;\n if (!isAuthenticated) return;\n\n const params = new URLSearchParams(window.location.search);\n const returnUrl = params.get('returnUrl');\n const destination =\n returnUrl && isSafeRedirect(returnUrl) ? returnUrl : redirectTo;\n window.location.href = destination;\n }, [isMounted, isLoading, isAuthenticated, redirectTo]);\n\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (isAuthenticated) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">A redirecionar...</div>\n </div>\n )\n );\n }\n\n return <>{children}</>;\n}\n","/**\n * Higher-Order Component (HOC) to protect components\n * Automatically redirects to login if user is not authenticated\n *\n * Does NOT use next/router to avoid SSR \"NextRouter was not mounted\".\n * Uses window.location for redirect.\n *\n * Usage:\n * ```tsx\n * function MyProtectedPage() {\n * return <div>Protected Content</div>;\n * }\n * export default withAuth(MyProtectedPage);\n * ```\n */\n\nimport { ComponentType, useEffect, useState, ReactNode } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface WithAuthOptions {\n loginPath?: string;\n loadingComponent?: ReactNode;\n}\n\nexport function withAuth<P extends object>(\n Component: ComponentType<P>,\n options: WithAuthOptions = {}\n) {\n const { loginPath = '/login', loadingComponent } = options;\n\n return function AuthenticatedComponent(props: P) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (!isLoading && !isAuthenticated) {\n const returnUrl = window.location.pathname + window.location.search;\n window.location.href = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;\n }\n }, [isMounted, isLoading, isAuthenticated, loginPath]);\n\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (!isAuthenticated) {\n return null;\n }\n\n return <Component {...props} />;\n };\n}\n","/**\n * Hook to fetch and manage services (Projects module)\n */\n\nimport { useState, useEffect } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { ServiceCatalogResponse, ApiError } from '../types';\n\ninterface UseServicesOptions {\n category?: string;\n active?: boolean;\n}\n\ninterface UseServicesReturn {\n services: ServiceCatalogResponse[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch services from Projects module\n * \n * @example\n * ```tsx\n * function ServicesPage() {\n * const { services, isLoading, error } = useServices({ active: true });\n * \n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * return (\n * <div>\n * {services?.map(service => (\n * <ServiceCard key={service.id} service={service} />\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useServices(options: UseServicesOptions = {}): UseServicesReturn {\n const { client } = useFoxPixelContext();\n const [services, setServices] = useState<ServiceCatalogResponse[] | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchServices = async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n const params = new URLSearchParams();\n if (options.category) params.append('category', options.category);\n if (options.active !== undefined) params.append('active', String(options.active));\n\n const url = `/api/v1/services${params.toString() ? `?${params.toString()}` : ''}`;\n const data = await client.get<ServiceCatalogResponse[]>(url);\n \n setServices(data);\n } catch (err) {\n setError(err as ApiError);\n setServices(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchServices();\n }, [options.category, options.active]);\n\n return {\n services,\n isLoading,\n error,\n refetch: fetchServices,\n };\n}\n","/**\n * Hook to capture leads (CRM module)\n */\n\nimport { useState } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { CreateLeadRequest, Lead, ApiError } from '../types';\n\ninterface UseLeadCaptureReturn {\n captureLead: (data: CreateLeadRequest) => Promise<Lead>;\n isLoading: boolean;\n error: ApiError | null;\n}\n\n/**\n * Capture a lead (create lead in CRM)\n * \n * @example\n * ```tsx\n * function ContactForm() {\n * const { captureLead, isLoading, error } = useLeadCapture();\n * \n * const handleSubmit = async (e) => {\n * e.preventDefault();\n * try {\n * const lead = await captureLead({\n * fullName: 'John Doe',\n * email: 'john@example.com',\n * phone: '+1234567890',\n * source: 'website',\n * });\n * alert('Lead created!');\n * } catch (err) {\n * console.error('Error:', err);\n * }\n * };\n * \n * return <form onSubmit={handleSubmit}>...</form>;\n * }\n * ```\n */\nexport function useLeadCapture(): UseLeadCaptureReturn {\n const { client } = useFoxPixelContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const captureLead = async (data: CreateLeadRequest): Promise<Lead> => {\n try {\n setIsLoading(true);\n setError(null);\n\n const lead = await client.post<Lead>('/api/v1/leads', data);\n \n return lead;\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n captureLead,\n isLoading,\n error,\n };\n}\n","/**\n * Hook to capture contacts (CRM module)\n */\n\nimport { useState } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\n\ninterface Contact {\n id: string;\n fullName: string;\n email?: string;\n phone?: string;\n company?: string;\n notes?: string;\n postalCode?: string;\n address?: string;\n city?: string;\n createdAt: string;\n}\n\ninterface CreateContactRequest {\n fullName: string;\n email?: string;\n phone?: string;\n company?: string;\n notes?: string;\n nif?: string;\n address?: string;\n postalCode?: string;\n city?: string;\n}\n\ninterface ApiError {\n message: string;\n status?: number;\n code?: string;\n}\n\ninterface UseContactCaptureReturn {\n captureContact: (data: CreateContactRequest) => Promise<Contact>;\n isLoading: boolean;\n error: ApiError | null;\n}\n\n/**\n * Capture a contact (create contact in CRM)\n * \n * The frontend/SDK decides which fields to fill.\n * This hook accepts any fields from CreateContactRequest.\n * \n * @example\n * ```tsx\n * function ContactForm() {\n * const { captureContact, isLoading, error } = useContactCapture();\n * \n * const handleSubmit = async (e) => {\n * e.preventDefault();\n * try {\n * const contact = await captureContact({\n * fullName: 'John Doe',\n * email: 'john@example.com',\n * phone: '+1234567890',\n * postalCode: '75001',\n * notes: 'Interested in garden maintenance',\n * });\n * alert('Contact created!');\n * } catch (err) {\n * console.error('Error:', err);\n * }\n * };\n * \n * return <form onSubmit={handleSubmit}>...</form>;\n * }\n * ```\n */\nexport function useContactCapture(): UseContactCaptureReturn {\n const { client } = useFoxPixelContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const captureContact = async (data: CreateContactRequest): Promise<Contact> => {\n try {\n setIsLoading(true);\n setError(null);\n\n const contact = await client.post<Contact>('/api/v1/contacts', data);\n \n return contact;\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n captureContact,\n isLoading,\n error,\n };\n}\n"],"mappings":";AAKA,SAAgB,eAAe,YAAY,eAA0B;;;ACArE,OAAO,WAA8D;AAG9D,IAAM,qBAAN,MAAyB;AAAA,EAM9B,YAAY,QAAwB;AAClC,UAAM,SAAS,OAAO,UAAU,QAAQ,IAAI,gCAAgC;AAE5E,SAAK,SAAS,MAAM,OAAO;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;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["config","createContext","useContext","jsx","createContext","useContext","useEffect","useState","jsx","useState","useEffect","useEffect","useState","Fragment","jsx","useState","useEffect","useEffect","useState","jsx","useState","useEffect","useState","useEffect","useState","useEffect","useState","useState","useState","useState"]}
1
+ {"version":3,"sources":["../src/context/FoxPixelContext.tsx","../src/client/http.ts","../src/context/AuthContext.tsx","../src/components/ProtectedRoute.tsx","../src/components/GuestOnlyRoute.tsx","../src/components/withAuth.tsx","../src/hooks/useServices.ts","../src/hooks/useLeadCapture.ts","../src/hooks/useContactCapture.ts","../src/blog/hooks.ts","../src/blog/admin-hooks.ts","../src/blog/utils.ts"],"sourcesContent":["/**\n * React Context for FoxPixel SDK\n * Provides HTTP client and configuration to all hooks\n */\n\nimport React, { createContext, useContext, useMemo, ReactNode } from 'react';\nimport { FoxPixelHttpClient } from '../client/http';\nimport { FoxPixelConfig } from '../types';\n\ninterface FoxPixelContextValue {\n client: FoxPixelHttpClient;\n config: FoxPixelConfig;\n}\n\nconst FoxPixelContext = createContext<FoxPixelContextValue | null>(null);\n\nexport interface FoxPixelProviderProps {\n children: ReactNode;\n config?: FoxPixelConfig;\n}\n\n/**\n * FoxPixelProvider - Wraps your app and provides SDK functionality\n * \n * IMPORTANT: API Key should NEVER be passed from client-side.\n * Use server-side proxy (Next.js API routes) for API Key authentication.\n * \n * @example\n * ```tsx\n * // Client-side (no API Key)\n * <FoxPixelProvider>\n * <App />\n * </FoxPixelProvider>\n * \n * // Server-side proxy (Next.js API route)\n * // pages/api/foxpixel/[...path].ts\n * export default async function handler(req, res) {\n * const apiKey = process.env.FOXPIXEL_API_KEY;\n * // Proxy request with API Key\n * }\n * ```\n */\nexport function FoxPixelProvider({ children, config = {} }: FoxPixelProviderProps) {\n const client = useMemo(() => {\n return new FoxPixelHttpClient(config);\n }, [config.apiUrl, config.apiKey, config.tenantId]);\n\n const value = useMemo(() => ({\n client,\n config,\n }), [client, config]);\n\n return (\n <FoxPixelContext.Provider value={value}>\n {children}\n </FoxPixelContext.Provider>\n );\n}\n\n/**\n * Hook to access FoxPixel context\n * @throws Error if used outside FoxPixelProvider\n */\nexport function useFoxPixelContext(): FoxPixelContextValue {\n const context = useContext(FoxPixelContext);\n \n if (!context) {\n throw new Error('useFoxPixelContext must be used within FoxPixelProvider');\n }\n \n return context;\n}\n","/**\n * HTTP client for FoxPixel API\n * Handles authentication and request/response transformation\n */\n\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosError } from 'axios';\nimport { FoxPixelConfig, ApiError } from '../types';\n\nexport class FoxPixelHttpClient {\n private client: AxiosInstance;\n private apiKey?: string;\n private tenantId?: string;\n private endUserToken?: string;\n\n constructor(config: FoxPixelConfig) {\n const apiUrl = config.apiUrl || process.env.NEXT_PUBLIC_FOXPIXEL_API_URL || 'https://api.foxpixel.com';\n \n this.client = axios.create({\n baseURL: apiUrl,\n headers: {\n 'Content-Type': 'application/json',\n },\n withCredentials: true, // Important for httpOnly cookies (End User auth)\n });\n\n this.apiKey = config.apiKey || process.env.FOXPIXEL_API_KEY;\n this.tenantId = config.tenantId;\n\n // Setup request interceptor\n this.client.interceptors.request.use(\n (config) => {\n // If end user is logged in, use their token\n // Otherwise, use API Key (server-side only)\n if (this.endUserToken) {\n // End user token is sent via httpOnly cookie automatically\n // No need to set Authorization header\n } else if (this.apiKey) {\n // API Key should only be used server-side\n // In production, this should be proxied through Next.js API routes\n config.headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n return config;\n },\n (error) => Promise.reject(error)\n );\n\n // Setup response interceptor for error handling\n this.client.interceptors.response.use(\n (response) => response,\n (error: AxiosError) => {\n const apiError: ApiError = {\n message: 'An error occurred',\n status: error.response?.status,\n };\n\n if (error.response?.data) {\n const data = error.response.data as any;\n apiError.message = data.message || data.error || apiError.message;\n apiError.code = data.code;\n }\n\n // Mark 401 on /me endpoint as \"expected\" (not an error)\n // 401 is expected when checking if user is logged in (no cookie = not logged in)\n // The hook (useAuth) will handle this gracefully by ignoring 401\n const requestUrl = error.config?.url || '';\n const isMeEndpoint = requestUrl.includes('/auth/end-user/me');\n const isUnauthorized = error.response?.status === 401;\n\n if (isMeEndpoint && isUnauthorized) {\n // Mark as expected error (hook will handle silently)\n apiError.expected = true;\n }\n\n return Promise.reject(apiError);\n }\n );\n }\n\n /**\n * Set API Key (server-side only)\n */\n setApiKey(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n /**\n * Set tenant ID\n */\n setTenantId(tenantId: string) {\n this.tenantId = tenantId;\n }\n\n /**\n * Set end user token (for client-side auth)\n * Note: In practice, end user auth uses httpOnly cookies\n */\n setEndUserToken(token: string) {\n this.endUserToken = token;\n }\n\n /**\n * Clear end user token (logout)\n */\n clearEndUserToken() {\n this.endUserToken = undefined;\n }\n\n /**\n * Get underlying axios instance\n */\n getInstance(): AxiosInstance {\n return this.client;\n }\n\n /**\n * Make GET request\n */\n async get<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.get<T>(url, config);\n return response.data;\n }\n\n /**\n * Make POST request\n */\n async post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.post<T>(url, data, config);\n return response.data;\n }\n\n /**\n * Make PUT request\n */\n async put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.put<T>(url, data, config);\n return response.data;\n }\n\n /**\n * Make DELETE request\n */\n async delete<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.delete<T>(url, config);\n return response.data;\n }\n}\n","/**\n * Global Authentication Context\n * Manages authentication state across the entire application\n * Automatically handles session restoration on page reload\n */\n\nimport React, { createContext, useContext, useEffect, useState, useCallback, ReactNode } from 'react';\nimport { useFoxPixelContext } from './FoxPixelContext';\nimport { EndUser, EndUserLoginRequest, ApiError } from '../types';\n\ninterface AuthContextValue {\n user: EndUser | null;\n isLoading: boolean;\n isAuthenticated: boolean;\n error: ApiError | null;\n login: (credentials: EndUserLoginRequest) => Promise<void>;\n logout: () => Promise<void>;\n register: (data: { email: string; password: string; fullName: string; phone?: string }) => Promise<void>;\n updateProfile: (data: { fullName?: string; phone?: string }) => Promise<void>;\n refetch: () => Promise<void>;\n}\n\nconst AuthContext = createContext<AuthContextValue | null>(null);\n\nexport interface AuthProviderProps {\n children: ReactNode;\n /**\n * Redirect path when user is not authenticated\n * Default: '/login'\n */\n loginPath?: string;\n /**\n * Redirect path after successful login\n * Default: '/account'\n */\n accountPath?: string;\n}\n\n/**\n * AuthProvider - Manages authentication state globally\n * \n * Automatically:\n * - Restores session on mount (checks httpOnly cookie)\n * - Manages user state across the app\n * - Handles login/logout transparently\n * \n * @example\n * ```tsx\n * // In _app.tsx\n * <FoxPixelProvider>\n * <AuthProvider>\n * <Component {...pageProps} />\n * </AuthProvider>\n * </FoxPixelProvider>\n * ```\n */\nexport function AuthProvider({ \n children, \n loginPath = '/login',\n accountPath = '/account'\n}: AuthProviderProps) {\n const { client } = useFoxPixelContext();\n const [user, setUser] = useState<EndUser | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n /**\n * Fetch current user from backend\n * Automatically called on mount to restore session\n */\n const fetchCurrentUser = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.get<EndUser>('/api/v1/auth/end-user/me');\n setUser(response);\n } catch (err) {\n const apiError = err as ApiError;\n \n // 401 is expected when not logged in (no cookie)\n // Don't treat it as an error\n if (apiError.status !== 401 && !apiError.expected) {\n setError(apiError);\n }\n \n setUser(null);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Login with email and password\n * Token is automatically stored in httpOnly cookie by backend\n */\n const login = useCallback(async (credentials: EndUserLoginRequest) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.post<{ user: EndUser; message: string }>(\n '/api/v1/auth/end-user/login',\n credentials\n );\n\n setUser(response.user);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n setUser(null);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Register new user\n * Automatically logs in after registration (backend sets cookie)\n */\n const register = useCallback(async (data: { \n email: string; \n password: string; \n fullName: string; \n phone?: string \n }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.post<{ user: EndUser; message: string }>(\n '/api/v1/auth/end-user/register',\n data\n );\n\n // Backend automatically logs in after registration (cookie is set)\n setUser(response.user);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n setUser(null);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Update user profile (fullName, phone)\n * Automatically refreshes user data after update\n */\n const updateProfile = useCallback(async (data: { fullName?: string; phone?: string }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.put<EndUser>(\n '/api/v1/auth/end-user/me',\n data\n );\n\n // Update user state with new data\n setUser(response);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Logout (removes httpOnly cookie)\n */\n const logout = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n await client.post('/api/v1/auth/end-user/logout', {});\n setUser(null);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n // Even if logout fails, clear user state\n setUser(null);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n // Restore session on mount (check if user is already logged in)\n useEffect(() => {\n fetchCurrentUser();\n }, [fetchCurrentUser]);\n\n const value: AuthContextValue = {\n user,\n isLoading,\n isAuthenticated: user !== null,\n error,\n login,\n logout,\n register,\n updateProfile,\n refetch: fetchCurrentUser,\n };\n\n return (\n <AuthContext.Provider value={value}>\n {children}\n </AuthContext.Provider>\n );\n}\n\n/**\n * Hook to access authentication context\n * @throws Error if used outside AuthProvider\n */\nexport function useAuth(): AuthContextValue {\n const context = useContext(AuthContext);\n \n if (!context) {\n throw new Error('useAuth must be used within AuthProvider');\n }\n \n return context;\n}\n","/**\n * ProtectedRoute - Automatically protects pages/routes\n * Redirects to login if user is not authenticated\n *\n * Does NOT use next/router (useRouter) to avoid \"NextRouter was not mounted\"\n * during SSR. Uses window.location for redirect instead.\n *\n * Usage:\n * ```tsx\n * export default function Dashboard() {\n * return (\n * <ProtectedRoute>\n * <YourContent />\n * </ProtectedRoute>\n * );\n * }\n * ```\n */\n\nimport { ReactNode, useEffect, useState } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface ProtectedRouteProps {\n children: ReactNode;\n /**\n * Redirect path when not authenticated\n * Default: '/login'\n */\n loginPath?: string;\n /**\n * Show loading spinner while checking auth\n */\n loadingComponent?: ReactNode;\n}\n\nexport function ProtectedRoute({\n children,\n loginPath = '/login',\n loadingComponent,\n}: ProtectedRouteProps) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (!isLoading && !isAuthenticated) {\n const returnUrl = window.location.pathname + window.location.search;\n const url = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;\n window.location.href = url;\n }\n }, [isMounted, isLoading, isAuthenticated, loginPath]);\n\n // SSR or loading: show placeholder (no useRouter)\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (!isAuthenticated) {\n return null;\n }\n\n return <>{children}</>;\n}\n","/**\n * GuestOnlyRoute - For login/register pages\n * If user is already authenticated, redirects to account (or returnUrl).\n * Otherwise renders children (login/register form).\n *\n * Does NOT use next/router (avoids SSR issues). Uses window.location.\n *\n * Usage:\n * ```tsx\n * export default function Login() {\n * return (\n * <GuestOnlyRoute>\n * <LoginForm />\n * </GuestOnlyRoute>\n * );\n * }\n * ```\n */\n\nimport { ReactNode, useEffect, useState } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface GuestOnlyRouteProps {\n children: ReactNode;\n /**\n * Where to redirect when already authenticated.\n * Default: '/account'\n */\n redirectTo?: string;\n /**\n * Show this while checking auth or redirecting.\n */\n loadingComponent?: ReactNode;\n}\n\n/** Base path for account area. returnUrl must start with this to be trusted. */\nconst ACCOUNT_PREFIX = '/account';\n\nfunction isSafeRedirect(url: string): boolean {\n if (!url || url.startsWith('//') || url.includes(':')) return false;\n return url.startsWith('/') && url.startsWith(ACCOUNT_PREFIX);\n}\n\nexport function GuestOnlyRoute({\n children,\n redirectTo = '/account',\n loadingComponent,\n}: GuestOnlyRouteProps) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (isLoading) return;\n if (!isAuthenticated) return;\n\n const params = new URLSearchParams(window.location.search);\n const returnUrl = params.get('returnUrl');\n const destination =\n returnUrl && isSafeRedirect(returnUrl) ? returnUrl : redirectTo;\n window.location.href = destination;\n }, [isMounted, isLoading, isAuthenticated, redirectTo]);\n\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (isAuthenticated) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">A redirecionar...</div>\n </div>\n )\n );\n }\n\n return <>{children}</>;\n}\n","/**\n * Higher-Order Component (HOC) to protect components\n * Automatically redirects to login if user is not authenticated\n *\n * Does NOT use next/router to avoid SSR \"NextRouter was not mounted\".\n * Uses window.location for redirect.\n *\n * Usage:\n * ```tsx\n * function MyProtectedPage() {\n * return <div>Protected Content</div>;\n * }\n * export default withAuth(MyProtectedPage);\n * ```\n */\n\nimport { ComponentType, useEffect, useState, ReactNode } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface WithAuthOptions {\n loginPath?: string;\n loadingComponent?: ReactNode;\n}\n\nexport function withAuth<P extends object>(\n Component: ComponentType<P>,\n options: WithAuthOptions = {}\n) {\n const { loginPath = '/login', loadingComponent } = options;\n\n return function AuthenticatedComponent(props: P) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (!isLoading && !isAuthenticated) {\n const returnUrl = window.location.pathname + window.location.search;\n window.location.href = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;\n }\n }, [isMounted, isLoading, isAuthenticated, loginPath]);\n\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (!isAuthenticated) {\n return null;\n }\n\n return <Component {...props} />;\n };\n}\n","/**\n * Hook to fetch and manage services (Projects module)\n */\n\nimport { useState, useEffect } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { ServiceCatalogResponse, ApiError } from '../types';\n\ninterface UseServicesOptions {\n category?: string;\n active?: boolean;\n}\n\ninterface UseServicesReturn {\n services: ServiceCatalogResponse[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch services from Projects module\n * \n * @example\n * ```tsx\n * function ServicesPage() {\n * const { services, isLoading, error } = useServices({ active: true });\n * \n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * return (\n * <div>\n * {services?.map(service => (\n * <ServiceCard key={service.id} service={service} />\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useServices(options: UseServicesOptions = {}): UseServicesReturn {\n const { client } = useFoxPixelContext();\n const [services, setServices] = useState<ServiceCatalogResponse[] | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchServices = async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n const params = new URLSearchParams();\n if (options.category) params.append('category', options.category);\n if (options.active !== undefined) params.append('active', String(options.active));\n\n const url = `/api/v1/services${params.toString() ? `?${params.toString()}` : ''}`;\n const data = await client.get<ServiceCatalogResponse[]>(url);\n \n setServices(data);\n } catch (err) {\n setError(err as ApiError);\n setServices(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchServices();\n }, [options.category, options.active]);\n\n return {\n services,\n isLoading,\n error,\n refetch: fetchServices,\n };\n}\n","/**\n * Hook to capture leads (CRM module)\n */\n\nimport { useState } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { CreateLeadRequest, Lead, ApiError } from '../types';\n\ninterface UseLeadCaptureReturn {\n captureLead: (data: CreateLeadRequest) => Promise<Lead>;\n isLoading: boolean;\n error: ApiError | null;\n}\n\n/**\n * Capture a lead (create lead in CRM)\n * \n * @example\n * ```tsx\n * function ContactForm() {\n * const { captureLead, isLoading, error } = useLeadCapture();\n * \n * const handleSubmit = async (e) => {\n * e.preventDefault();\n * try {\n * const lead = await captureLead({\n * fullName: 'John Doe',\n * email: 'john@example.com',\n * phone: '+1234567890',\n * source: 'website',\n * });\n * alert('Lead created!');\n * } catch (err) {\n * console.error('Error:', err);\n * }\n * };\n * \n * return <form onSubmit={handleSubmit}>...</form>;\n * }\n * ```\n */\nexport function useLeadCapture(): UseLeadCaptureReturn {\n const { client } = useFoxPixelContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const captureLead = async (data: CreateLeadRequest): Promise<Lead> => {\n try {\n setIsLoading(true);\n setError(null);\n\n const lead = await client.post<Lead>('/api/v1/leads', data);\n \n return lead;\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n captureLead,\n isLoading,\n error,\n };\n}\n","/**\n * Hook to capture contacts (CRM module)\n */\n\nimport { useState } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\n\ninterface Contact {\n id: string;\n fullName: string;\n email?: string;\n phone?: string;\n company?: string;\n notes?: string;\n postalCode?: string;\n address?: string;\n city?: string;\n createdAt: string;\n}\n\ninterface CreateContactRequest {\n fullName: string;\n email?: string;\n phone?: string;\n company?: string;\n notes?: string;\n nif?: string;\n address?: string;\n postalCode?: string;\n city?: string;\n}\n\ninterface ApiError {\n message: string;\n status?: number;\n code?: string;\n}\n\ninterface UseContactCaptureReturn {\n captureContact: (data: CreateContactRequest) => Promise<Contact>;\n isLoading: boolean;\n error: ApiError | null;\n}\n\n/**\n * Capture a contact (create contact in CRM)\n * \n * The frontend/SDK decides which fields to fill.\n * This hook accepts any fields from CreateContactRequest.\n * \n * @example\n * ```tsx\n * function ContactForm() {\n * const { captureContact, isLoading, error } = useContactCapture();\n * \n * const handleSubmit = async (e) => {\n * e.preventDefault();\n * try {\n * const contact = await captureContact({\n * fullName: 'John Doe',\n * email: 'john@example.com',\n * phone: '+1234567890',\n * postalCode: '75001',\n * notes: 'Interested in garden maintenance',\n * });\n * alert('Contact created!');\n * } catch (err) {\n * console.error('Error:', err);\n * }\n * };\n * \n * return <form onSubmit={handleSubmit}>...</form>;\n * }\n * ```\n */\nexport function useContactCapture(): UseContactCaptureReturn {\n const { client } = useFoxPixelContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const captureContact = async (data: CreateContactRequest): Promise<Contact> => {\n try {\n setIsLoading(true);\n setError(null);\n\n const contact = await client.post<Contact>('/api/v1/contacts', data);\n \n return contact;\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n captureContact,\n isLoading,\n error,\n };\n}\n","/**\n * Hooks for Blog module (public API - SDK / headless)\n */\n\nimport { useState, useEffect } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { ApiError } from '../types';\nimport type {\n BlogPost,\n BlogPostPage,\n BlogCategory,\n BlogTag,\n BlogComment,\n CreateBlogCommentPayload,\n NewsletterSubscriber,\n SubscribeNewsletterPayload\n} from './types';\n\nexport interface UseBlogPostsOptions {\n page?: number;\n limit?: number;\n}\n\nexport interface UseBlogPostsReturn {\n data: BlogPostPage | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch published blog posts (paginated)\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useBlogPosts({ page: 0, limit: 10 });\n * data?.content.map(post => <PostCard key={post.id} post={post} />)\n * ```\n */\nexport function useBlogPosts(options: UseBlogPostsOptions = {}): UseBlogPostsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogPostPage | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const page = options.page ?? 0;\n const limit = options.limit ?? 10;\n\n const fetchPosts = async () => {\n try {\n setIsLoading(true);\n setError(null);\n const params = new URLSearchParams();\n params.append('page', String(page));\n params.append('size', String(limit));\n const url = `/api/v1/blog/posts?${params.toString()}`;\n const result = await client.get<BlogPostPage>(url);\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n setData(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchPosts();\n }, [page, limit]);\n\n return {\n data,\n isLoading,\n error,\n refetch: fetchPosts,\n };\n}\n\nexport interface UseBlogPostReturn {\n data: BlogPost | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch a single published blog post by slug\n *\n * @example\n * ```tsx\n * const { data: post, isLoading } = useBlogPost('my-post-slug');\n * ```\n */\nexport function useBlogPost(slug: string | undefined | null): UseBlogPostReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogPost | null>(null);\n const [isLoading, setIsLoading] = useState(!!slug);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchPost = async () => {\n if (!slug) {\n setData(null);\n setIsLoading(false);\n return;\n }\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogPost>(`/api/v1/blog/posts/${encodeURIComponent(slug)}`);\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n setData(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchPost();\n }, [slug]);\n\n return {\n data,\n isLoading,\n error,\n refetch: fetchPost,\n };\n}\n\nexport interface UseBlogCategoriesReturn {\n data: BlogCategory[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch blog categories (for filters / navigation)\n */\nexport function useBlogCategories(): UseBlogCategoriesReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogCategory[] | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchCategories = async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogCategory[]>('/api/v1/blog/categories');\n setData(Array.isArray(result) ? result : []);\n } catch (err) {\n setError(err as ApiError);\n setData(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchCategories();\n }, []);\n\n return {\n data,\n isLoading,\n error,\n refetch: fetchCategories,\n };\n}\n\nexport interface UseBlogTagsReturn {\n data: BlogTag[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch blog tags (for filters / display)\n */\nexport function useBlogTags(): UseBlogTagsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogTag[] | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchTags = async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogTag[]>('/api/v1/blog/tags');\n setData(Array.isArray(result) ? result : []);\n } catch (err) {\n setError(err as ApiError);\n setData(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchTags();\n }, []);\n\n return {\n data,\n isLoading,\n error,\n refetch: fetchTags,\n };\n}\n\nexport interface UseBlogCommentsReturn {\n data: BlogComment[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch approved comments for a published blog post (public API)\n *\n * @example\n * ```tsx\n * const { data: comments, refetch } = useBlogComments(post?.slug);\n * ```\n */\nexport function useBlogComments(slug: string | undefined | null): UseBlogCommentsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogComment[] | null>(null);\n const [isLoading, setIsLoading] = useState(!!slug);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchComments = async () => {\n if (!slug) {\n setData(null);\n setIsLoading(false);\n return;\n }\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogComment[]>(\n `/api/v1/blog/posts/${encodeURIComponent(slug)}/comments`\n );\n setData(Array.isArray(result) ? result : []);\n } catch (err) {\n setError(err as ApiError);\n setData(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchComments();\n }, [slug]);\n\n return {\n data,\n isLoading,\n error,\n refetch: fetchComments,\n };\n}\n\nexport interface UseBlogCommentSubmitReturn {\n submit: (payload: CreateBlogCommentPayload) => Promise<BlogComment | null>;\n isSubmitting: boolean;\n error: ApiError | null;\n resetError: () => void;\n}\n\n/**\n * Submit a comment on a published blog post (public API). Call refetch on comments after success.\n *\n * @example\n * ```tsx\n * const { submit, isSubmitting, error } = useBlogCommentSubmit(post?.slug);\n * await submit({ guestName: 'João', guestEmail: 'j@x.com', content: 'Texto' });\n * refetch(); // from useBlogComments\n * ```\n */\nexport function useBlogCommentSubmit(slug: string | undefined | null): UseBlogCommentSubmitReturn {\n const { client } = useFoxPixelContext();\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const submit = async (payload: CreateBlogCommentPayload): Promise<BlogComment | null> => {\n if (!slug) return null;\n try {\n setIsSubmitting(true);\n setError(null);\n const result = await client.post<BlogComment>(\n `/api/v1/blog/posts/${encodeURIComponent(slug)}/comments`,\n payload\n );\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const resetError = () => setError(null);\n\n return {\n submit,\n isSubmitting,\n error,\n resetError,\n };\n}\n\n// ==================== Featured Posts Hook ====================\n\nexport interface UseBlogFeaturedPostsReturn {\n data: BlogPostPage | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch featured blog posts\n */\nexport function useBlogFeaturedPosts(limit = 6): UseBlogFeaturedPostsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogPostPage | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchFeatured = async () => {\n try {\n setIsLoading(true);\n setError(null);\n const params = new URLSearchParams();\n params.append('page', '0');\n params.append('size', String(limit));\n const url = `/api/v1/blog/posts/featured?${params.toString()}`;\n const result = await client.get<BlogPostPage>(url);\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n setData(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchFeatured();\n }, [limit]);\n\n return {\n data,\n isLoading,\n error,\n refetch: fetchFeatured,\n };\n}\n\n// ==================== Newsletter Hooks ====================\n\nexport interface UseNewsletterSubscribeReturn {\n subscribe: (payload: SubscribeNewsletterPayload) => Promise<NewsletterSubscriber | null>;\n isSubmitting: boolean;\n error: ApiError | null;\n success: boolean;\n reset: () => void;\n}\n\n/**\n * Subscribe to newsletter (public API)\n *\n * @example\n * ```tsx\n * const { subscribe, isSubmitting, success, error } = useNewsletterSubscribe();\n * await subscribe({ email: 'user@example.com', name: 'John' });\n * ```\n */\nexport function useNewsletterSubscribe(): UseNewsletterSubscribeReturn {\n const { client } = useFoxPixelContext();\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n const [success, setSuccess] = useState(false);\n\n const subscribe = async (payload: SubscribeNewsletterPayload): Promise<NewsletterSubscriber | null> => {\n try {\n setIsSubmitting(true);\n setError(null);\n setSuccess(false);\n const result = await client.post<NewsletterSubscriber>(\n '/api/v1/blog/newsletter/subscribe',\n payload\n );\n setSuccess(true);\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const reset = () => {\n setError(null);\n setSuccess(false);\n };\n\n return {\n subscribe,\n isSubmitting,\n error,\n success,\n reset,\n };\n}\n\nexport interface UseNewsletterUnsubscribeReturn {\n unsubscribe: (email: string) => Promise<boolean>;\n isSubmitting: boolean;\n error: ApiError | null;\n success: boolean;\n}\n\n/**\n * Unsubscribe from newsletter (public API)\n */\nexport function useNewsletterUnsubscribe(): UseNewsletterUnsubscribeReturn {\n const { client } = useFoxPixelContext();\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n const [success, setSuccess] = useState(false);\n\n const unsubscribe = async (email: string): Promise<boolean> => {\n try {\n setIsSubmitting(true);\n setError(null);\n setSuccess(false);\n await client.post('/api/v1/blog/newsletter/unsubscribe', null, {\n params: { email },\n });\n setSuccess(true);\n return true;\n } catch (err) {\n setError(err as ApiError);\n return false;\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return {\n unsubscribe,\n isSubmitting,\n error,\n success,\n };\n}\n","/**\n * Admin hooks for Blog module (tenant-admin dashboard)\n * These hooks use the authenticated admin API endpoints\n */\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { ApiError } from '../types';\nimport type {\n BlogPost,\n BlogPostPage,\n BlogCategory,\n BlogTag,\n BlogComment,\n NewsletterSubscriber,\n NewsletterSubscriberPage,\n NewsletterStats,\n BlogSettings,\n BlogAnalyticsSummary,\n} from './types';\n\n// ==================== Posts Admin ====================\n\nexport interface CreateBlogPostPayload {\n title: string;\n slug?: string;\n excerpt?: string;\n content: string;\n coverImageUrl?: string;\n metaTitle?: string;\n metaDescription?: string;\n canonicalUrl?: string;\n ogTitle?: string;\n ogDescription?: string;\n ogImageUrl?: string;\n status?: 'DRAFT' | 'SCHEDULED' | 'PUBLISHED';\n scheduledAt?: string;\n isFeatured?: boolean;\n allowComments?: boolean;\n categoryIds?: string[];\n tagIds?: string[];\n isAiGenerated?: boolean;\n aiGenerationMetadata?: Record<string, unknown>;\n businessContextSnapshot?: string;\n}\n\nexport interface UpdateBlogPostPayload extends Partial<CreateBlogPostPayload> {\n changeReason?: string;\n}\n\nexport interface UseAdminBlogPostsOptions {\n page?: number;\n size?: number;\n}\n\nexport interface UseAdminBlogPostsReturn {\n data: BlogPostPage | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\nexport function useAdminBlogPosts(options: UseAdminBlogPostsOptions = {}): UseAdminBlogPostsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogPostPage | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const page = options.page ?? 0;\n const size = options.size ?? 20;\n\n const fetchPosts = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const params = new URLSearchParams();\n params.append('page', String(page));\n params.append('size', String(size));\n const result = await client.get<BlogPostPage>(`/api/blog/posts?${params.toString()}`);\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client, page, size]);\n\n useEffect(() => {\n fetchPosts();\n }, [fetchPosts]);\n\n return { data, isLoading, error, refetch: fetchPosts };\n}\n\nexport interface UseAdminBlogPostReturn {\n data: BlogPost | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\nexport function useAdminBlogPost(id: string | undefined | null): UseAdminBlogPostReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogPost | null>(null);\n const [isLoading, setIsLoading] = useState(!!id);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchPost = useCallback(async () => {\n if (!id) {\n setData(null);\n setIsLoading(false);\n return;\n }\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogPost>(`/api/blog/posts/${id}`);\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client, id]);\n\n useEffect(() => {\n fetchPost();\n }, [fetchPost]);\n\n return { data, isLoading, error, refetch: fetchPost };\n}\n\nexport interface UseAdminBlogPostMutationsReturn {\n create: (payload: CreateBlogPostPayload) => Promise<BlogPost | null>;\n update: (id: string, payload: UpdateBlogPostPayload) => Promise<BlogPost | null>;\n remove: (id: string) => Promise<boolean>;\n isLoading: boolean;\n error: ApiError | null;\n}\n\nexport function useAdminBlogPostMutations(): UseAdminBlogPostMutationsReturn {\n const { client } = useFoxPixelContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const create = async (payload: CreateBlogPostPayload): Promise<BlogPost | null> => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.post<BlogPost>('/api/blog/posts', payload);\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n } finally {\n setIsLoading(false);\n }\n };\n\n const update = async (id: string, payload: UpdateBlogPostPayload): Promise<BlogPost | null> => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.put<BlogPost>(`/api/blog/posts/${id}`, payload);\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n } finally {\n setIsLoading(false);\n }\n };\n\n const remove = async (id: string): Promise<boolean> => {\n try {\n setIsLoading(true);\n setError(null);\n await client.delete(`/api/blog/posts/${id}`);\n return true;\n } catch (err) {\n setError(err as ApiError);\n return false;\n } finally {\n setIsLoading(false);\n }\n };\n\n return { create, update, remove, isLoading, error };\n}\n\n// ==================== Categories Admin ====================\n\nexport interface CreateCategoryPayload {\n name: string;\n slug?: string;\n description?: string;\n color?: string;\n parentId?: string;\n sortOrder?: number;\n}\n\nexport interface UseAdminBlogCategoriesReturn {\n data: BlogCategory[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n create: (payload: CreateCategoryPayload) => Promise<BlogCategory | null>;\n update: (id: string, payload: Partial<CreateCategoryPayload>) => Promise<BlogCategory | null>;\n remove: (id: string) => Promise<boolean>;\n}\n\nexport function useAdminBlogCategories(): UseAdminBlogCategoriesReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogCategory[] | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchCategories = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogCategory[]>('/api/blog/categories');\n setData(Array.isArray(result) ? result : []);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n useEffect(() => {\n fetchCategories();\n }, [fetchCategories]);\n\n const create = async (payload: CreateCategoryPayload): Promise<BlogCategory | null> => {\n try {\n const result = await client.post<BlogCategory>('/api/blog/categories', payload);\n await fetchCategories();\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n }\n };\n\n const update = async (id: string, payload: Partial<CreateCategoryPayload>): Promise<BlogCategory | null> => {\n try {\n const result = await client.put<BlogCategory>(`/api/blog/categories/${id}`, payload);\n await fetchCategories();\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n }\n };\n\n const remove = async (id: string): Promise<boolean> => {\n try {\n await client.delete(`/api/blog/categories/${id}`);\n await fetchCategories();\n return true;\n } catch (err) {\n setError(err as ApiError);\n return false;\n }\n };\n\n return { data, isLoading, error, refetch: fetchCategories, create, update, remove };\n}\n\n// ==================== Tags Admin ====================\n\nexport interface CreateTagPayload {\n name: string;\n slug?: string;\n}\n\nexport interface UseAdminBlogTagsReturn {\n data: BlogTag[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n create: (payload: CreateTagPayload) => Promise<BlogTag | null>;\n update: (id: string, payload: Partial<CreateTagPayload>) => Promise<BlogTag | null>;\n remove: (id: string) => Promise<boolean>;\n}\n\nexport function useAdminBlogTags(): UseAdminBlogTagsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogTag[] | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchTags = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogTag[]>('/api/blog/tags');\n setData(Array.isArray(result) ? result : []);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n useEffect(() => {\n fetchTags();\n }, [fetchTags]);\n\n const create = async (payload: CreateTagPayload): Promise<BlogTag | null> => {\n try {\n const result = await client.post<BlogTag>('/api/blog/tags', payload);\n await fetchTags();\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n }\n };\n\n const update = async (id: string, payload: Partial<CreateTagPayload>): Promise<BlogTag | null> => {\n try {\n const result = await client.put<BlogTag>(`/api/blog/tags/${id}`, payload);\n await fetchTags();\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n }\n };\n\n const remove = async (id: string): Promise<boolean> => {\n try {\n await client.delete(`/api/blog/tags/${id}`);\n await fetchTags();\n return true;\n } catch (err) {\n setError(err as ApiError);\n return false;\n }\n };\n\n return { data, isLoading, error, refetch: fetchTags, create, update, remove };\n}\n\n// ==================== Comments Admin ====================\n\nexport interface UseAdminBlogCommentsOptions {\n status?: string;\n postId?: string;\n page?: number;\n size?: number;\n}\n\nexport interface BlogCommentAdmin extends BlogComment {\n postTitle?: string;\n postSlug?: string;\n authorEmail?: string;\n}\n\nexport interface BlogCommentPage {\n content: BlogCommentAdmin[];\n totalElements: number;\n totalPages: number;\n size: number;\n number: number;\n first: boolean;\n last: boolean;\n empty: boolean;\n}\n\nexport interface UseAdminBlogCommentsReturn {\n data: BlogCommentPage | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n updateStatus: (id: string, status: 'APPROVED' | 'REJECTED' | 'SPAM') => Promise<boolean>;\n remove: (id: string) => Promise<boolean>;\n}\n\nexport function useAdminBlogComments(options: UseAdminBlogCommentsOptions = {}): UseAdminBlogCommentsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogCommentPage | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const { status, postId, page = 0, size = 20 } = options;\n\n const fetchComments = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const params = new URLSearchParams();\n params.append('page', String(page));\n params.append('size', String(size));\n if (status) params.append('status', status);\n if (postId) params.append('postId', postId);\n const result = await client.get<BlogCommentPage>(`/api/blog/comments?${params.toString()}`);\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client, status, postId, page, size]);\n\n useEffect(() => {\n fetchComments();\n }, [fetchComments]);\n\n const updateStatus = async (id: string, newStatus: 'APPROVED' | 'REJECTED' | 'SPAM'): Promise<boolean> => {\n try {\n await client.put(`/api/blog/comments/${id}/status`, { status: newStatus });\n await fetchComments();\n return true;\n } catch (err) {\n setError(err as ApiError);\n return false;\n }\n };\n\n const remove = async (id: string): Promise<boolean> => {\n try {\n await client.delete(`/api/blog/comments/${id}`);\n await fetchComments();\n return true;\n } catch (err) {\n setError(err as ApiError);\n return false;\n }\n };\n\n return { data, isLoading, error, refetch: fetchComments, updateStatus, remove };\n}\n\n// ==================== Newsletter Admin ====================\n\nexport interface UseAdminNewsletterSubscribersOptions {\n status?: string;\n page?: number;\n size?: number;\n}\n\nexport interface UseAdminNewsletterSubscribersReturn {\n data: NewsletterSubscriberPage | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n remove: (id: string) => Promise<boolean>;\n}\n\nexport function useAdminNewsletterSubscribers(options: UseAdminNewsletterSubscribersOptions = {}): UseAdminNewsletterSubscribersReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<NewsletterSubscriberPage | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const { status, page = 0, size = 20 } = options;\n\n const fetchSubscribers = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const params = new URLSearchParams();\n params.append('page', String(page));\n params.append('size', String(size));\n if (status) params.append('status', status);\n const result = await client.get<NewsletterSubscriberPage>(`/api/blog/newsletter/subscribers?${params.toString()}`);\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client, status, page, size]);\n\n useEffect(() => {\n fetchSubscribers();\n }, [fetchSubscribers]);\n\n const remove = async (id: string): Promise<boolean> => {\n try {\n await client.delete(`/api/blog/newsletter/subscribers/${id}`);\n await fetchSubscribers();\n return true;\n } catch (err) {\n setError(err as ApiError);\n return false;\n }\n };\n\n return { data, isLoading, error, refetch: fetchSubscribers, remove };\n}\n\nexport interface UseAdminNewsletterStatsReturn {\n data: NewsletterStats | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\nexport function useAdminNewsletterStats(): UseAdminNewsletterStatsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<NewsletterStats | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchStats = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<NewsletterStats>('/api/blog/newsletter/stats');\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n useEffect(() => {\n fetchStats();\n }, [fetchStats]);\n\n return { data, isLoading, error, refetch: fetchStats };\n}\n\n// ==================== Settings Admin ====================\n\nexport interface UseAdminBlogSettingsReturn {\n data: BlogSettings | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n update: (settings: Partial<BlogSettings>) => Promise<BlogSettings | null>;\n}\n\nexport function useAdminBlogSettings(): UseAdminBlogSettingsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogSettings | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchSettings = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogSettings>('/api/blog/settings');\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n useEffect(() => {\n fetchSettings();\n }, [fetchSettings]);\n\n const update = async (settings: Partial<BlogSettings>): Promise<BlogSettings | null> => {\n try {\n const result = await client.put<BlogSettings>('/api/blog/settings', settings);\n setData(result);\n return result;\n } catch (err) {\n setError(err as ApiError);\n return null;\n }\n };\n\n return { data, isLoading, error, refetch: fetchSettings, update };\n}\n\n// ==================== Analytics Admin ====================\n\nexport interface UseAdminBlogAnalyticsReturn {\n data: BlogAnalyticsSummary | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\nexport function useAdminBlogAnalytics(): UseAdminBlogAnalyticsReturn {\n const { client } = useFoxPixelContext();\n const [data, setData] = useState<BlogAnalyticsSummary | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchAnalytics = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await client.get<BlogAnalyticsSummary>('/api/blog/analytics/summary');\n setData(result);\n } catch (err) {\n setError(err as ApiError);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n useEffect(() => {\n fetchAnalytics();\n }, [fetchAnalytics]);\n\n return { data, isLoading, error, refetch: fetchAnalytics };\n}\n","/**\n * Blog utilities - Schema.org JSON-LD for SEO\n */\n\nimport type { BlogPost } from './types';\n\nexport interface BlogPostSchemaLdOptions {\n /** Full URL of the site (e.g. https://example.com) */\n siteUrl: string;\n /** Organization name for publisher */\n publisherName?: string;\n /** Logo URL for publisher */\n publisherLogoUrl?: string;\n}\n\n/**\n * Build Schema.org BlogPosting JSON-LD for a blog post\n *\n * @example\n * ```tsx\n * const schemaLd = getBlogPostSchemaLd(post, { siteUrl: 'https://example.com', publisherName: 'My Site' });\n * <script type=\"application/ld+json\" dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaLd) }} />\n * ```\n */\nexport function getBlogPostSchemaLd(\n post: BlogPost,\n options: BlogPostSchemaLdOptions\n): Record<string, unknown> {\n const { siteUrl, publisherName, publisherLogoUrl } = options;\n const postUrl = `${siteUrl.replace(/\\/$/, '')}/blog/${post.slug}`;\n\n const schema: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': 'BlogPosting',\n headline: post.title,\n description: post.metaDescription || post.excerpt || undefined,\n image: post.coverImageUrl || undefined,\n datePublished: post.publishedAt || undefined,\n dateModified: post.updatedAt,\n mainEntityOfPage: {\n '@type': 'WebPage',\n '@id': postUrl,\n },\n };\n\n if (publisherName || publisherLogoUrl) {\n schema.publisher = {\n '@type': 'Organization',\n ...(publisherName && { name: publisherName }),\n ...(publisherLogoUrl && {\n logo: {\n '@type': 'ImageObject',\n url: publisherLogoUrl,\n },\n }),\n };\n }\n\n return schema;\n}\n"],"mappings":";AAKA,SAAgB,eAAe,YAAY,eAA0B;;;ACArE,OAAO,WAA8D;AAG9D,IAAM,qBAAN,MAAyB;AAAA,EAM9B,YAAY,QAAwB;AAClC,UAAM,SAAS,OAAO,UAAU,QAAQ,IAAI,gCAAgC;AAE5E,SAAK,SAAS,MAAM,OAAO;AAAA,MACzB,SAAS;AAAA,MACT,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,iBAAiB;AAAA;AAAA,IACnB,CAAC;AAED,SAAK,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC3C,SAAK,WAAW,OAAO;AAGvB,SAAK,OAAO,aAAa,QAAQ;AAAA,MAC/B,CAACA,YAA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D;;;ACxkBO,SAAS,oBACd,MACA,SACyB;AACzB,QAAM,EAAE,SAAS,eAAe,iBAAiB,IAAI;AACrD,QAAM,UAAU,GAAG,QAAQ,QAAQ,OAAO,EAAE,CAAC,SAAS,KAAK,IAAI;AAE/D,QAAM,SAAkC;AAAA,IACtC,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,UAAU,KAAK;AAAA,IACf,aAAa,KAAK,mBAAmB,KAAK,WAAW;AAAA,IACrD,OAAO,KAAK,iBAAiB;AAAA,IAC7B,eAAe,KAAK,eAAe;AAAA,IACnC,cAAc,KAAK;AAAA,IACnB,kBAAkB;AAAA,MAChB,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,iBAAiB,kBAAkB;AACrC,WAAO,YAAY;AAAA,MACjB,SAAS;AAAA,MACT,GAAI,iBAAiB,EAAE,MAAM,cAAc;AAAA,MAC3C,GAAI,oBAAoB;AAAA,QACtB,MAAM;AAAA,UACJ,SAAS;AAAA,UACT,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["config","createContext","useContext","jsx","createContext","useContext","useEffect","useState","jsx","useState","useEffect","useEffect","useState","Fragment","jsx","useState","useEffect","useEffect","useState","jsx","useState","useEffect","useState","useEffect","useState","useEffect","useState","useState","useState","useState","useState","useEffect","useState","useEffect","useState","useEffect","useCallback","useState","useCallback","useEffect"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxpixel/react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React SDK for FoxPixel API - Headless integration for custom sites and portals",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",