Skip to content

Commit

Permalink
fix: ensure all fields are available in final completion event
Browse files Browse the repository at this point in the history
  • Loading branch information
christianmat committed Aug 23, 2024
1 parent 0f5c086 commit b6438e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/bright-mice-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@frigade/js": patch
"@frigade/react": patch
---

Adds the entire form context to flow completion event
9 changes: 8 additions & 1 deletion packages/js-api/src/core/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class Flow extends Fetchable {
thisStep.id
)
if (isLastStep) {
await this.sendFlowStateToAPI(COMPLETED_FLOW)
await this.sendFlowStateToAPI(COMPLETED_FLOW, properties)
}
}

Expand Down Expand Up @@ -487,6 +487,13 @@ export class Flow extends Fetchable {
.indexOf(currentStep)
}

/**
* Get the progress of the flow as a number between 0 and 1. Useful when rendering a progress bar.
*/
public getProgress(): number {
return (this.getNumberOfCompletedSteps() || 0) / (this.getNumberOfAvailableSteps() || 1)
}

/**
* @ignore
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Form/FormStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function FormStep({
const disabled = step.$state.blocked || !formContext.formState.isValid ? true : false

useEffect(() => {
formContext.reset()
formContext.clearErrors()
}, [step])

return (
Expand Down

0 comments on commit b6438e4

Please sign in to comment.