Skip to content

Commit 40ae9ea

Browse files
create form template - allow continuing if a field is specified (#399)
* allow continue if a field is specified * tsc workaround * also add same logic for form instance --------- Co-authored-by: Kaiyang Zheng <kaiyang.zheng@gmail.com>
1 parent 5df6050 commit 40ae9ea

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

apps/web/src/components/createFormInstance/SignatureDropdown.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ export const SignatureDropdown = ({
9696
}
9797
}, [assignedGroupData, field.id]);
9898

99+
// this is not ideal, we should just use on onClick handler fucntion
100+
// instead of useEffect
99101
useEffect(() => {
100102
switch (activeTab) {
101103
case 'Employee':
@@ -182,6 +184,9 @@ export const SignatureDropdown = ({
182184
onClick={() => {
183185
setActiveTab(tab);
184186
setSelectedOption(null);
187+
setAssignedGroupData((prev) =>
188+
prev.filter((group) => group.fieldGroupId !== field.id),
189+
);
185190
}}
186191
flex="1"
187192
borderRadius="0"

apps/web/src/pages/create-instance/assign-groups.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function AssignGroups() {
1212
formInstanceDescription,
1313
formTemplate,
1414
formInstanceUseId,
15+
assignedGroupData,
1516
} = useCreateFormInstance();
1617

1718
const [pdfFile, setPdfFile] = useState<File | null>(null);
@@ -45,7 +46,7 @@ function AssignGroups() {
4546
deleteFunction={() => {}}
4647
submitLink={'/create-instance/review'}
4748
backLink={'/create-instance/description'}
48-
disabled={false}
49+
disabled={formTemplate?.fieldGroups.length !== assignedGroupData.length}
4950
/>
5051
);
5152
}

apps/web/src/pages/create-template/input-fields.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ function InputFields() {
5454
deleteFunction={() => {}}
5555
submitLink={'/create-template/review'}
5656
backLink={'/create-template/description'}
57-
// TODO set disabled based on some state in the pdf editor component
58-
disabled={false}
57+
disabled={
58+
Object.values(formFields)
59+
.map((page) => Array.from(page.values()))
60+
.reduce((prev, curr) => prev + curr.length, 0) === 0
61+
}
5962
/>
6063
);
6164
}

0 commit comments

Comments
 (0)