File tree Expand file tree Collapse file tree 5 files changed +20
-3
lines changed
frontend/packages/pydantic-forms/src Expand file tree Collapse file tree 5 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,9 @@ const Footer = () => {
2020 sendLabel,
2121 footerComponent,
2222 allowUntouchedSubmit,
23+ hasNext,
24+ formInputData,
2325 } = usePydanticFormContext ( ) ;
24-
2526 const t = useTranslations ( 'footer' ) ;
2627
2728 const PreviousButton = ( ) => (
@@ -75,7 +76,7 @@ const Footer = () => {
7576 ! rhf . formState . isSubmitting )
7677 }
7778 >
78- { sendLabel ?? t ( 'send' ) }
79+ { sendLabel ?? hasNext ? t ( 'send' ) : t ( 'submit ') }
7980 </ button >
8081 ) ;
8182
@@ -88,8 +89,10 @@ const Footer = () => {
8889 ! rhf . formState . isDirty && (
8990 < div > Het formulier is nog niet aangepast</ div >
9091 ) }
92+ { formInputData && formInputData . length > 0 && (
93+ < PreviousButton />
94+ ) }
9195
92- < PreviousButton />
9396 < ResetButton />
9497
9598 { ! ! onCancel && < CancelButton /> }
Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ function PydanticFormContextProvider({
151151 // we cache the form scheme so when there is an error, we still have the form
152152 // the form is not in the error response
153153 const [ rawSchema , setRawSchema ] = useState < PydanticFormSchemaRawJson > ( ) ;
154+ const [ hasNext , setHasNext ] = useState < boolean > ( false ) ;
154155
155156 // extract the JSON schema to a more usable custom schema
156157
@@ -235,6 +236,9 @@ function PydanticFormContextProvider({
235236 // when we receive a form from the JSON, we fully reset the scheme
236237 if ( apiResponse ?. form ) {
237238 setRawSchema ( apiResponse . form ) ;
239+ if ( apiResponse . meta ) {
240+ setHasNext ( ! ! apiResponse . meta . hasNext ) ;
241+ }
238242 setErrorDetails ( undefined ) ;
239243 }
240244
@@ -362,6 +366,7 @@ function PydanticFormContextProvider({
362366 setFormInputData ( [ ] ) ;
363367 setIsFullFilled ( false ) ;
364368 setRawSchema ( undefined ) ;
369+ setHasNext ( false ) ;
365370 } , [ ] ) ;
366371
367372 const PydanticFormContextState = {
@@ -393,6 +398,8 @@ function PydanticFormContextProvider({
393398 formKey,
394399 formIdKey,
395400 clearForm,
401+ formInputData,
402+ hasNext,
396403 } ;
397404
398405 return (
Original file line number Diff line number Diff line change 22 "footer" : {
33 "cancel" : " Cancel" ,
44 "send" : " Send" ,
5+ "submit" : " Submit" ,
56 "reset" : " Reset" ,
67 "previous" : " Previous" ,
78 "next" : " Next" ,
Original file line number Diff line number Diff line change 22 "footer" : {
33 "cancel" : " Annuleren" ,
44 "send" : " Verzenden" ,
5+ "submit" : " Indienen" ,
56 "reset" : " Resetten" ,
67 "notModifiedYet" : " Het formulier is nog niet aangepast" ,
78 "notFilledYet" : " Het formulier is nog niet ingevuld" ,
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ export interface PydanticFormContextProps {
7878 formKey : string ;
7979 formIdKey ?: string ;
8080 clearForm : ( ) => void ;
81+ hasNext : boolean ;
82+ formInputData : object [ ] ;
8183}
8284
8385export enum PydanticFormState {
@@ -384,6 +386,9 @@ export interface PydanticFormApiResponse {
384386 form : PydanticFormSchemaRawJson ;
385387 success ?: boolean ;
386388 validation_errors : PydanticFormApiValidationError [ ] ;
389+ meta ?: {
390+ hasNext ?: boolean ;
391+ } ;
387392}
388393
389394export interface PydanticFormBaseSchema {
You can’t perform that action at this time.
0 commit comments