Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

625: Application end screen #648

Merged
merged 9 commits into from
Dec 14, 2022
28 changes: 24 additions & 4 deletions administration/src/application/components/ApplyController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import useVersionedLocallyStoredState from '../useVersionedLocallyStoredState'
import DiscardAllInputsButton from './DiscardAllInputsButton'
import { useGarbageCollectArrayBuffers, useInitializeGlobalArrayBuffersManager } from '../globalArrayBuffersManager'
import ApplicationForm from './forms/ApplicationForm'
import { useCallback, useMemo } from 'react'
import { useCallback, useMemo, useState } from 'react'
import { SnackbarProvider, useSnackbar } from 'notistack'
import styled from 'styled-components'
import ApplicationErrorBoundary from '../ApplicationErrorBoundary'

// This env variable is determined by '../../../application_commit.sh'. It holds the hash of the last commit to the
Expand All @@ -19,7 +20,15 @@ const lastCommitForApplicationForm = process.env.REACT_APP_APPLICATION_COMMIT as

export const applicationStorageKey = 'applicationState'

const SuccessContent = styled.div`
white-space: pre-line;
display: flex;
justify-content: center;
margin-bottom: 1rem;
`

const ApplyController = () => {
const [formSubmitted, setFormSubmitted] = useState<boolean>(false)
const [addBlueEakApplication, { loading }] = useAddBlueEakApplicationMutation()
const { status, state, setState } = useVersionedLocallyStoredState(
ApplicationForm.initialState,
Expand Down Expand Up @@ -57,14 +66,25 @@ const ApplyController = () => {
application: applicationInput,
},
})

setFormSubmitted(true)
setState(() => ApplicationForm.initialState)
michael-markl marked this conversation as resolved.
Show resolved Hide resolved
}
const successText = `Ihr Antrag für die Ehrenamtskarte wurde erfolgreich übermittelt.
Sie können das Fenster schließen.`
f1sh1918 marked this conversation as resolved.
Show resolved Hide resolved

return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'start', margin: '16px' }}>
<div style={{ maxWidth: '1000px', width: '100%' }}>
<h2 style={{ textAlign: 'center' }}>Blaue Ehrenamtskarte beantragen</h2>
<ApplicationForm.Component state={state} setState={setState} onSubmit={submit} loading={loading} />
<DialogActions>{loading ? null : <DiscardAllInputsButton discardAll={discardAll} />}</DialogActions>
<h2 style={{ textAlign: 'center' }}>{formSubmitted ? 'Erfolgreich gesendet' : 'Ehrenamtskarte beantragen'}</h2>
{formSubmitted ? (
<SuccessContent>{successText}</SuccessContent>
) : (
<ApplicationForm.Component state={state} setState={setState} onSubmit={submit} loading={loading} />
)}
<DialogActions>
{loading || formSubmitted ? null : <DiscardAllInputsButton discardAll={discardAll} />}
</DialogActions>
</div>
</div>
)
Expand Down