Skip to content

Commit

Permalink
fix(service-portal): Documents dl url & notifications api - hotfix (#…
Browse files Browse the repository at this point in the history
…15255)

* fix(documents-v2): Add download URL to detail document v2 (#15194)

* fix(service-portal): Update notification icon styling (#15219)

* Update notification icon styling

* Add option to remove button docline

* fix(service-portal): Notifications - locale updates. Add cleanstring (#15239)

* Fix locale updates. Add cleanstring

* update string clean

* Update packagejson

* Update query

* Update query

* Add lang option

* Test

* Fix

* Add locale

* Test name update

* fix: force generated files

* chore: nx format:write update dirty files

* Revert test

* Remove ff

* fix: hash generated files

* fix(j-s): Null Service Reference (#15247)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(native-app): Notifications final improvements (#15240)

* feat: buttons at top should not be sticky

* feat: add empty state for notifications

* fix: make sure to update unreadCount in inbox when fetching next page

* feat: add fallback icon for notifications

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(consultation-portal): KAM-2522: PowerBI report added (#15251)

* fix: hash generated files (#15253)

* fix: hash generated files

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <builders@andes.is>

* fix: remove file

* Update __config.mjs

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: lommi <jonorn@gmail.com>
Co-authored-by: andes-it <builders@andes.is>
Co-authored-by: Guðjón Guðjónsson <gudjon@kolibri.is>
Co-authored-by: Þórey Jóna <thoreyjona@gmail.com>
Co-authored-by: Karl Arnar Ægisson <korsbacka@gmail.com>

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: lommi <jonorn@gmail.com>
Co-authored-by: andes-it <builders@andes.is>
Co-authored-by: Guðjón Guðjónsson <gudjon@kolibri.is>
Co-authored-by: Þórey Jóna <thoreyjona@gmail.com>
Co-authored-by: Karl Arnar Ægisson <korsbacka@gmail.com>
  • Loading branch information
7 people authored Jun 18, 2024
1 parent c18f4c6 commit 2586497
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@ const NotificationButton = ({
showMenu = false,
disabled,
}: Props) => {
const { formatMessage } = useLocale()
const { formatMessage, lang } = useLocale()
const [hasMarkedLocally, setHasMarkedLocally] = useState(false)
const [markAllAsSeen] = useMarkAllNotificationsAsSeenMutation()
const { width } = useWindowSize()
const isMobile = width < theme.breakpoints.md
const ref = useRef<HTMLButtonElement>(null)

const { data } = useGetUserNotificationsOverviewQuery({
const { data, refetch } = useGetUserNotificationsOverviewQuery({
variables: {
input: {
limit: 5,
},
locale: lang,
},
})

useEffect(() => {
refetch()
}, [lang, refetch])

const showBadge =
!!data?.userNotificationsOverview?.unseenCount && !hasMarkedLocally

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const NotificationLine = ({ data, onClickCallback }: Props) => {
<AvatarImage
img={data.sender.logoUrl}
background={!isRead ? 'white' : 'blue100'}
as="div"
imageClass={styles.img}
/>
) : undefined}
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export const link = style({
overflow: 'hidden',
})

export const img = style({
height: 'auto',
width: 'auto',
display: 'flex',
maxHeight: 28,
maxWidth: 28,
})

globalStyle(`${link} > span`, {
boxShadow: 'none',
})
Expand Down
1 change: 1 addition & 0 deletions libs/api/domains/documents/src/lib/documentV2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class DocumentServiceV2 {
publicationDate: document.date,
id: documentId,
name: document.fileName,
downloadUrl: `${this.downloadServiceConfig.baseUrl}/download/v1/electronic-documents/${documentId}`,
sender: {
id: document.senderNationalId,
name: document.senderName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from './notifications.model'
import type { Locale } from '@island.is/shared/types'
import { LOGGER_PROVIDER, type Logger } from '@island.is/logging'
import { FeatureFlag, Features } from '@island.is/nest/feature-flags'

const LOG_CATEGORY = 'notifications-resolver'
export const AUDIT_NAMESPACE = 'notifications-resolver'
Expand All @@ -22,7 +21,6 @@ export const AUDIT_NAMESPACE = 'notifications-resolver'
@Resolver()
@Audit({ namespace: AUDIT_NAMESPACE })
@Scopes(DocumentsScope.main)
@FeatureFlag(Features.ServicePortalNotificationsEnabled)
export class NotificationsResolver {
constructor(
private readonly service: NotificationsService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import type { Locale } from '@island.is/shared/types'
import { LOGGER_PROVIDER, type Logger } from '@island.is/logging'
import { Loader } from '@island.is/nest/dataloader'
import { AUDIT_NAMESPACE } from './notifications.resolver'
import { FeatureFlag, Features } from '@island.is/nest/feature-flags'
import { DocumentsScope } from '@island.is/auth/scopes'

const LOG_CATEGORY = 'notification-list-resolver'
Expand All @@ -35,7 +34,6 @@ const LOG_CATEGORY = 'notification-list-resolver'
@Resolver(() => NotificationsResponse)
@Audit({ namespace: AUDIT_NAMESPACE })
@Scopes(DocumentsScope.main)
@FeatureFlag(Features.ServicePortalNotificationsEnabled)
export class NotificationsListResolver {
constructor(
private readonly service: NotificationsService,
Expand Down
17 changes: 13 additions & 4 deletions libs/api/domains/notifications/src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { RenderedNotificationDto } from '@island.is/clients/user-notification'
import { Notification } from '../lib/notifications.model'

const cleanString = (str?: string) => {
if (!str) {
return ''
}
return str.replace(/\s+/g, ' ').trim()
}

export const notificationMapper = (
notification: RenderedNotificationDto,
): Notification => ({
Expand All @@ -20,10 +27,12 @@ export const notificationMapper = (
nationalId: undefined,
},
message: {
title: notification.title,
body: notification.body,
dataCopy: notification.dataCopy,
displayBody: notification.dataCopy ?? notification.body,
title: cleanString(notification.title),
body: cleanString(notification.body),
dataCopy: notification.dataCopy
? cleanString(notification.dataCopy)
: undefined,
displayBody: cleanString(notification.dataCopy ?? notification.body),
link: {
url: notification.clickActionUrl,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ export const avatar = style({
})

export const circleImg = style({
width: '28px',
height: 'auto',
width: 'auto',
display: 'flex',
maxHeight: 38,
maxWidth: 38,
})

export const button = style({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ interface Props {
avatar?: ReactNode
onClick?: (event: MouseEvent<HTMLElement>) => void
large?: boolean
as?: 'div' | 'button'
imageClass?: string
}

export const AvatarImage: FC<Props> = ({
img,
background,
avatar,
large,
imageClass,
as = 'button',
onClick,
}) => {
const { formatMessage } = useLocale()
Expand All @@ -38,14 +42,24 @@ export const AvatarImage: FC<Props> = ({
className={cn(styles.imageContainer, {
[styles.largeAvatar]: large,
})}
component="button"
aria-label={formatMessage(messages.markAsBulkSelection)}
component={as}
aria-label={
as === 'button'
? formatMessage(messages.markAsBulkSelection)
: undefined
}
onClick={onClick}
>
{avatar ? (
avatar
) : (
<img className={styles.image} src={img} alt="document" />
<img
className={cn(styles.image, {
[`${imageClass}`]: imageClass,
})}
src={img}
alt="document"
/>
)}
</Box>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ fragment NotificationDataFields on Notification {
}
}

query GetUserNotifications($input: NotificationsInput!) {
userNotifications(input: $input) {
query GetUserNotificationsList($input: NotificationsInput!, $locale: String) {
userNotifications(input: $input, locale: $locale) {
data {
...NotificationDataFields
recipient {
Expand All @@ -52,8 +52,11 @@ query GetUserNotifications($input: NotificationsInput!) {
}
}

query GetUserNotificationsOverview($input: NotificationsInput!) {
userNotificationsOverview: userNotifications(input: $input) {
query GetUserNotificationsOverview(
$input: NotificationsInput!
$locale: String
) {
userNotificationsOverview: userNotifications(input: $input, locale: $locale) {
data {
...NotificationDataFields
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useEffect, useState } from 'react'
import {
Box,
Button,
Expand All @@ -17,7 +17,7 @@ import {
} from '@island.is/service-portal/core'

import {
useGetUserNotificationsQuery,
useGetUserNotificationsListQuery,
useMarkAllNotificationsAsReadMutation,
useMarkUserNotificationAsReadMutation,
} from './Notifications.generated'
Expand All @@ -32,7 +32,7 @@ const DEFAULT_PAGE_SIZE = 5

const UserNotifications = () => {
useNamespaces('sp.information-notifications')
const { formatMessage } = useLocale()
const { formatMessage, lang } = useLocale()
const [loadingMore, setLoadingMore] = useState(false)

const [postMarkAsRead] = useMarkUserNotificationAsReadMutation()
Expand All @@ -47,16 +47,21 @@ const UserNotifications = () => {
})

const { data, loading, error, refetch, fetchMore } =
useGetUserNotificationsQuery({
useGetUserNotificationsListQuery({
variables: {
input: {
limit: DEFAULT_PAGE_SIZE,
before: '',
after: '',
},
locale: lang,
},
})

useEffect(() => {
refetch()
}, [refetch, lang])

const loadMore = (cursor: string) => {
if (loadingMore) return
setLoadingMore(true)
Expand All @@ -67,6 +72,7 @@ const UserNotifications = () => {
before: '',
after: cursor,
},
locale: lang,
},
updateQuery: (prevResult, { fetchMoreResult }) => {
if (
Expand Down

0 comments on commit 2586497

Please sign in to comment.