Skip to content

Commit

Permalink
fix: flow action handler params
Browse files Browse the repository at this point in the history
  • Loading branch information
christianmat committed Sep 26, 2024
1 parent 1819298 commit e8d1067
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-trainers-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@frigade/react": patch
---

Fixes an issue where visibilityCriteria is not respected with some flow actions
18 changes: 9 additions & 9 deletions packages/react/src/hooks/useStepHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export function useStepHandlers(step: FlowStep, { onPrimary, onSecondary }: Step
const { navigate } = useContext(FrigadeContext)

const stepActions = {
'flow.back': () => step.flow.back(),
'flow.complete': () => step.flow.complete(),
'flow.forward': () => step.flow.forward(),
'flow.back': (...args) => step.flow.back(...args),
'flow.complete': (...args) => step.flow.complete(...args),
'flow.forward': (...args) => step.flow.forward(...args),
'flow.restart': () => step.flow.restart(),
'flow.skip': () => step.flow.skip(),
'flow.start': () => step.flow.start(),
'step.complete': () => step.complete(),
'step.skip': () => step.skip(),
'flow.skip': (...args) => step.flow.skip(...args),
'flow.start': (...args) => step.flow.start(...args),
'step.complete': (...args) => step.complete(...args),
'step.skip': (...args) => step.skip(...args),
'step.reset': () => step.reset(),
'step.start': () => step.start(),
'step.start': (...args) => step.start(...args),
}

return {
Expand All @@ -62,7 +62,7 @@ export function useStepHandlers(step: FlowStep, { onPrimary, onSecondary }: Step
step.primaryButton.action === false ? false : stepActions[step.primaryButton.action]

if (typeof primaryAction === 'function') {
primaryAction()
await primaryAction(properties, optimistic)
} else if (primaryAction !== false) {
await step.complete(properties, optimistic)
}
Expand Down

0 comments on commit e8d1067

Please sign in to comment.