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(ojoi): Rejected state and improvements #16574

Merged
merged 18 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
194d7a6
Rejected application now go to appropriate state.
jonbjarnio Oct 22, 2024
e778fc3
Added action cards to application, and users can directly create a ne…
jonbjarnio Oct 24, 2024
4bb9a7e
Updating signatures markup, adding links to go navigate to screen fro…
jonbjarnio Oct 24, 2024
f138713
Fixed issues found during design review
jonbjarnio Oct 25, 2024
ea4ddfd
New method that fetches case data for submitted applications.
jonbjarnio Oct 25, 2024
4bd4f2b
Merge branch 'main' into feat/ojoi-application-additional-state
jonbjarnio Oct 25, 2024
1e7b33b
Removed console log
jonbjarnio Oct 28, 2024
e7ead51
Merge branch 'feat/ojoi-application-additional-state' of https://gith…
jonbjarnio Oct 28, 2024
7fc8990
Merge branch 'main' into feat/ojoi-application-additional-state
jonbjarnio Oct 28, 2024
78abee2
Merge branch 'main' into feat/ojoi-application-additional-state
jonbjarnio Oct 28, 2024
beb8db1
Merge branch 'main' into feat/ojoi-application-additional-state
jonbjarnio Oct 28, 2024
f251dae
Merge branch 'main' into feat/ojoi-application-additional-state
jonbjarnio Oct 28, 2024
ff530c4
Merge branch 'main' into feat/ojoi-application-additional-state
jonbjarnio Oct 28, 2024
be68126
Add hardcoded string to messages
jonbjarnio Oct 28, 2024
f3d2295
Merge branch 'feat/ojoi-application-additional-state' of https://gith…
jonbjarnio Oct 28, 2024
d74a8b7
Added more strings to messages
jonbjarnio Oct 28, 2024
8aebbb9
Merge branch 'main' into feat/ojoi-application-additional-state
jonbjarnio Oct 28, 2024
8035df4
Merge branch 'main' into feat/ojoi-application-additional-state
kodiakhq[bot] Oct 28, 2024
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
7 changes: 0 additions & 7 deletions apps/web/screens/OfficialJournalOfIceland/OJOISearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,6 @@ const OJOISearchPage: CustomScreen<OJOISearchProps> = ({
[debouncedSearch],
)

const defaultDepartment = departmentsOptions.find(
(d) => d.value === defaultSearchParams.deild,
)

console.log(defaultSearchParams)
console.log('defaultdepartment', defaultDepartment)

return (
<OJOIWrapper
pageTitle={formatMessage(m.search.title)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { DeleteApplicationAttachmentInput } from '../models/deleteApplicationAtt
import type { User } from '@island.is/auth-nest-tools'
import { GetUserInvolvedPartiesResponse } from '../models/getUserInvolvedParties.response'
import { GetUserInvolvedPartiesInput } from '../models/getUserInvolvedParties.input'
import { OJOIAIdInput } from '../models/id.input'
import { OJOIAApplicationCaseResponse } from '../models/applicationCase.response'

@Scopes(ApiScope.internal)
@UseGuards(IdsUserGuard, ScopesGuard)
Expand Down Expand Up @@ -123,4 +125,14 @@ export class OfficialJournalOfIcelandApplicationResolver {
) {
return this.ojoiApplicationService.getUserInvolvedParties(input, user)
}

@Query(() => OJOIAApplicationCaseResponse, {
name: 'OJOIAGetApplicationCase',
})
getApplicationCase(
@Args('input') input: OJOIAIdInput,
@CurrentUser() user: User,
) {
return this.ojoiApplicationService.getApplicationCase(input.id, user)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CommentDirection,
GetCommentsResponse,
} from '../models/getComments.response'
import { OJOIAApplicationCaseResponse } from '../models/applicationCase.response'

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

Expand Down Expand Up @@ -207,4 +208,34 @@ export class OfficialJournalOfIcelandApplicationService {
user,
)
}

async getApplicationCase(
id: string,
user: User,
): Promise<OJOIAApplicationCaseResponse> {
const { applicationCase } =
await this.ojoiApplicationService.getApplicationCase(
{
id,
},
user,
)

let title = 'Óþekkt'

if ('title' in applicationCase.status) {
title = applicationCase.status.title as string
}

const mapped: OJOIAApplicationCaseResponse = {
department: applicationCase.department.title,
type: applicationCase.type.title,
categories: applicationCase.categories.map((c) => c.title),
html: applicationCase.html,
status: title,
communicationStatus: applicationCase.communicationStatus.title,
}

return mapped
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Field, ObjectType } from '@nestjs/graphql'

@ObjectType('OJOIAApplicationCaseResponse')
export class OJOIAApplicationCaseResponse {
@Field()
department!: string

@Field()
type!: string

@Field()
status!: string

@Field()
communicationStatus!: string

@Field(() => [String])
categories!: string[]

@Field()
html!: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Field, InputType, ID } from '@nestjs/graphql'

@InputType('OJOIAIdInput', {
description: 'Input dto that represents the id of the application',
})
export class OJOIAIdInput {
@Field(() => ID)
id!: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import { InputFields } from '../../lib/types'

type Props = {
applicationId: string
defaultName?: string
defaultEmail?: string
defaultPhone?: string
defaultVisible?: boolean
}

export const AddChannel = ({
applicationId,
defaultName,
defaultEmail,
defaultPhone,
defaultVisible,
Expand All @@ -26,25 +28,28 @@ export const AddChannel = ({
})
const { formatMessage: f } = useLocale()

const [name, setName] = useState('')
const [email, setEmail] = useState('')
const [phone, setPhone] = useState('')
const [isVisible, setIsVisible] = useState(defaultVisible ?? false)

useEffect(() => {
setName(defaultName ?? name)
setEmail(defaultEmail ?? email)
setPhone(defaultPhone ?? phone)
setIsVisible(defaultVisible ?? false)
}, [defaultEmail, defaultPhone, defaultVisible])
}, [defaultName, defaultEmail, defaultPhone, defaultVisible])

const onAddChannel = () => {
const currentAnswers = structuredClone(application.answers)
const currentChannels = currentAnswers.advert?.channels ?? []
const updatedAnswers = set(currentAnswers, InputFields.advert.channels, [
...currentChannels,
{ email, phone },
{ name, email, phone },
])

updateApplication(updatedAnswers)
setName('')
setEmail('')
setPhone('')
}
Expand All @@ -58,6 +63,16 @@ export const AddChannel = ({
width="full"
>
<Box className={styles.contentWrap} marginBottom={5}>
<Box className={styles.emailWrap}>
<Input
size="xs"
name="name"
type="text"
value={name}
label={f(general.name)}
onChange={(e) => setName(e.target.value)}
/>
</Box>
<Box className={styles.emailWrap}>
<Input
size="xs"
Expand All @@ -84,6 +99,7 @@ export const AddChannel = ({
variant="ghost"
onClick={() => {
setIsVisible(!isVisible)
setName('')
setEmail('')
setPhone('')
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { general } from '../../lib/messages'
import { useApplication } from '../../hooks/useUpdateApplication'
import { InputFields } from '../../lib/types'
import set from 'lodash/set'
import { useAuth } from '@island.is/auth/react'

type Props = {
applicationId: string
onEditChannel: (email?: string, phone?: string) => void
onEditChannel?: (email?: string, phone?: string, name?: string) => void
}

export const ChannelList = ({ applicationId, onEditChannel }: Props) => {
Expand All @@ -17,16 +18,28 @@ export const ChannelList = ({ applicationId, onEditChannel }: Props) => {
applicationId,
})

const channels = application.answers.advert?.channels || []
const { userInfo } = useAuth()

const onRemoveChannel = (email?: string) => {
const defaultName = userInfo?.profile?.name
const defaultEmail = userInfo?.profile?.email
const defaultPhone = userInfo?.profile?.phone_number

const initalChannel = {
name: defaultName,
email: defaultEmail,
phone: defaultPhone,
}

const channels = application.answers.advert?.channels || [initalChannel]

const onRemoveChannel = (index?: number) => {
const currentAnswers = structuredClone(application.answers)
const currentChannels = currentAnswers.advert?.channels ?? []

const updatedAnswers = set(
currentAnswers,
InputFields.advert.channels,
currentChannels.filter((channel) => channel.email !== email),
currentChannels.filter((_, i) => i !== index),
)

updateApplication(updatedAnswers)
Expand All @@ -40,35 +53,43 @@ export const ChannelList = ({ applicationId, onEditChannel }: Props) => {
<T.Table>
<T.Head>
<T.Row>
<T.HeadData>{formatMessage(general.name)}</T.HeadData>
<T.HeadData>{formatMessage(general.email)}</T.HeadData>
<T.HeadData>{formatMessage(general.phoneNumber)}</T.HeadData>
<T.HeadData></T.HeadData>
<T.HeadData></T.HeadData>
</T.Row>
</T.Head>
<T.Body>
{channels.map((channel, i) => (
<T.Row key={i}>
<T.Data>{channel.email}</T.Data>
<T.Data>{channel.phone}</T.Data>
<T.Data style={{ paddingInline: 0 }} align="center" width={1}>
<button
type="button"
onClick={() => onEditChannel(channel.email, channel.phone)}
>
<Icon color="blue400" icon="pencil" />
</button>
</T.Data>
<T.Data style={{ paddingInline: 0 }} align="center" width={1}>
<button
type="button"
onClick={() => onRemoveChannel(channel.email)}
>
<Icon color="blue400" icon="trash" />
</button>
</T.Data>
</T.Row>
))}
{channels.map((channel, i) => {
return (
<T.Row key={i}>
<T.Data>{channel.name}</T.Data>
<T.Data>{channel.email}</T.Data>
<T.Data>{channel.phone}</T.Data>
<T.Data style={{ paddingInline: 0 }} align="center" width={1}>
{onEditChannel && (
<button
type="button"
onClick={() =>
onEditChannel(channel.name, channel.email, channel.phone)
}
>
<Icon color="blue400" icon="pencil" />
</button>
)}
</T.Data>

<T.Data style={{ paddingInline: 0 }} align="center" width={1}>
{onEditChannel && (
<button type="button" onClick={() => onRemoveChannel(i)}>
<Icon color="blue400" icon="trash" />
</button>
)}
</T.Data>
</T.Row>
)
})}
</T.Body>
</T.Table>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import {
AlertMessage,
AlertMessageProps,
Box,
Bullet,
BulletList,
Button,
Inline,
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'
import { OJOI_INPUT_HEIGHT, Routes } from '../../lib/constants'

type WarningProps = {
type?: AlertMessageProps['type']
Expand All @@ -23,6 +27,7 @@ type Props = {
warning?: WarningProps
children?: React.ReactNode
loading?: boolean
goToScreen?: (screen: string) => void
}

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

Expand All @@ -43,6 +49,54 @@ export const FormScreen = ({

return (
<>
{process.env.NODE_ENV === 'development' && goToScreen && (
<Box marginBottom={2}>
<Inline flexWrap="wrap" space={2}>
<Button
variant="text"
size="small"
onClick={() => goToScreen(Routes.ADVERT)}
>
Grunnupplýsingar
</Button>
<Button
variant="text"
size="small"
onClick={() => goToScreen(Routes.ATTACHMENTS)}
>
Viðaukar og fylgiskjöl
</Button>
<Button
variant="text"
size="small"
onClick={() => goToScreen(Routes.PREVIEW)}
>
Forskoðun
</Button>
<Button
variant="text"
size="small"
onClick={() => goToScreen(Routes.ORIGINAL)}
>
Frumrit
</Button>
<Button
variant="text"
size="small"
onClick={() => goToScreen(Routes.PUBLISHING)}
>
Óskir um birtingu
</Button>
<Button
variant="text"
size="small"
onClick={() => goToScreen(Routes.SUMMARY)}
>
Samantekt
</Button>
</Inline>
</Box>
)}
<Box className={styles.formIntro}>
{(title || button) && (
<Box marginBottom={2} className={styles.titleWrapper}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const classes: EditorClasses = {

editor: style({
position: 'relative',
minHeight: 200,
minHeight: 100,
maxHeight: 'calc(100vh - 10rem)',
width: '100%',
caretColor: theme.color.blue400,
Expand Down
Loading
Loading