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

Lisätään ei tuloja -vaihtoehto tuloselvityslomakkeeseen #6454

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Expand Up @@ -560,6 +560,10 @@ const GrossIncomeSelection = React.memo(function GrossIncomeSelection({
const t = useTranslation()

const onIncomeSourceChange = useFieldDispatch(onChange, 'incomeSource')
const onNoIncomeDescriptionChange = useFieldDispatch(
onChange,
'noIncomeDescription'
)
const onEstimatedMonthlyIncomeChange = useFieldDispatch(
onChange,
'estimatedMonthlyIncome'
Expand All @@ -581,7 +585,7 @@ const GrossIncomeSelection = React.memo(function GrossIncomeSelection({
/>
<Gap size="s" />
<Radio
label={t.income.incomesRegisterConsent}
label={t.income.grossIncome.incomesRegisterConsent}
data-qa="incomes-register-consent-checkbox"
checked={formData.incomeSource === 'INCOMES_REGISTER'}
onChange={() => onIncomeSourceChange('INCOMES_REGISTER')}
Expand All @@ -593,10 +597,36 @@ const GrossIncomeSelection = React.memo(function GrossIncomeSelection({
onChange={() => onIncomeSourceChange('ATTACHMENTS')}
/>
<Gap size="s" />
<Radio
label={t.income.grossIncome.noIncome}
checked={formData.incomeSource === 'NO_INCOME'}
onChange={() => onIncomeSourceChange('NO_INCOME')}
/>
<Gap size="s" />
<InfoBox
message={t.income.grossIncome.attachmentsVerificationInfo}
thin
/>
{formData.incomeSource === 'NO_INCOME' && (
<>
<Gap size="m" />
<Label htmlFor="no-income-description">
{t.income.grossIncome.noIncomeDescription} *
</Label>
<Gap size="s" />
<InputField
id="no-income-description"
data-qa="no-income-description"
value={formData.noIncomeDescription}
onChange={onNoIncomeDescriptionChange}
hideErrorsBeforeTouched={!showFormErrors}
info={errorToInputInfo(
validate(formData.noIncomeDescription, required),
t.validationErrors
)}
/>
</>
)}
{formData.incomeSource === 'ATTACHMENTS' && (
<>
<Gap size="s" />
Expand All @@ -607,63 +637,74 @@ const GrossIncomeSelection = React.memo(function GrossIncomeSelection({
/>
</>
)}
<Gap size="L" />
<Label>{t.income.grossIncome.estimate}</Label>
<Gap size="m" />
<FixedSpaceRow>
<FixedSpaceColumn>
<LightLabel htmlFor="estimated-monthly-income">
{t.income.grossIncome.estimatedMonthlyIncome} *
</LightLabel>
<InputField
id="estimated-monthly-income"
data-qa="gross-monthly-income-estimate"
value={formData.estimatedMonthlyIncome}
onChange={onEstimatedMonthlyIncomeChange}
hideErrorsBeforeTouched={!showFormErrors}
info={errorToInputInfo(
validate(formData.estimatedMonthlyIncome, required, validInt),
t.validationErrors
)}
/>
</FixedSpaceColumn>
</FixedSpaceRow>
<Gap size="L" />
<Label>{t.income.grossIncome.otherIncome}</Label>
<Gap size="s" />
{t.income.grossIncome.otherIncomeDescription}
<Gap size="s" />
<OtherIncomeWrapper>
<MultiSelect
value={formData.otherIncome}
options={otherIncomes}
getOptionId={identity}
getOptionLabel={(option: OtherIncome) =>
t.income.grossIncome.otherIncomeTypes[option]
}
onChange={onOtherIncomeChange}
placeholder={t.income.grossIncome.choosePlaceholder}
/>
</OtherIncomeWrapper>
{formData.otherIncome.map((incomeType) => (
<AttachmentSection
key={incomeType}
attachmentType={incomeType}
showFormErrors={showFormErrors}
attachmentHandler={attachmentHandler}
/>
))}
{formData.otherIncome.length > 0 && (
{(formData.incomeSource === 'INCOMES_REGISTER' ||
formData.incomeSource === 'ATTACHMENTS') && (
<>
<Gap size="L" />
<Label>{t.income.grossIncome.estimate}</Label>
<Gap size="m" />
<FixedSpaceRow>
<FixedSpaceColumn>
<LightLabel htmlFor="estimated-monthly-income">
{t.income.grossIncome.estimatedMonthlyIncome} *
</LightLabel>
<InputField
id="estimated-monthly-income"
data-qa="gross-monthly-income-estimate"
value={formData.estimatedMonthlyIncome}
onChange={onEstimatedMonthlyIncomeChange}
hideErrorsBeforeTouched={!showFormErrors}
info={errorToInputInfo(
validate(
formData.estimatedMonthlyIncome,
required,
validInt
),
t.validationErrors
)}
/>
</FixedSpaceColumn>
</FixedSpaceRow>
<Gap size="L" />
<Label>{t.income.grossIncome.otherIncome}</Label>
<Gap size="s" />
<Label>{t.income.grossIncome.otherIncomeInfoLabel}</Label>
<Gap size="s" />
<P noMargin>{t.income.grossIncome.otherIncomeInfoDescription}</P>
{t.income.grossIncome.otherIncomeDescription}
<Gap size="s" />
<InputField
value={formData.otherIncomeInfo}
onChange={onOtherIncomeInfoChange}
/>
<OtherIncomeWrapper>
<MultiSelect
value={formData.otherIncome}
options={otherIncomes}
getOptionId={identity}
getOptionLabel={(option: OtherIncome) =>
t.income.grossIncome.otherIncomeTypes[option]
}
onChange={onOtherIncomeChange}
placeholder={t.income.grossIncome.choosePlaceholder}
/>
</OtherIncomeWrapper>
{formData.otherIncome.map((incomeType) => (
<AttachmentSection
key={incomeType}
attachmentType={incomeType}
showFormErrors={showFormErrors}
attachmentHandler={attachmentHandler}
/>
))}
{formData.otherIncome.length > 0 && (
<>
<Gap size="s" />
<Label>{t.income.grossIncome.otherIncomeInfoLabel}</Label>
<Gap size="s" />
<P noMargin>
{t.income.grossIncome.otherIncomeInfoDescription}
</P>
<Gap size="s" />
<InputField
value={formData.otherIncomeInfo}
onChange={onOtherIncomeInfoChange}
/>
</>
)}
</>
)}
</FixedSpaceColumn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,44 +201,60 @@ const GrossIncome = React.memo(function GrossIncome({
gross: Gross
}) {
const t = useTranslation()
return (
<>
<H2>{t.income.view.grossTitle}</H2>
<Row
label={t.income.view.incomeSource}
value={
gross.incomeSource === 'INCOMES_REGISTER'
? t.income.view.incomesRegister
: t.income.view.attachmentsAndKela
}
/>
<Row
label={t.income.view.grossEstimatedIncome}
value={gross.estimatedMonthlyIncome}
/>
<Row
label={t.income.view.otherIncome}
value={
if (gross.type === 'INCOME') {
return (
<>
<H2>{t.income.view.grossTitle}</H2>
<Row
label={t.income.view.incomeSource}
value={
gross.incomeSource === 'INCOMES_REGISTER'
? t.income.view.incomesRegister
: t.income.view.attachmentsAndKela
}
/>
<Row
label={t.income.view.grossEstimatedIncome}
value={gross.estimatedMonthlyIncome}
/>
<Row
label={t.income.view.otherIncome}
value={
<>
{gross.otherIncome.map((incomeType) => (
<Item key={incomeType}>
{t.income.grossIncome.otherIncomeTypes[incomeType]}
</Item>
))}
{gross.otherIncome.length === 0 && '-'}
</>
}
/>
{gross.otherIncome.length > 0 && (
<>
{gross.otherIncome.map((incomeType) => (
<Item key={incomeType}>
{t.income.grossIncome.otherIncomeTypes[incomeType]}
</Item>
))}
{gross.otherIncome.length === 0 && '-'}
<Row
label={t.income.view.otherIncomeInfo}
value={gross.otherIncomeInfo}
/>
</>
}
/>
{gross.otherIncome.length > 0 && (
<>
<Row
label={t.income.view.otherIncomeInfo}
value={gross.otherIncomeInfo}
/>
</>
)}
</>
)
)}
</>
)
} else {
return (
<>
<H2>{t.income.view.grossTitle}</H2>
<Row
label={t.income.view.incomeSource}
value={t.income.view.noIncomeTitle}
/>
<Row
label={t.income.view.noIncomeDescription}
value={gross.noIncomeDescription}
/>
</>
)
}
})

const EstimatedIncome = React.memo(function EstimatedIncome({
Expand Down
84 changes: 50 additions & 34 deletions frontend/src/employee-frontend/components/IncomeStatementPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,42 +204,58 @@ function IncomeInfo({

function GrossIncome({ gross }: { gross: Gross }) {
const { i18n } = useTranslation()
return (
<>
<H2>{i18n.incomeStatement.grossTitle}</H2>
<Row
label={i18n.incomeStatement.incomeSource}
value={
gross.incomeSource === 'INCOMES_REGISTER'
? i18n.incomeStatement.incomesRegister
: i18n.incomeStatement.attachmentsAndKela
}
/>
<Row
label={i18n.incomeStatement.grossEstimatedIncome}
value={gross.estimatedMonthlyIncome}
/>
<Row
label={i18n.incomeStatement.otherIncome}
value={
<>
{gross.otherIncome.map((incomeType) => (
<Item key={incomeType}>
{i18n.incomeStatement.otherIncomeTypes[incomeType]}
</Item>
))}
{gross.otherIncome.length === 0 && '-'}
</>
}
/>
{gross.otherIncome.length > 0 && (
if (gross.type === 'INCOME') {
return (
<>
<H2>{i18n.incomeStatement.grossTitle}</H2>
<Row
label={i18n.incomeStatement.incomeSource}
value={
gross.incomeSource === 'INCOMES_REGISTER'
? i18n.incomeStatement.incomesRegister
: i18n.incomeStatement.attachmentsAndKela
}
/>
<Row
label={i18n.incomeStatement.otherIncomeInfo}
value={gross.otherIncomeInfo}
label={i18n.incomeStatement.grossEstimatedIncome}
value={gross.estimatedMonthlyIncome}
/>
)}
</>
)
<Row
label={i18n.incomeStatement.otherIncome}
value={
<>
{gross.otherIncome.map((incomeType) => (
<Item key={incomeType}>
{i18n.incomeStatement.otherIncomeTypes[incomeType]}
</Item>
))}
{gross.otherIncome.length === 0 && '-'}
</>
}
/>
{gross.otherIncome.length > 0 && (
<Row
label={i18n.incomeStatement.otherIncomeInfo}
value={gross.otherIncomeInfo}
/>
)}
</>
)
} else {
return (
<>
<H2>{i18n.incomeStatement.grossTitle}</H2>
<Row
label={i18n.incomeStatement.incomeSource}
value={i18n.incomeStatement.noIncomeTitle}
/>
<Row
label={i18n.incomeStatement.noIncomeDescription}
value={gross.noIncomeDescription}
/>
</>
)
}
}

function EstimatedIncome({
Expand Down
Loading