Skip to content

Commit 188f594

Browse files
committed
Simplify story
1 parent 77272cb commit 188f594

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

packages/ra-core/src/auth/useLogin.stories.tsx

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import usePermissions, { UsePermissionsResult } from './usePermissions';
2+
import usePermissions from './usePermissions';
33
import { CoreAdminContext, TestMemoryRouter, useLogin, useLogout } from '..';
44

55
export default {
@@ -36,34 +36,26 @@ const LogoutButton = () => {
3636
return <button onClick={logout}>Logout</button>;
3737
};
3838

39-
const UsePermissions = ({
40-
children,
41-
}: {
42-
children: (state: UsePermissionsResult<any, Error>) => React.ReactNode;
43-
}) => {
39+
const UsePermissions = () => {
4440
const permissionQueryParams = {
4541
retry: false,
4642
};
47-
const res = usePermissions({}, permissionQueryParams);
48-
return children(res);
43+
const state = usePermissions({}, permissionQueryParams);
44+
return (
45+
<div>
46+
{state.isPending ? <span>LOADING</span> : null}
47+
{state.permissions ? (
48+
<span>PERMISSIONS: {state.permissions}</span>
49+
) : null}
50+
{state.error ? <span>ERROR</span> : null}
51+
</div>
52+
);
4953
};
5054

51-
const inspectPermissionsState = (state: UsePermissionsResult<any, Error>) => (
52-
<div>
53-
{state.isPending ? <span>LOADING</span> : null}
54-
{state.permissions ? (
55-
<span>PERMISSIONS: {state.permissions}</span>
56-
) : null}
57-
{state.error ? <span>ERROR</span> : null}
58-
</div>
59-
);
60-
6155
export const PermissionsState = () => (
6256
<TestMemoryRouter>
6357
<CoreAdminContext authProvider={getAuthProviderWithLoginAndLogout()}>
64-
<UsePermissions>
65-
{state => inspectPermissionsState(state)}
66-
</UsePermissions>
58+
<UsePermissions />
6759
<LoginButton />
6860
<LogoutButton />
6961
</CoreAdminContext>

0 commit comments

Comments
 (0)