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
|
||||
navbar={
|
||||
<Navbar
|
||||
padding='md'
|
||||
p='md'
|
||||
hiddenBreakpoint='sm'
|
||||
hidden={!opened}
|
||||
width={{ sm: 200, lg: 230 }}
|
||||
|
@ -247,7 +247,7 @@ export default function Layout({ children, user }) {
|
|||
</Navbar>
|
||||
}
|
||||
header={
|
||||
<Header height={70} padding='md'>
|
||||
<Header height={70} p='md'>
|
||||
<div style={{ display: 'flex', alignItems: 'center', height: '100%' }}>
|
||||
<MediaQuery largerThan='sm' styles={{ display: 'none' }}>
|
||||
<Burger
|
||||
|
@ -325,7 +325,7 @@ export default function Layout({ children, user }) {
|
|||
</Header>
|
||||
}
|
||||
>
|
||||
<Paper withBorder padding='md' shadow='xs'>{children}</Paper>
|
||||
<Paper withBorder p='md' shadow='xs'>{children}</Paper>
|
||||
</AppShell>
|
||||
);
|
||||
}
|
|
@ -1,54 +1,13 @@
|
|||
// https://github.com/mikecao/umami/blob/master/redux/store.js
|
||||
import { useMemo } from 'react';
|
||||
import { Action, CombinedState, configureStore, EnhancedStore } from '@reduxjs/toolkit';
|
||||
import thunk, { ThunkAction } from 'redux-thunk';
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import rootReducer from './reducers';
|
||||
import { User } from './reducers/user';
|
||||
import { useDispatch, TypedUseSelectorHook, useSelector } from 'react-redux';
|
||||
|
||||
let store: EnhancedStore<CombinedState<{
|
||||
user: User;
|
||||
}>>;
|
||||
|
||||
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 const store = configureStore({
|
||||
reducer: rootReducer,
|
||||
});
|
||||
|
||||
export type AppState = ReturnType<typeof store.getState>
|
||||
|
||||
export type AppDispatch = typeof store.dispatch
|
||||
|
||||
export type AppThunk<ReturnType = void> = ThunkAction<
|
||||
ReturnType,
|
||||
AppState,
|
||||
unknown,
|
||||
Action<User>
|
||||
>
|
||||
|
||||
export const useStoreDispatch = () => useDispatch<AppDispatch>();
|
||||
export const useStoreSelector: TypedUseSelectorHook<AppState> = useSelector;
|
|
@ -71,7 +71,7 @@ export default function EmbeddedImage({ image, user, pass }) {
|
|||
onClose={() => setOpened(false)}
|
||||
title='Password Protected'
|
||||
centered={true}
|
||||
hideCloseButton={true}
|
||||
withCloseButton={true}
|
||||
closeOnEscape={false}
|
||||
closeOnClickOutside={false}
|
||||
>
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import Head from 'next/head';
|
||||
import { useStore } from 'lib/redux/store';
|
||||
import { store } from 'lib/redux/store';
|
||||
import ZiplineTheming from 'components/Theming';
|
||||
|
||||
export default function MyApp({ Component, pageProps }) {
|
||||
const store = useStore();
|
||||
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Head>
|
||||
|
|
Loading…
Add table
Reference in a new issue