Skip to content

Commit

Permalink
assigns users forms in todo section only if their signature is requir…
Browse files Browse the repository at this point in the history
…ed next, not if their signature is requierd at all (previous implementation)
  • Loading branch information
kaiyangzheng committed Dec 8, 2023
1 parent 7a1e85f commit 09649eb
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions apps/web/src/hooks/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,23 @@ export const useForm = () => {
const todoForms: FormInstanceEntity[] = assignedFIData.filter(
(formInstance: FormInstanceEntity) => {
const signatures: SignatureEntity[] = formInstance.signatures;
for (let i = 0; i < signatures.length; i++) {
if (signatures[i].signerPositionId === user.positionId) {
return signatures[i].signed === false;
}

// Filter out signatures that are already signed
signatures.filter((signature: SignatureEntity) => {
return signature.signed === false;
});

// Sort signatures by order
signatures.sort((a: SignatureEntity, b: SignatureEntity) => {
return a.order - b.order;
});

// Get next signature
const nextSignature: SignatureEntity = signatures[0];

// If next signature is current user, then this form is a todo
if (nextSignature.signerPositionId === user.positionId) {
return true;
}
},
);
Expand Down

0 comments on commit 09649eb

Please sign in to comment.