FIX;Auth reducer init state as default parameter
This commit is contained in:
parent
884c1a9350
commit
30952c7d94
9 changed files with 21 additions and 16 deletions
|
@ -93,8 +93,8 @@ const App = (): React.ReactElement => {
|
||||||
|
|
||||||
const userMenuItems: IMenuItem[] = useMemo(
|
const userMenuItems: IMenuItem[] = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{ label: getMessage(MenuLocalization.signOut), href: '/signin' },
|
{ label: getMessage(MenuLocalization.signIn), href: '/signin' },
|
||||||
{ label: getMessage(MenuLocalization.signOut), href: '/signin' },
|
{ label: getMessage(MenuLocalization.signOut), href: '/signout' },
|
||||||
],
|
],
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
|
@ -168,10 +168,10 @@ exports[`App should match snapshot 1`] = `
|
||||||
"user": Array [
|
"user": Array [
|
||||||
Object {
|
Object {
|
||||||
"href": "/signin",
|
"href": "/signin",
|
||||||
"label": "Sign out",
|
"label": "Sign in",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"href": "/signin",
|
"href": "/signout",
|
||||||
"label": "Sign out",
|
"label": "Sign out",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -19,6 +19,7 @@ export class InternalMenuLocalization {
|
||||||
@withNS public calendar: string;
|
@withNS public calendar: string;
|
||||||
@withNS public checkbox: string;
|
@withNS public checkbox: string;
|
||||||
@withNS public home: string;
|
@withNS public home: string;
|
||||||
|
@withNS public signIn: string;
|
||||||
@withNS public signOut: string;
|
@withNS public signOut: string;
|
||||||
@withNS public localization: string;
|
@withNS public localization: string;
|
||||||
@withNS public localizationStart: string;
|
@withNS public localizationStart: string;
|
||||||
|
|
|
@ -17,6 +17,7 @@ export const menu: InternalMenuLocalization = {
|
||||||
table: 'Tabulka',
|
table: 'Tabulka',
|
||||||
textField: 'Textové pole',
|
textField: 'Textové pole',
|
||||||
toaster: 'Toaster',
|
toaster: 'Toaster',
|
||||||
|
signIn: 'Přihlásit se',
|
||||||
signOut: 'Odhlásit se',
|
signOut: 'Odhlásit se',
|
||||||
localization: 'Lokalizace',
|
localization: 'Lokalizace',
|
||||||
localizationStart: 'Jak začít',
|
localizationStart: 'Jak začít',
|
||||||
|
|
|
@ -17,6 +17,7 @@ export const menu: InternalMenuLocalization = {
|
||||||
table: 'Table',
|
table: 'Table',
|
||||||
textField: 'Text field',
|
textField: 'Text field',
|
||||||
toaster: 'Toaster',
|
toaster: 'Toaster',
|
||||||
|
signIn: 'Sign in',
|
||||||
signOut: 'Sign out',
|
signOut: 'Sign out',
|
||||||
localization: 'Localization',
|
localization: 'Localization',
|
||||||
localizationStart: 'Get started',
|
localizationStart: 'Get started',
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { useDispatch } from 'react-redux';
|
||||||
|
|
||||||
import { setAuthenticated } from '@treejs/auth/actions';
|
import { setAuthenticated } from '@treejs/auth/actions';
|
||||||
import Button from '@treejs/components/Button';
|
import Button from '@treejs/components/Button';
|
||||||
|
import { Grid, GridCol } from '@treejs/components/Grid';
|
||||||
import { STATUS } from '@treejs/types/common';
|
import { STATUS } from '@treejs/types/common';
|
||||||
|
|
||||||
import history from 'documentation/utils/history';
|
import history from 'documentation/utils/history';
|
||||||
|
@ -28,13 +29,11 @@ export const SignIn: React.FC = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Grid cols={4}>
|
||||||
|
<GridCol>
|
||||||
<Button label="Sing in" status={STATUS.info} onClick={authenticate} />
|
<Button label="Sing in" status={STATUS.info} onClick={authenticate} />
|
||||||
|
</GridCol>
|
||||||
<a href="#" onClick={handleSignOut}>
|
</Grid>
|
||||||
Show sign out page
|
|
||||||
</a>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { useDispatch } from 'react-redux';
|
||||||
import { setAuthenticated } from '@treejs/auth/actions';
|
import { setAuthenticated } from '@treejs/auth/actions';
|
||||||
import authRequired, { IAuthHOCInjectProps } from '@treejs/auth/hoc/authRequired';
|
import authRequired, { IAuthHOCInjectProps } from '@treejs/auth/hoc/authRequired';
|
||||||
import Button from '@treejs/components/Button';
|
import Button from '@treejs/components/Button';
|
||||||
|
import { Grid, GridCol } from '@treejs/components/Grid';
|
||||||
import { STATUS } from '@treejs/types/common';
|
import { STATUS } from '@treejs/types/common';
|
||||||
|
|
||||||
import history from 'documentation/utils/history';
|
import history from 'documentation/utils/history';
|
||||||
|
@ -33,9 +34,11 @@ export const SignOut: React.FC<IProps> = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Grid cols={4}>
|
||||||
|
<GridCol>
|
||||||
<Button label="Sign out" status={STATUS.warning} onClick={authenticate} />
|
<Button label="Sign out" status={STATUS.warning} onClick={authenticate} />
|
||||||
</>
|
</GridCol>
|
||||||
|
</Grid>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,7 @@ const initialState: AuthReducer<any> = {
|
||||||
|
|
||||||
type Payload = SetAuthenticatedPayload<any>;
|
type Payload = SetAuthenticatedPayload<any>;
|
||||||
|
|
||||||
const reducer = (state: AuthReducer<any>, action: Action<Payload, ACTIONS>): AuthReducer<any> => {
|
const reducer = (state = initialState, action: Action<Payload, ACTIONS>): AuthReducer<any> => {
|
||||||
state = initialState;
|
|
||||||
if (action.type === ACTIONS.SET_AUTHENTICATE) {
|
if (action.type === ACTIONS.SET_AUTHENTICATE) {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
|
@ -86,6 +86,7 @@ const field = (theme) => ({
|
||||||
},
|
},
|
||||||
'.logo': {
|
'.logo': {
|
||||||
margin: '0.25rem',
|
margin: '0.25rem',
|
||||||
|
marginLeft: '1rem',
|
||||||
fontSize: '1rem',
|
fontSize: '1rem',
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue