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