Skip to content

Commit

Permalink
Merge branch 'main' into j-s/update-punishment-type-prison-indictment…
Browse files Browse the repository at this point in the history
…-overview
  • Loading branch information
kodiakhq[bot] authored Dec 16, 2024
2 parents 33f5477 + c4bc9c4 commit 67a1220
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ export class CaseService {
'Content-Type': 'application/json',
authorization: `Bearer ${this.config.secretToken}`,
},
body: JSON.stringify({ nationalId }),
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ export const m = defineMessages({
id: 'sp.social-insurance-maintenance:income-plan-link-text',
defaultMessage: 'Hvað er tekjuáætlun?',
},
incomePlanTemporarilyUnavailable: {
id: 'sp.social-insurance-maintenance:income-plan-temporarily-unavailable',
paymentPlanTemporarilyUnavailable: {
id: 'sp.social-insurance-maintenance:payment-plan-temporarily-unavailable',
defaultMessage:
'Bráðabirgðatekjuáætlun 2025 verður tilbúin seinni part desember',
'Bráðabirgðagreiðsluáætlun 2025 verður tilbúin seinni part desember',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,14 @@ import {
m as coreMessages,
} from '@island.is/portals/my-pages/core'
import { m } from '../../lib/messages'
import {
useGetIncomePlanDetailLazyQuery,
useGetIncomePlanDetailQuery,
} from './IncomePlanDetail.generated'
import { useGetIncomePlanDetailQuery } from './IncomePlanDetail.generated'
import { Problem } from '@island.is/react-spa/shared'
import { useEffect, useState } from 'react'
import { useFeatureFlagClient } from '@island.is/react/feature-flags'

const IncomePlanDetail = () => {
useNamespaces('sp.social-insurance-maintenance')
const { formatMessage } = useLocale()

const [displayPaymentPlan, setDisplayPaymentPlan] = useState(false)
const [query, { data, loading, error }] = useGetIncomePlanDetailLazyQuery()

const featureFlagClient = useFeatureFlagClient()
useEffect(() => {
const isFlagEnabled = async () => {
const ffEnabled = await featureFlagClient.getValue(
`isServicePortalPaymentPlan2025Enabled`,
false,
)
if (ffEnabled) {
setDisplayPaymentPlan(ffEnabled as boolean)
}
}
isFlagEnabled()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
if (displayPaymentPlan) {
query()
}
}, [displayPaymentPlan])

if (!displayPaymentPlan) {
return (
<IntroWrapper
title={formatMessage(coreMessages.latestIncomePlan)}
intro={formatMessage(m.incomePlanDetail)}
serviceProviderSlug={'tryggingastofnun'}
serviceProviderTooltip={formatMessage(
coreMessages.socialInsuranceTooltip,
)}
>
<AlertMessage
type="warning"
message={formatMessage(m.incomePlanTemporarilyUnavailable)}
/>
</IntroWrapper>
)
}

const { data, loading, error } = useGetIncomePlanDetailQuery()
return (
<IntroWrapper
title={formatMessage(coreMessages.latestIncomePlan)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,77 @@
import { Box, Divider, Stack, Text } from '@island.is/island-ui/core'
import {
AlertMessage,
Box,
Divider,
Stack,
Text,
} from '@island.is/island-ui/core'
import { useLocale, useNamespaces } from '@island.is/localization'
import { Problem } from '@island.is/react-spa/shared'
import {
FootNote,
IntroHeader,
IntroWrapper,
LinkButton,
UserInfoLine,
amountFormat,
m as coreMessages,
} from '@island.is/portals/my-pages/core'
import { m } from '../../lib/messages'
import { useGetPreviousPaymentsQuery } from './PaymentPlan.generated'
import { PaymentGroupTable } from '../../components'
import { useEffect, useState } from 'react'
import { useFeatureFlagClient } from '@island.is/react/feature-flags'
import { useGetPreviousPaymentsLazyQuery } from './PaymentPlan.generated'

const PaymentPlan = () => {
useNamespaces('sp.social-insurance-maintenance')
const { formatMessage } = useLocale()

const { data, loading, error } = useGetPreviousPaymentsQuery()
const [displayPaymentPlan, setDisplayPaymentPlan] = useState(false)
const [query, { data, loading, error }] = useGetPreviousPaymentsLazyQuery()

const featureFlagClient = useFeatureFlagClient()

useEffect(() => {
const isFlagEnabled = async () => {
const ffEnabled = await featureFlagClient.getValue(
`isServicePortalPaymentPlan2025Enabled`,
false,
)
if (ffEnabled) {
setDisplayPaymentPlan(ffEnabled as boolean)
}
}
isFlagEnabled()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
if (displayPaymentPlan) {
query()
}
}, [displayPaymentPlan])

if (!displayPaymentPlan) {
return (
<IntroWrapper
title={formatMessage(coreMessages.paymentPlan)}
intro={formatMessage(
coreMessages.socialInsuranceMaintenanceDescription,
)}
serviceProviderSlug={'tryggingastofnun'}
serviceProviderTooltip={formatMessage(
coreMessages.socialInsuranceTooltip,
)}
>
<AlertMessage
type="warning"
message={formatMessage(m.paymentPlanTemporarilyUnavailable)}
/>
</IntroWrapper>
)
}

return (
<Box>
<IntroHeader
<IntroWrapper
title={formatMessage(coreMessages.paymentPlan)}
intro={formatMessage(
coreMessages.socialInsuranceMaintenanceDescription,
Expand All @@ -30,68 +80,68 @@ const PaymentPlan = () => {
serviceProviderTooltip={formatMessage(
coreMessages.socialInsuranceTooltip,
)}
/>
{error && !loading ? (
<Problem error={error} noBorder={false} />
) : !error && !loading && !data?.socialInsurancePayments ? (
<Problem
type="no_data"
noBorder={false}
title={formatMessage(coreMessages.noData)}
message={formatMessage(coreMessages.noDataFoundDetail)}
imgSrc="./assets/images/sofa.svg"
/>
) : (
<>
<Box>
<Stack space={1}>
<UserInfoLine
label={formatMessage(m.nextPayment)}
content={
data?.socialInsurancePayments?.nextPayment
? amountFormat(data?.socialInsurancePayments?.nextPayment)
: ' 0 kr.'
}
loading={loading}
/>
<Divider />
<UserInfoLine
label={formatMessage(m.previousMonthsPayment)}
content={
data?.socialInsurancePayments?.previousPayment
? amountFormat(
data?.socialInsurancePayments?.previousPayment,
)
: ' 0 kr.'
}
loading={loading}
/>
<Divider />
</Stack>
>
{error && !loading ? (
<Problem error={error} noBorder={false} />
) : !error && !loading && !data?.socialInsurancePayments ? (
<Problem
type="no_data"
noBorder={false}
title={formatMessage(coreMessages.noData)}
message={formatMessage(coreMessages.noDataFoundDetail)}
imgSrc="./assets/images/sofa.svg"
/>
) : (
<>
<Box>
<Stack space={1}>
<UserInfoLine
label={formatMessage(m.nextPayment)}
content={
data?.socialInsurancePayments?.nextPayment
? amountFormat(data?.socialInsurancePayments?.nextPayment)
: ' 0 kr.'
}
loading={loading}
/>
<Divider />
<UserInfoLine
label={formatMessage(m.previousMonthsPayment)}
content={
data?.socialInsurancePayments?.previousPayment
? amountFormat(
data?.socialInsurancePayments?.previousPayment,
)
: ' 0 kr.'
}
loading={loading}
/>
<Divider />
</Stack>

<Text marginTop={[2, 2, 6]} marginBottom={2} variant="h5">
{formatMessage(coreMessages.period)}
</Text>
<Text marginTop={[2, 2, 6]} marginBottom={2} variant="h5">
{formatMessage(coreMessages.period)}
</Text>

<PaymentGroupTable />
</Box>
<Box>
<Text variant="small" marginTop={5} marginBottom={2}>
{formatMessage(m.maintenanceFooter)}
{formatMessage(m.maintenanceFooterLink, {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
link: (str: any) => (
<LinkButton
to={formatMessage(m.maintenanceFooterLinkUrl)}
text={str ?? ''}
/>
),
})}
</Text>
</Box>
</>
)}
<FootNote serviceProviderSlug="tryggingastofnun" />
<PaymentGroupTable />
</Box>
<Box>
<Text variant="small" marginTop={5} marginBottom={2}>
{formatMessage(m.maintenanceFooter)}
{formatMessage(m.maintenanceFooterLink, {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
link: (str: any) => (
<LinkButton
to={formatMessage(m.maintenanceFooterLinkUrl)}
text={str ?? ''}
/>
),
})}
</Text>
</Box>
</>
)}
</IntroWrapper>
</Box>
)
}
Expand Down

0 comments on commit 67a1220

Please sign in to comment.