diff --git a/apps/service-portal/src/components/Notifications/NotificationButton.tsx b/apps/service-portal/src/components/Notifications/NotificationButton.tsx index 95bd7a20d4f1..82583f47e539 100644 --- a/apps/service-portal/src/components/Notifications/NotificationButton.tsx +++ b/apps/service-portal/src/components/Notifications/NotificationButton.tsx @@ -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(null) - const { data } = useGetUserNotificationsOverviewQuery({ + const { data, refetch } = useGetUserNotificationsOverviewQuery({ variables: { input: { limit: 5, }, + locale: lang, }, }) + useEffect(() => { + refetch() + }, [lang, refetch]) + const showBadge = !!data?.userNotificationsOverview?.unseenCount && !hasMarkedLocally diff --git a/apps/service-portal/src/components/Notifications/NotificationLine.tsx b/apps/service-portal/src/components/Notifications/NotificationLine.tsx index 2e8a14b5aa80..add475d4efff 100644 --- a/apps/service-portal/src/components/Notifications/NotificationLine.tsx +++ b/apps/service-portal/src/components/Notifications/NotificationLine.tsx @@ -51,6 +51,8 @@ export const NotificationLine = ({ data, onClickCallback }: Props) => { ) : undefined} span`, { boxShadow: 'none', }) diff --git a/libs/api/domains/documents/src/lib/documentV2.service.ts b/libs/api/domains/documents/src/lib/documentV2.service.ts index ed368daa8be1..a55b1873eb34 100644 --- a/libs/api/domains/documents/src/lib/documentV2.service.ts +++ b/libs/api/domains/documents/src/lib/documentV2.service.ts @@ -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, diff --git a/libs/api/domains/notifications/src/lib/notifications.resolver.ts b/libs/api/domains/notifications/src/lib/notifications.resolver.ts index 0f4ee313468d..8b9d124e7359 100644 --- a/libs/api/domains/notifications/src/lib/notifications.resolver.ts +++ b/libs/api/domains/notifications/src/lib/notifications.resolver.ts @@ -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' @@ -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, diff --git a/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts b/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts index 738fc7d18d58..cd2b81bc5d19 100644 --- a/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts +++ b/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts @@ -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' @@ -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, diff --git a/libs/api/domains/notifications/src/utils/helpers.ts b/libs/api/domains/notifications/src/utils/helpers.ts index 2e45833e1afe..f8c68345fd92 100644 --- a/libs/api/domains/notifications/src/utils/helpers.ts +++ b/libs/api/domains/notifications/src/utils/helpers.ts @@ -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 => ({ @@ -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, }, diff --git a/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts b/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts index c370bbbb5ef4..dae430067f2a 100644 --- a/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts +++ b/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts @@ -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({ diff --git a/libs/service-portal/documents/src/components/DocumentLine/AvatarImage.tsx b/libs/service-portal/documents/src/components/DocumentLine/AvatarImage.tsx index ac96192dde52..51094f492fc0 100644 --- a/libs/service-portal/documents/src/components/DocumentLine/AvatarImage.tsx +++ b/libs/service-portal/documents/src/components/DocumentLine/AvatarImage.tsx @@ -13,6 +13,8 @@ interface Props { avatar?: ReactNode onClick?: (event: MouseEvent) => void large?: boolean + as?: 'div' | 'button' + imageClass?: string } export const AvatarImage: FC = ({ @@ -20,6 +22,8 @@ export const AvatarImage: FC = ({ background, avatar, large, + imageClass, + as = 'button', onClick, }) => { const { formatMessage } = useLocale() @@ -38,14 +42,24 @@ export const AvatarImage: FC = ({ 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 ) : ( - document + document )} ) diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql index b370a1d97a3d..b3dbcdbf1c08 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -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 { @@ -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 } diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 294bec5bc6cf..7914eaf6defa 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import { Box, Button, @@ -17,7 +17,7 @@ import { } from '@island.is/service-portal/core' import { - useGetUserNotificationsQuery, + useGetUserNotificationsListQuery, useMarkAllNotificationsAsReadMutation, useMarkUserNotificationAsReadMutation, } from './Notifications.generated' @@ -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() @@ -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) @@ -67,6 +72,7 @@ const UserNotifications = () => { before: '', after: cursor, }, + locale: lang, }, updateQuery: (prevResult, { fetchMoreResult }) => { if (