import { CustomRoutes, localStorageStore, Resource, type AuthProvider, type DataProvider, } from "ra-core"; import { useEffect } from "react"; import { Route } from "react-router"; import { AdminContext, AdminUI } from "@/components/ds/admin/admin"; import { ForgotPasswordPage } from "@/components/supabase/forgot-password-page"; import { SetPasswordPage } from "@/components/supabase/set-password-page"; import { ChangePasswordPage } from "@/components/supabase/change-password-page"; import { OtpLoginPage } from "@/components/supabase/otp-login-page"; import companies from "../companies"; import contacts from "../contacts"; import { Dashboard } from "../dashboard/Dashboard"; import deals from "../deals"; import invoices from "../invoices"; import { Layout } from "../layout/Layout"; import { SignupPage } from "../login/SignupPage"; import { authProvider as defaultAuthProvider, dataProvider as defaultDataProvider, } from "../providers/supabase"; import sales from "../sales"; import { DatabasePage } from "../settings/DatabasePage"; import { SettingsPage } from "../settings/SettingsPage"; import { IntegrationsPage } from "../integrations/IntegrationsPage"; import tasks from "../tasks"; import type { ConfigurationContextValue } from "./ConfigurationContext"; import { ConfigurationProvider } from "./ConfigurationContext"; import { defaultCompanySectors, defaultContactGender, defaultDarkModeLogo, defaultDealCategories, defaultDealPipelineStatuses, defaultDealStages, defaultLightModeLogo, defaultNoteStatuses, defaultTaskPriorities, defaultTaskStatuses, defaultTaskTypes, defaultTitle, } from "./defaultConfiguration"; import { i18nProvider } from "./i18nProvider"; import { StartPage } from "../login/StartPage.tsx"; import { DatabaseHealthCheck } from "./DatabaseHealthCheck"; import { SDKProvider } from "./SDKProvider"; import { AIPage } from "../ai/AIPage"; import { Sparkles } from "lucide-react"; import { AISettingsProvider } from "./AISettingsProvider"; export type CRMProps = { dataProvider?: DataProvider; authProvider?: AuthProvider; disableTelemetry?: boolean; } & Partial; /** * CRM Component * * This component sets up and renders the main CRM application using `ra-core`. It provides * default configurations and themes but allows for customization through props. The component * wraps the application with a `ConfigurationProvider` to provide configuration values via context. * * @param {Array} contactGender - The gender options for contacts used in the application. * @param {string[]} companySectors - The list of company sectors used in the application. * @param {RaThemeOptions} darkTheme - The theme to use when the application is in dark mode. * @param {string[]} dealCategories - The categories of deals used in the application. * @param {string[]} dealPipelineStatuses - The statuses of deals in the pipeline used in the application. * @param {DealStage[]} dealStages - The stages of deals used in the application. * @param {RaThemeOptions} lightTheme - The theme to use when the application is in light mode. * @param {string} logo - The logo used in the CRM application. * @param {NoteStatus[]} noteStatuses - The statuses of notes used in the application. * @param {string[]} taskTypes - The types of tasks used in the application. * @param {Object[]} taskPriorities - The priorities of tasks used in the application. * @param {Object[]} taskStatuses - The statuses of tasks used in the application. * @param {string} title - The title of the CRM application. * * @returns {JSX.Element} The rendered CRM application. * * @example * // Basic usage of the CRM component * import { CRM } from '@/components/atomic-crm/dashboard/CRM'; * * const App = () => ( * * ); * * export default App; */ export const CRM = ({ contactGender = defaultContactGender, companySectors = defaultCompanySectors, companyLifecycleStages, companyTypes, companyQualificationStatuses, companyRevenueRanges, dealCategories = defaultDealCategories, dealPipelineStatuses = defaultDealPipelineStatuses, dealStages = defaultDealStages, darkModeLogo = defaultDarkModeLogo, lightModeLogo = defaultLightModeLogo, noteStatuses = defaultNoteStatuses, taskTypes = defaultTaskTypes, taskPriorities = defaultTaskPriorities, taskStatuses = defaultTaskStatuses, title = defaultTitle, externalHeartbeatStatuses, internalHeartbeatStatuses, dataProvider = defaultDataProvider, authProvider = defaultAuthProvider, disableTelemetry, ...rest }: CRMProps) => { useEffect(() => { if ( disableTelemetry || process.env.NODE_ENV !== "production" || typeof window === "undefined" || typeof window.location === "undefined" || typeof Image === "undefined" ) { return; } const img = new Image(); img.src = `https://atomic-crm-telemetry.marmelab.com/atomic-crm-telemetry?domain=${window.location.hostname}`; }, [disableTelemetry]); const crmContent = ( } /> } /> } /> } /> } /> } /> } /> } /> } /> ); return {crmContent}; };