Skip to content

Commit

Permalink
feat(): set signing status
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-grzelak committed Jul 28, 2023
1 parent 5fe214e commit 1b62e9d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,19 @@ export const EmbeddedSigningAction: FC<EmbeddedSigningActionActionProps> = ({
*/
const decodedSignUrl = he.decode(signUrl)

const finishSigning = useCallback(() => {
onSubmit(activity_id)
}, [activity_id, onSubmit])
const finishSigning = useCallback(
({ signed }: { signed: boolean }) => {
onSubmit(activity_id, { signed })
},
[activity_id, onSubmit]
)

useEffect(() => {
if (isFinished) {
setIsIframeLoaded(false)

if (event === DocuSignEvent.SIGNING_COMPLETE) {
finishSigning()
finishSigning({ signed: true })
}
}
}, [event, finishSigning, isFinished])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LoadingPage } from '../../../../LoadingPage'

interface FinishedMessage {
event: DocuSignEvent
finishSigning: () => void
finishSigning: (args: { signed: boolean }) => void
}

export const FinishedMessage: FC<FinishedMessage> = ({
Expand All @@ -15,6 +15,10 @@ export const FinishedMessage: FC<FinishedMessage> = ({
}) => {
const { t } = useTranslation()

const finishAndFailSigning = () => {
finishSigning({ signed: false })
}

switch (event) {
case DocuSignEvent.SIGNING_COMPLETE:
return (
Expand All @@ -25,7 +29,9 @@ export const FinishedMessage: FC<FinishedMessage> = ({
<>
<span>
<h2>{t('activities.docu_sign.expired_sign_document')}</h2>
<Button onClick={finishSigning}>{t('activities.cta_done')}</Button>
<Button onClick={finishAndFailSigning}>
{t('activities.cta_done')}
</Button>
</span>
</>
)
Expand All @@ -34,7 +40,9 @@ export const FinishedMessage: FC<FinishedMessage> = ({
<>
<span>
<h2>{t('activities.docu_sign.failed_sign_document')}</h2>
<Button onClick={finishSigning}>{t('activities.cta_done')}</Button>
<Button onClick={finishAndFailSigning}>
{t('activities.cta_done')}
</Button>
</span>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const useCompleteEmbeddedSigningAction = () => {
const { isSubmitting, onSubmit: _onSubmit } = useCompleteExtensionActivity()

const onSubmit = useCallback(
async (activityId: string) => {
const dataPoints: DataPoints = []
async (activityId: string, { signed }: { signed: boolean }) => {
const dataPoints: DataPoints = [{ key: 'signed', value: String(signed) }]

return _onSubmit(activityId, dataPoints)
},
Expand Down

0 comments on commit 1b62e9d

Please sign in to comment.