Skip to content

Commit

Permalink
fix(social-insurance-maintenance): Disable payment plan with FF (#17181)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
thorkellmani and kodiakhq[bot] authored Dec 10, 2024
1 parent 0309242 commit 4a6defe
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 45 deletions.
3 changes: 3 additions & 0 deletions libs/feature-flags/src/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export enum Features {
//New License service fetch enabled
licensesV2 = 'isLicensesV2Enabled',

//Is social administration payment plan 2025 enabled?
isServicePortalPaymentPlan2025Enabled = 'isServicePortalPaymentPlan2025Enabled',

//Possible universities
isUniversityOfAkureyriEnabled = 'isUniversityOfAkureyriEnabled',
isAgriculturalUniversityOfIcelandEnabled = 'isAgriculturalUniversityOfIcelandEnabled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +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',
defaultMessage:
'Bráðabirgðatekjuáætlun 2025 verður tilbúin seinni part desember',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,6 @@ const parseSubtext = (
}
}

const parseTag = (
tag: SocialInsuranceIncomePlanStatus,
formatMessage: FormatMessage,
) => {
switch (tag) {
case SocialInsuranceIncomePlanStatus.ACCEPTED:
return {
label: formatMessage(coreMessages.processed),
variant: 'mint' as const,
outlined: false,
}
case SocialInsuranceIncomePlanStatus.IN_PROGRESS:
return {
label: formatMessage(coreMessages.inProgress),
variant: 'purple' as const,
outlined: false,
}
case SocialInsuranceIncomePlanStatus.CANCELLED:
return {
label: formatMessage(coreMessages.rejected),
variant: 'red' as const,
outlined: false,
}
default:
return {
label: formatMessage(coreMessages.unknown),
variant: 'red' as const,
outlined: false,
}
}
}

const IncomePlan = () => {
useNamespaces('sp.social-insurance-maintenance')
const { formatMessage } = useLocale()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Box,
Inline,
Stack,
Button,
Expand All @@ -10,32 +9,75 @@ import {
import { useLocale, useNamespaces } from '@island.is/localization'
import {
EmptyTable,
FootNote,
IntroHeader,
IntroWrapper,
LinkButton,
amountFormat,
m as coreMessages,
} from '@island.is/portals/my-pages/core'
import { m } from '../../lib/messages'
import { useGetIncomePlanDetailQuery } from './IncomePlanDetail.generated'
import {
useGetIncomePlanDetailLazyQuery,
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 { data, loading, error } = useGetIncomePlanDetailQuery()
return (
<Box>
<IntroHeader
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>
)
}

return (
<IntroWrapper
title={formatMessage(coreMessages.latestIncomePlan)}
intro={formatMessage(m.incomePlanDetail)}
serviceProviderSlug={'tryggingastofnun'}
serviceProviderTooltip={formatMessage(
coreMessages.socialInsuranceTooltip,
)}
>
{error && !loading ? (
<Problem error={error} noBorder={false} />
) : !error && !loading && !data?.socialInsuranceIncomePlan ? (
Expand Down Expand Up @@ -117,10 +159,7 @@ const IncomePlanDetail = () => {
)}
</Stack>
)}
<Hidden print>
<FootNote serviceProviderSlug="tryggingastofnun" />
</Hidden>
</Box>
</IntroWrapper>
)
}

Expand Down

0 comments on commit 4a6defe

Please sign in to comment.