-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export of forms or submissions to a json file (#3896)
* Error creating events by calendar if End Date before Start Date or End time is before Start time * fix:Status service view includes extraneous top margin above heading * fix: add and edit notification type cancel state * fix:Save button in queue editor disables incorrectly on role changes * feat:form UI schema code completion hints based on the data schema * fix: scroll in form editor and help content. * fix:icon accessibilty issue and web-component upgrade issue * fix: Form -- All uppercase letter in Input label in schema, but in preview show input label in Pascal Case * fix: mobile view bottom up lay out * feat: export of forms or submissions to a json file --------- Co-authored-by: Shuang chen <[email protected]> Co-authored-by: Shuang chen <[email protected]> Co-authored-by: athena-chen-chen <[email protected]>
- Loading branch information
1 parent
f29fcc6
commit 3aa240d
Showing
10 changed files
with
152 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
apps/tenant-management-webapp/src/app/pages/admin/services/form/export/formExport.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { RootState } from '@store/index'; | ||
import { GoAButton, GoADropdown, GoADropdownItem, GoAFormItem } from '@abgov/react-components-new'; | ||
import { getFormDefinitions, getExportFormInfo } from '@store/form/action'; | ||
import { FormDefinition } from '@store/form/model'; | ||
|
||
export const FormExport = (): JSX.Element => { | ||
const dispatch = useDispatch(); | ||
|
||
const [selectedForm, setSelectedForm] = useState<FormDefinition>(); | ||
const [resourceType, setResourceType] = useState(''); | ||
const formDefinitions = useSelector((state: RootState) => state.form.definitions); | ||
|
||
const formList: FormDefinition[] = Object.entries(formDefinitions).map(([, value]) => value); | ||
const next = useSelector((state: RootState) => state.form.nextEntries); | ||
|
||
const exportToCsv = () => { | ||
if (selectedForm?.submissionRecords === true) { | ||
dispatch(getExportFormInfo(selectedForm?.id, 'submissions')); | ||
} else { | ||
dispatch(getExportFormInfo(selectedForm.id, 'forms')); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
if (next) { | ||
dispatch(getFormDefinitions(next)); | ||
} | ||
}, [next === 'NTA=']); | ||
|
||
return ( | ||
<section> | ||
<div> | ||
<GoAFormItem label="Form types"> | ||
<GoADropdown | ||
name="formTypes" | ||
value={selectedForm?.name} | ||
onChange={(name, value: string) => { | ||
const currentForm = formList.find((form) => form.name === value); | ||
setSelectedForm(currentForm); | ||
setResourceType(currentForm?.submissionRecords === true ? 'Submissions' : 'Forms'); | ||
}} | ||
aria-label="form-selection-dropdown" | ||
width="100%" | ||
testId="form-selection-dropdown" | ||
> | ||
{formList.map((item) => ( | ||
<GoADropdownItem | ||
name="formTypeList" | ||
key={item?.name} | ||
label={item?.name} | ||
value={item?.name} | ||
testId={`${item?.name}`} | ||
/> | ||
))} | ||
</GoADropdown> | ||
</GoAFormItem> | ||
<br /> | ||
<GoAFormItem label="Records"> | ||
<h3>{resourceType}</h3> | ||
</GoAFormItem> | ||
<br /> | ||
<GoAButton | ||
type="primary" | ||
size="normal" | ||
variant="normal" | ||
onClick={exportToCsv} | ||
testId="exportBtn" | ||
disabled={!selectedForm || Object.keys(formDefinitions).length === 0} | ||
> | ||
Export | ||
</GoAButton> | ||
</div> | ||
</section> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters