Skip to content

Commit b334435

Browse files
author
Ruben van Leeuwen
committed
1719: Adds configurable loading component
1 parent df1cbcf commit b334435

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

frontend/packages/pydantic-forms/src/components/render/RenderForm.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ const RenderForm = (contextProps: PydanticFormContextProps) => {
2626
title,
2727
headerComponent,
2828
skipSuccessNotice,
29+
loadingComponent,
2930
} = contextProps;
3031

31-
if (isLoading && !isSending) {
32-
return <div>Formulier aan het ophalen... A</div>;
33-
}
32+
const LoadingComponent = loadingComponent ?? (
33+
<div>Formulier aan het ophalen...</div>
34+
);
3435

35-
if (!pydanticFormSchema) {
36-
return <div>Formulier aan het ophalen... B</div>;
36+
if (isLoading && !isSending) {
37+
return LoadingComponent;
3738
}
3839

39-
if (isSending) {
40-
return <div>Formulier aan het verzenden...</div>;
40+
if (!pydanticFormSchema || isSending) {
41+
return LoadingComponent;
4142
}
4243

4344
if (isFullFilled) {

frontend/packages/pydantic-forms/src/core/PydanticFormContextProvider.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function PydanticFormContextProvider({
6464
sendLabel,
6565
headerComponent,
6666
footerComponent,
67+
loadingComponent,
6768
successNotice,
6869
onSuccess,
6970
onCancel,
@@ -320,6 +321,7 @@ function PydanticFormContextProvider({
320321
pydanticFormSchema,
321322
headerComponent,
322323
footerComponent,
324+
loadingComponent,
323325
onCancel,
324326
title,
325327
sendLabel,

frontend/packages/pydantic-forms/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface PydanticFormInitialContextProps {
2828
children: (props: PydanticFormContextProps) => React.ReactNode;
2929
headerComponent?: React.ReactNode;
3030
footerComponent?: React.ReactNode;
31+
loadingComponent?: React.ReactNode;
3132
hasCardWrapper?: boolean;
3233

3334
config: PydanticFormsContextConfig;
@@ -65,6 +66,7 @@ export interface PydanticFormContextProps {
6566
successNotice?: React.ReactNode;
6667
headerComponent?: React.ReactNode;
6768
footerComponent?: React.ReactNode;
69+
loadingComponent?: React.ReactNode;
6870
allowUntouchedSubmit?: boolean;
6971
skipSuccessNotice?: boolean;
7072
footerCtaPrimaryVariant?: string;

0 commit comments

Comments
 (0)