fix: fix build (#149)
This commit is contained in:
parent
bfa6c70bf3
commit
7a91a60af9
4 changed files with 9 additions and 52 deletions
|
@ -181,7 +181,7 @@ export default function Layout({ children, user }) {
|
||||||
fixed
|
fixed
|
||||||
navbar={
|
navbar={
|
||||||
<Navbar
|
<Navbar
|
||||||
padding='md'
|
p='md'
|
||||||
hiddenBreakpoint='sm'
|
hiddenBreakpoint='sm'
|
||||||
hidden={!opened}
|
hidden={!opened}
|
||||||
width={{ sm: 200, lg: 230 }}
|
width={{ sm: 200, lg: 230 }}
|
||||||
|
@ -247,7 +247,7 @@ export default function Layout({ children, user }) {
|
||||||
</Navbar>
|
</Navbar>
|
||||||
}
|
}
|
||||||
header={
|
header={
|
||||||
<Header height={70} padding='md'>
|
<Header height={70} p='md'>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', height: '100%' }}>
|
<div style={{ display: 'flex', alignItems: 'center', height: '100%' }}>
|
||||||
<MediaQuery largerThan='sm' styles={{ display: 'none' }}>
|
<MediaQuery largerThan='sm' styles={{ display: 'none' }}>
|
||||||
<Burger
|
<Burger
|
||||||
|
@ -325,7 +325,7 @@ export default function Layout({ children, user }) {
|
||||||
</Header>
|
</Header>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Paper withBorder padding='md' shadow='xs'>{children}</Paper>
|
<Paper withBorder p='md' shadow='xs'>{children}</Paper>
|
||||||
</AppShell>
|
</AppShell>
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -1,54 +1,13 @@
|
||||||
// https://github.com/mikecao/umami/blob/master/redux/store.js
|
import { configureStore } from '@reduxjs/toolkit';
|
||||||
import { useMemo } from 'react';
|
|
||||||
import { Action, CombinedState, configureStore, EnhancedStore } from '@reduxjs/toolkit';
|
|
||||||
import thunk, { ThunkAction } from 'redux-thunk';
|
|
||||||
import rootReducer from './reducers';
|
import rootReducer from './reducers';
|
||||||
import { User } from './reducers/user';
|
|
||||||
import { useDispatch, TypedUseSelectorHook, useSelector } from 'react-redux';
|
import { useDispatch, TypedUseSelectorHook, useSelector } from 'react-redux';
|
||||||
|
|
||||||
let store: EnhancedStore<CombinedState<{
|
export const store = configureStore({
|
||||||
user: User;
|
reducer: rootReducer,
|
||||||
}>>;
|
});
|
||||||
|
|
||||||
export function getStore(preloadedState) {
|
|
||||||
return configureStore({
|
|
||||||
reducer: rootReducer,
|
|
||||||
middleware: [thunk],
|
|
||||||
preloadedState,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const initializeStore = preloadedState => {
|
|
||||||
let _store = store ?? getStore(preloadedState);
|
|
||||||
|
|
||||||
if (preloadedState && store) {
|
|
||||||
_store = getStore({
|
|
||||||
...store.getState(),
|
|
||||||
...preloadedState,
|
|
||||||
});
|
|
||||||
store = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof window === 'undefined') return _store;
|
|
||||||
if (!store) store = _store;
|
|
||||||
|
|
||||||
return _store;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function useStore(initialState?: User) {
|
|
||||||
return useMemo(() => initializeStore(initialState), [initialState]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AppState = ReturnType<typeof store.getState>
|
export type AppState = ReturnType<typeof store.getState>
|
||||||
|
|
||||||
export type AppDispatch = typeof store.dispatch
|
export type AppDispatch = typeof store.dispatch
|
||||||
|
|
||||||
export type AppThunk<ReturnType = void> = ThunkAction<
|
|
||||||
ReturnType,
|
|
||||||
AppState,
|
|
||||||
unknown,
|
|
||||||
Action<User>
|
|
||||||
>
|
|
||||||
|
|
||||||
export const useStoreDispatch = () => useDispatch<AppDispatch>();
|
export const useStoreDispatch = () => useDispatch<AppDispatch>();
|
||||||
export const useStoreSelector: TypedUseSelectorHook<AppState> = useSelector;
|
export const useStoreSelector: TypedUseSelectorHook<AppState> = useSelector;
|
|
@ -71,7 +71,7 @@ export default function EmbeddedImage({ image, user, pass }) {
|
||||||
onClose={() => setOpened(false)}
|
onClose={() => setOpened(false)}
|
||||||
title='Password Protected'
|
title='Password Protected'
|
||||||
centered={true}
|
centered={true}
|
||||||
hideCloseButton={true}
|
withCloseButton={true}
|
||||||
closeOnEscape={false}
|
closeOnEscape={false}
|
||||||
closeOnClickOutside={false}
|
closeOnClickOutside={false}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import { useStore } from 'lib/redux/store';
|
import { store } from 'lib/redux/store';
|
||||||
import ZiplineTheming from 'components/Theming';
|
import ZiplineTheming from 'components/Theming';
|
||||||
|
|
||||||
export default function MyApp({ Component, pageProps }) {
|
export default function MyApp({ Component, pageProps }) {
|
||||||
const store = useStore();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Head>
|
<Head>
|
||||||
|
|
Loading…
Add table
Reference in a new issue