Skip to content

Commit

Permalink
feat(ojoi): Add involved party to (#16200)
Browse files Browse the repository at this point in the history
* Involved party client / graphql

* WIP: setting up involved party screen

* Involved parties now ready

* Fixed PR comments.

* Fixed more PR comments
  • Loading branch information
jonbjarnio authored and thoreyjona committed Oct 2, 2024
1 parent ee301d0 commit b9b67a6
Show file tree
Hide file tree
Showing 16 changed files with 384 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { GetApplicationAttachmentInput } from '../models/getApplicationAttachmen
import { GetApplicationAttachmentsResponse } from '../models/getApplicationAttachments.response'
import { DeleteApplicationAttachmentInput } from '../models/deleteApplicationAttachment.input'
import type { User } from '@island.is/auth-nest-tools'
import { GetUserInvolvedPartiesResponse } from '../models/getUserInvolvedParties.response'
import { GetUserInvolvedPartiesInput } from '../models/getUserInvolvedParties.input'

@Scopes(ApiScope.internal)
@UseGuards(IdsUserGuard, ScopesGuard)
Expand Down Expand Up @@ -110,4 +112,15 @@ export class OfficialJournalOfIcelandApplicationResolver {
) {
return this.ojoiApplicationService.deleteApplicationAttachment(input, user)
}

@Query(() => GetUserInvolvedPartiesResponse, {
name: 'officialJournalOfIcelandApplicationGetUserInvolvedParties',
})
getUserInvolvedParties(
@Args('input', { type: () => GetUserInvolvedPartiesInput })
input: GetUserInvolvedPartiesInput,
@CurrentUser() user: User,
) {
return this.ojoiApplicationService.getUserInvolvedParties(input, user)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DeleteApplicationAttachmentInput } from '../models/deleteApplicationAtt
import { LOGGER_PROVIDER } from '@island.is/logging'
import type { Logger } from '@island.is/logging'
import { User } from '@island.is/auth-nest-tools'
import { GetUserInvolvedPartiesInput } from '../models/getUserInvolvedParties.input'

const LOG_CATEGORY = 'official-journal-of-iceland-application'

Expand Down Expand Up @@ -166,4 +167,13 @@ export class OfficialJournalOfIcelandApplicationService {
return { success: false }
}
}

async getUserInvolvedParties(input: GetUserInvolvedPartiesInput, user: User) {
return this.ojoiApplicationService.getUserInvolvedParties(
{
id: input.applicationId,
},
user,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Field, ID, InputType } from '@nestjs/graphql'

@InputType('GetUserInvolvedPartiesInput')
export class GetUserInvolvedPartiesInput {
@Field(() => ID)
applicationId!: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Field, ObjectType } from '@nestjs/graphql'

@ObjectType('OfficialJournalOfIcelandApplicationGetUserInvolvedParty')
export class InvolvededParty {
@Field({ description: 'The id of the involved party' })
id!: string

@Field({ description: 'The title of the involved party' })
title!: string

@Field({ description: 'The slug of the involved party' })
slug!: string
}

@ObjectType('OfficialJournalOfIcelandApplicationGetUserInvolvedPartiesResponse')
export class GetUserInvolvedPartiesResponse {
@Field(() => [InvolvededParty])
involvedParties!: InvolvededParty[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import {
AlertMessage,
AlertMessageProps,
Box,
SkeletonLoader,
Text,
} from '@island.is/island-ui/core'
import * as styles from './FormScreen.css'
import { useLocale } from '@island.is/localization'
import { general } from '../../lib/messages'
import { OJOI_INPUT_HEIGHT } from '../../lib/constants'

type WarningProps = {
type?: AlertMessageProps['type']
Expand All @@ -20,6 +22,7 @@ type Props = {
button?: React.ReactNode
warning?: WarningProps
children?: React.ReactNode
loading?: boolean
}

export const FormScreen = ({
Expand All @@ -28,6 +31,7 @@ export const FormScreen = ({
button,
children,
warning,
loading,
}: Props) => {
const { formatMessage } = useLocale()

Expand Down Expand Up @@ -61,7 +65,16 @@ export const FormScreen = ({
</Box>
)}
</Box>
<Box className={styles.childrenWrapper}>{children}</Box>
{loading ? (
<SkeletonLoader
height={OJOI_INPUT_HEIGHT}
repeat={3}
borderRadius="standard"
space={2}
/>
) : (
<Box className={styles.childrenWrapper}>{children}</Box>
)}
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
preview,
publishing,
summary,
involvedParty,
} from '../lib/messages'
export const Requirements: Form = buildForm({
id: 'OfficialJournalOfIcelandApplication',
Expand All @@ -35,8 +36,25 @@ export const Requirements: Form = buildForm({
title: '',
component: 'RequirementsScreen',
}),
],
}),
],
}),
buildSection({
id: Routes.INVOLVED_PARTY,
title: involvedParty.general.section,
children: [
buildMultiField({
id: Routes.INVOLVED_PARTY,
title: '',
children: [
buildCustomField({
id: 'involvedParty',
title: '',
component: 'InvolvedPartyScreen',
}),
buildSubmitField({
id: 'toDraft',
id: 'toComments',
title: '',
refetchApplicationAfterSubmit: true,
actions: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ export const DEPARTMENTS_QUERY = gql`
}
`

export const INVOLVED_PARTIES_QUERY = gql`
query InvolvedParties($input: GetUserInvolvedPartiesInput!) {
officialJournalOfIcelandApplicationGetUserInvolvedParties(input: $input) {
involvedParties {
id
title
slug
}
}
}
`

export const CATEGORIES_QUERY = gql`
query AdvertCategories($params: OfficialJournalOfIcelandQueryInput!) {
officialJournalOfIcelandCategories(params: $params) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useQuery } from '@apollo/client'
import { OfficialJournalOfIcelandApplicationGetUserInvolvedPartiesResponse } from '@island.is/api/schema'
import { INVOLVED_PARTIES_QUERY } from '../graphql/queries'

type Props = {
applicationId?: string
onComplete?: (data: InvolvedPartiesResponse) => void
onError?: (error: Error) => void
}

type InvolvedPartiesResponse = {
officialJournalOfIcelandApplicationGetUserInvolvedParties: OfficialJournalOfIcelandApplicationGetUserInvolvedPartiesResponse
}
export const useInvolvedParties = ({
applicationId,
onComplete,
onError,
}: Props) => {
const { data, loading, error } = useQuery<InvolvedPartiesResponse>(
INVOLVED_PARTIES_QUERY,
{
skip: !applicationId,
fetchPolicy: 'no-cache',
variables: {
input: {
applicationId: applicationId,
},
},
onCompleted: (data) => {
onComplete && onComplete(data)
},
onError: (error) => {
onError && onError(error)
},
},
)

return {
involvedParties:
data?.officialJournalOfIcelandApplicationGetUserInvolvedParties
.involvedParties,
loading,
error,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const MINIMUM_WEEKDAYS = 10

export enum Routes {
REQUIREMENTS = 'requirements',
INVOLVED_PARTY = 'involvedParty',
COMMENTS = 'comments',
ADVERT = 'advert',
SIGNATURE = 'signature',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './publishing'
export * from './summary'
export * from './signatures'
export * from './comments'
export * from './involved-parties'
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { defineMessages } from 'react-intl'

export const involvedParty = {
general: defineMessages({
title: {
id: 'ojoi.application:original.general.title',
defaultMessage: 'Stofnun ',
description: 'Title of the involved party screen',
},
intro: {
id: 'ojoi.application:original.general.intro',
defaultMessage:
'Hér getur þú valið stofnun sem þú vilt tengja við umsóknina þína.',
description: 'Intro of the involved party form',
},
section: {
id: 'ojoi.application:original.general.section',
defaultMessage: 'Stofnanir',
description: 'Title of the involved party section',
},
}),
inputs: {
select: defineMessages({
placeholder: {
id: 'ojoi.application:original.inputs.select.placeholder',
defaultMessage: 'Veldu stofnun',
description: 'Placeholder for the select input',
},
}),
},

errors: defineMessages({
title: {
id: 'ojoi.application:original.error.title',
defaultMessage: 'Þú hefur ekki aðgang',
description: 'Title of the error message',
},
message: {
id: 'ojoi.application:original.error.message',
defaultMessage:
'Ekki tókst að sækja stofnanir fyrir aðganginn þinn, ef þú telur þig eiga að hafa aðgang, vinsamlegast hafðu samband við ritstjóra Stjórnartíðnda.',
description: 'Error message',
},
noDataTitle: {
id: 'ojoi.application:original.error.noDataTitle',
defaultMessage: 'Engar stofnanir',
description: 'Title of the no data message',
},
noDataMessage: {
id: 'ojoi.application:original.error.noDataMessage',
defaultMessage:
'Notandinn er ekki tengdur neinum stofnunum, vinsamlegast hafðu samband við ritstjóra Stjórnartíðnda.',
description: 'No data message',
},
}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const InputFields = {
categories: 'advert.categories',
channels: 'advert.channels',
message: 'advert.message',
involvedPartyId: 'advert.involvedPartyId',
},
[Routes.SIGNATURE]: {
regular: 'signatures.regular',
Expand Down
Loading

0 comments on commit b9b67a6

Please sign in to comment.