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(application-system): handle pruned application links #15233

Merged
merged 10 commits into from
Jun 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export class BaseApplicationResponseDto {
@IsEnum(ApplicationStatus)
status!: ApplicationStatus

@ApiProperty()
@Expose()
@IsBoolean()
pruned?: boolean

constructor(partial: Partial<BaseApplicationResponseDto>) {
Object.assign(this, partial)
}
Expand Down
3 changes: 3 additions & 0 deletions libs/api/domains/application/src/lib/application.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ export class Application {

@Field(() => ApplicationResponseDtoStatusEnum)
status!: ApplicationResponseDtoStatusEnum

@Field(() => Boolean, { nullable: true })
pruned?: boolean
}

@ObjectType()
Expand Down
18 changes: 12 additions & 6 deletions libs/api/domains/application/src/lib/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ export class ApplicationService {
}

async findOne(id: string, auth: Auth, locale: Locale) {
return await this.applicationApiWithAuth(auth).applicationControllerFindOne(
{
id,
locale,
},
)
const data = await this.applicationApiWithAuth(
auth,
).applicationControllerFindOne({
id,
locale,
})

if (data.pruned) {
return { ...data, answers: {}, attachments: {}, externalData: {} }
}

return data
}

async getPaymentStatus(
Expand Down
18 changes: 18 additions & 0 deletions libs/application/core/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,24 @@ export const coreErrorScreenMessages = defineMessages({
description:
'Error screen description when user has a bad subject error after checking delegations',
},
prunedTitle: {
id: 'application.system:core.errorScreen.prunedTitle',
defaultMessage: 'Umsóknin er runnin út',
description:
'Error screen title when the application has been pruned and is not editable',
},
prunedSubTitle: {
id: 'application.system:core.errorScreen.prunedSubTitle',
defaultMessage: 'Umsóknin hefur runnið út og er ekki lengur aðgengileg',
description:
'Error screen subtitle when the application has been pruned and is not editable',
},
prunedDescription: {
id: 'application.system:core.errorScreen.prunedDescription#markdown',
defaultMessage: `* Öllum persónugögnum var eytt þegar umsóknin rann út\n* Ef klára á umsókn af þessu tagi þarf að stofna nýja`,
description:
'Error screen description when user has a bad subject error after checking delegations',
},
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
lostTitle: {
id: 'application.system:core.errorScreen.lostTitle',
defaultMessage: 'Umsókn týnd - Ekki til',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ export const ApplicationFragment = gql`
name
institution
status
pruned
}
`
6 changes: 6 additions & 0 deletions libs/application/ui-shell/src/components/ErrorShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const messageTypes = {
subTitle: coreErrorScreenMessages.badSubjectSubTitle,
description: coreErrorScreenMessages.badSubjectDescription,
},
pruned: {
title: coreErrorScreenMessages.prunedTitle,
subTitle: coreErrorScreenMessages.prunedSubTitle,
description: coreErrorScreenMessages.prunedDescription,
},
}

interface Props {
Expand All @@ -66,6 +71,7 @@ interface Props {
| 'notExist'
| 'idNotFound'
| 'badSubject'
| 'pruned'
applicationType?: ApplicationTypes
}

Expand Down
38 changes: 21 additions & 17 deletions libs/application/ui-shell/src/lib/ApplicationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ import {
} from '@island.is/shared/problem'
import { DelegationsScreen } from '../components/DelegationsScreen'

const ApplicationLoader: FC<
React.PropsWithChildren<{
applicationId: string
nationalRegistryId: string
slug: string
}>
> = ({ applicationId, nationalRegistryId, slug }) => {
type Props = {
applicationId: string
nationalRegistryId: string
slug: string
}
jonnigs marked this conversation as resolved.
Show resolved Hide resolved

const ApplicationLoader = ({
applicationId,
nationalRegistryId,
slug,
}: Props) => {
const type = getTypeFromSlug(slug)
const [delegationsChecked, setDelegationsChecked] = useState(
type ? false : true,
)
const [delegationsChecked, setDelegationsChecked] = useState(!type)

const { lang: locale } = useLocale()
const { data, error, loading, refetch } = useQuery(APPLICATION_APPLICATION, {
Expand Down Expand Up @@ -72,6 +74,10 @@ const ApplicationLoader: FC<
return <ErrorShell errorType="idNotFound" />
}

if (application.pruned) {
return <ErrorShell errorType="pruned" />
}

if (!applicationId || error) {
const foundError = findProblemInApolloError(error, [
ProblemType.BAD_SUBJECT,
Expand Down Expand Up @@ -184,13 +190,11 @@ const ShellWrapper: FC<
)
}

export const ApplicationForm: FC<
React.PropsWithChildren<{
applicationId: string
nationalRegistryId: string
slug: string
}>
> = ({ applicationId, nationalRegistryId, slug }) => {
export const ApplicationForm = ({
applicationId,
nationalRegistryId,
slug,
}: Props) => {
return (
<FieldProvider>
<ApplicationLoader
Expand Down
Loading