import type { CommonProps } from '@/proxy/common' import ConfigProvider from '@/components/ui/ConfigProvider' import { themeConfig } from '@/proxy/theme/theme.config' import { useStoreActions, useStoreState } from '@/store' import useDarkMode from '@/utils/hooks/useDarkmode' import useNotification from '@/utils/hooks/useNotification' import { useSetting } from '@/utils/hooks/useSetting' import useTabFocus from '@/utils/hooks/useTabFocus' import { ComponentProps, useEffect } from 'react' import { Helmet } from 'react-helmet' import { useNavigate, useLocation } from 'react-router-dom' import { getSetupStatus } from '@/services/setup.service' import { ROUTES_ENUM } from '@/routes/route.constant' import { useAppVersionNotice } from '@/views/version/useAppVersionNotice' let didInit = false const Theme = (props: CommonProps) => { const { getConfig } = useStoreActions((a) => a.abpConfig) const { setSetupMode } = useStoreActions((a) => a.base.common) const navigate = useNavigate() const location = useLocation() useEffect(() => { if (!didInit) { didInit = true // Direkt /setup'a gelindiyse — hemen setupMode=true yap (loading gate açılsın) if (location.pathname === ROUTES_ENUM.setup) { setSetupMode(true) return } // Veritabanı var mı kontrol et; yoksa setup sayfasına yönlendir getSetupStatus() .then((res) => { if (!res.data.dbExists) { setSetupMode(true) navigate(ROUTES_ENUM.setup, { replace: true }) } else { getConfig(false) } }) .catch(() => { getConfig(false) }) } }, []) function getThemeStyle() { const mode = theme.mode const style = setting('App.SiteManagement.Theme.Style') return style?.replace(mode === 'dark' ? 'light' : 'dark', mode) } const { setting } = useSetting() const theme = useStoreState((state) => state.theme) const locale = useStoreState((state) => state.abpConfig.config?.localization.currentCulture.cultureName) ?? 'en' useDarkMode() useTabFocus() useNotification() useAppVersionNotice() type ConfigProviderValue = NonNullable['value']> const currentTheme = { ...themeConfig, ...theme, ...{ locale }, } as ConfigProviderValue return ( <> {setting('App.SiteManagement.Theme.Style') && ( )} {props.children} ) } export default Theme