Fix RTK-Query empty fetch method + minor changes
Change-Id: I0411ff0f046d820eb6c6857762332e87a1ba1767
This commit is contained in:
parent
8d18290080
commit
31488b89a4
4 changed files with 8 additions and 8 deletions
|
@ -1,12 +1,12 @@
|
|||
import React, { FC, ReactElement, ReactNode } from 'react';
|
||||
|
||||
export type FetchLoaderProps = {
|
||||
active: boolean;
|
||||
children: ReactNode;
|
||||
isLoading: boolean;
|
||||
placeholder?: ReactElement;
|
||||
};
|
||||
|
||||
export const FetchLoader: FC<FetchLoaderProps> = ({ children, isLoading, placeholder }) => {
|
||||
export const FetchLoader: FC<FetchLoaderProps> = ({ children, active: isLoading, placeholder }) => {
|
||||
if (!isLoading) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ export const baseQuery =
|
|||
{
|
||||
body?: RequestBody;
|
||||
headers?: Record<string, string | number | boolean>;
|
||||
method: string;
|
||||
method?: string;
|
||||
params?: Record<string, string>;
|
||||
url: string;
|
||||
},
|
||||
Response
|
||||
> =>
|
||||
async ({ url, method, params, body, headers }, { getState }) => {
|
||||
async ({ url, method = 'GET', params, body, headers }, { getState }) => {
|
||||
if ((getState() as AuthRootState).treejs[AUTH_REDUCER_NAME] !== undefined) {
|
||||
const isAuthenticated = getAuthAttribute([getState() as AuthRootState, 'authenticated']);
|
||||
if (isAuthenticated) {
|
||||
|
|
|
@ -22,7 +22,7 @@ export default {
|
|||
|
||||
export const Input: Story = {
|
||||
args: {
|
||||
isLoading: true,
|
||||
active: true,
|
||||
children: 'children',
|
||||
placeholder: <FetchShapeInput />,
|
||||
},
|
||||
|
@ -30,7 +30,7 @@ export const Input: Story = {
|
|||
|
||||
export const Table: Story = {
|
||||
args: {
|
||||
isLoading: true,
|
||||
active: true,
|
||||
children: 'children',
|
||||
placeholder: <FetchShapeTable />,
|
||||
},
|
||||
|
@ -38,7 +38,7 @@ export const Table: Story = {
|
|||
|
||||
export const Block: Story = {
|
||||
args: {
|
||||
isLoading: true,
|
||||
active: true,
|
||||
children: 'children',
|
||||
placeholder: <FetchShapeBlock />,
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@ const FetchPage = (): React.ReactElement => {
|
|||
<Button status={StatusEnum.warning} label="Odeslat" onClick={() => handleFetch(1)} disabled={isFetching} />
|
||||
</GridCol>
|
||||
</Grid>
|
||||
<FetchLoader isLoading={isFetching} placeholder={<Placeholder />}>
|
||||
<FetchLoader active={isFetching} placeholder={<Placeholder />}>
|
||||
<pre>{JSON.stringify(data, undefined, 2)}</pre>
|
||||
</FetchLoader>
|
||||
</>
|
||||
|
|
Loading…
Add table
Reference in a new issue