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

feat: prefill campaign application organizer form values from current user (Epic #1842) #1874

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useState } from 'react'

import { Grid, StepLabel } from '@mui/material'
import { Person } from 'gql/person'

import {
CampaignApplicationFormData,
Expand All @@ -25,17 +25,6 @@ import {
StyledStepConnector,
} from './helpers/campaignApplication.styled'

const initialValues: CampaignApplicationFormData = {
organizer: {
name: '',
phone: '',
email: '',
acceptTermsAndConditions: false,
transparencyTermsAccepted: false,
personalInformationProcessingAccepted: false,
},
}

const steps: StepType[] = [
{
title: 'campaign-application:steps.organizer.title',
Expand All @@ -51,9 +40,24 @@ const steps: StepType[] = [
},
]

export default function CampaignApplicationForm() {
type Props = {
person?: Person
}

export default function CampaignApplicationForm({ person }: Props) {
const [activeStep, setActiveStep] = useState<Steps>(Steps.ORGANIZER)

const initialValues: CampaignApplicationFormData = {
organizer: {
name: `${person?.firstName} ${person?.lastName}` ?? '',
phone: person?.phone ?? '',
email: person?.email ?? '',
acceptTermsAndConditions: false,
transparencyTermsAccepted: false,
personalInformationProcessingAccepted: false,
},
}

const handleSubmit = () => {
stepsHandler({ activeStep, setActiveStep })
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { CircularProgress, Grid } from '@mui/material'
import { useCurrentPerson } from 'common/util/useCurrentPerson'
import Layout from '../layout/Layout'
import CampaignApplicationForm from './CampaignApplicationForm'

export default function CampaignApplicationPage() {
const { data: userData, isLoading } = useCurrentPerson()
const person = userData?.user || undefined

if (isLoading) {
return (
<Grid container justifyContent="center" alignContent="center" sx={{ height: '100vh' }}>
<CircularProgress />
</Grid>
)
}

return (
<Layout maxWidth="md" sx={{ paddingInline: 5 }}>
<CampaignApplicationForm />
<CampaignApplicationForm person={person} />
</Layout>
)
}
Loading