mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 08:25:47 +01:00
✨ Add tRPC
This commit is contained in:
@@ -33,15 +33,17 @@ import { theme } from '../tools/server/theme/theme';
|
||||
|
||||
import { useEditModeInformationStore } from '../hooks/useEditModeInformation';
|
||||
import '../styles/global.scss';
|
||||
import nextI18nextConfig from '../../next-i18next.config';
|
||||
import { api } from '~/utils/api';
|
||||
|
||||
function App(
|
||||
this: any,
|
||||
props: AppProps & {
|
||||
props: AppProps<{
|
||||
colorScheme: ColorScheme;
|
||||
packageAttributes: ServerSidePackageAttributesType;
|
||||
editModeEnabled: boolean;
|
||||
defaultColorScheme: ColorScheme;
|
||||
}
|
||||
}>
|
||||
) {
|
||||
const { Component, pageProps } = props;
|
||||
const [primaryColor, setPrimaryColor] = useState<MantineTheme['primaryColor']>('red');
|
||||
@@ -58,7 +60,7 @@ function App(
|
||||
|
||||
// hook will return either 'dark' or 'light' on client
|
||||
// and always 'light' during ssr as window.matchMedia is not available
|
||||
const preferredColorScheme = useColorScheme(props.defaultColorScheme);
|
||||
const preferredColorScheme = useColorScheme(props.pageProps.defaultColorScheme);
|
||||
const [colorScheme, setColorScheme] = useLocalStorage<ColorScheme>({
|
||||
key: 'mantine-color-scheme',
|
||||
defaultValue: preferredColorScheme,
|
||||
@@ -69,9 +71,9 @@ function App(
|
||||
const { setDisabled } = useEditModeInformationStore();
|
||||
|
||||
useEffect(() => {
|
||||
setInitialPackageAttributes(props.packageAttributes);
|
||||
setInitialPackageAttributes(props.pageProps.packageAttributes);
|
||||
|
||||
if (!props.editModeEnabled) {
|
||||
if (!props.pageProps.editModeEnabled) {
|
||||
setDisabled();
|
||||
}
|
||||
}, []);
|
||||
@@ -161,11 +163,13 @@ App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => {
|
||||
const colorScheme: ColorScheme = (process.env.DEFAULT_COLOR_SCHEME as ColorScheme) ?? 'light';
|
||||
|
||||
return {
|
||||
colorScheme: getCookie('color-scheme', ctx) || 'light',
|
||||
packageAttributes: getServiceSidePackageAttributes(),
|
||||
editModeEnabled: !disableEditMode,
|
||||
defaultColorScheme: colorScheme,
|
||||
pageProps: {
|
||||
colorScheme: getCookie('color-scheme', ctx) || 'light',
|
||||
packageAttributes: getServiceSidePackageAttributes(),
|
||||
editModeEnabled: !disableEditMode,
|
||||
defaultColorScheme: colorScheme,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default appWithTranslation(App);
|
||||
export default appWithTranslation<any>(api.withTRPC(App), nextI18nextConfig as any);
|
||||
|
||||
Reference in New Issue
Block a user