Skip to content

Commit

Permalink
Merge pull request #6 from pughlab/drafts-bugfixes
Browse files Browse the repository at this point in the history
Fixed bug where all values were saved as strings. Changed draft autos…
  • Loading branch information
suluxan authored Feb 9, 2024
2 parents ab015e8 + faa747c commit 96cb082
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ui/src/components/form/FormGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function FormGenerator({ formMetadata, root }) {

const { patientIdentifier } = useContext(PatientIdentifierContext)
const { activeSubmission } = useContext(ActiveSubmissionContext)
const { patientFound } = useContext(PatientFoundContext)
const { patientFound, setPatientFound } = useContext(PatientFoundContext)

// Reducer variables and associated functions
const [state, dispatch] = useReducer(formReducer, initialState)
Expand Down Expand Up @@ -208,7 +208,7 @@ export function FormGenerator({ formMetadata, root }) {
const { name, value } = e.target
dispatch({
type: 'UPDATE_FIELDS',
payload: { [name]: value }
payload: { [name]: value instanceof Date || isNaN(value) ? value : Number(value) }
})
setDraftModified(true)
}
Expand Down Expand Up @@ -447,6 +447,7 @@ export function FormGenerator({ formMetadata, root }) {
// the submissions table to re-render
alert('Form submitted!')
setLastSubmissionUpdate(`Submissions-${new Date().toUTCString()}`)
setPatientFound(true)
}
})
.catch((error) => {
Expand Down Expand Up @@ -534,7 +535,16 @@ export function FormGenerator({ formMetadata, root }) {
// final render
return (
<div key={formMetadata.form_name} style={{ paddingLeft: "60px", paddingRight: "60px" }}>
{ lastDraftUpdate !== "" ? <><span style={{float: 'right'}}>Last autosaved at: {lastDraftUpdate}</span><br/></> : <></> }
{
lastDraftUpdate !== ""
? <>
<span style={{float: 'right'}}>
Patient {patientIdentifier.submitter_donor_id}: {formMetadata.form_name} form last autosaved at: {lastDraftUpdate}
</span>
<br/>
</>
: <></>
}
<Form
size="small"
onSubmit={(event) => {
Expand Down

0 comments on commit 96cb082

Please sign in to comment.