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

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

Merged
merged 27 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c242c18
Fix locale updates. Add cleanstring
thordurhhh Jun 14, 2024
5a25e30
update string clean
thordurhhh Jun 14, 2024
b965cea
Merge branch 'main' into service-portal/notifications-locale-cleanstring
kodiakhq[bot] Jun 14, 2024
6f1509f
Update packagejson
thordurhhh Jun 14, 2024
75b7fca
Merge branch 'service-portal/notifications-locale-cleanstring' of git…
thordurhhh Jun 14, 2024
5af8a26
Merge branch 'main' into service-portal/notifications-locale-cleanstring
kodiakhq[bot] Jun 14, 2024
b727577
Update query
thordurhhh Jun 14, 2024
ae5d56a
Update query
thordurhhh Jun 14, 2024
1a60cbb
Add lang option
thordurhhh Jun 14, 2024
76f5cf0
Test
thordurhhh Jun 14, 2024
895b218
Fix
thordurhhh Jun 14, 2024
f6bda61
Add locale
thordurhhh Jun 14, 2024
332484d
Test name update
thordurhhh Jun 14, 2024
825347c
fix: force generated files
lodmfjord Jun 14, 2024
bf4e3b1
chore: nx format:write update dirty files
andes-it Jun 14, 2024
3e064f5
Merge branch 'main' into service-portal/notifications-locale-cleanstring
thordurhhh Jun 17, 2024
17e5673
Revert test
thordurhhh Jun 17, 2024
2f28224
Remove ff
thordurhhh Jun 18, 2024
b36f87c
fix: hash generated files
lodmfjord Jun 18, 2024
56f72cc
fix(j-s): Null Service Reference (#15247)
gudjong Jun 18, 2024
3b25846
feat(native-app): Notifications final improvements (#15240)
thoreyjona Jun 18, 2024
c6dffb8
feat(consultation-portal): KAM-2522: PowerBI report added (#15251)
karlarnar Jun 18, 2024
fc305bb
fix: hash generated files (#15253)
lodmfjord Jun 18, 2024
266fdd9
fix: remove file
lodmfjord Jun 18, 2024
db50472
Merge branch 'main' into service-portal/notifications-locale-cleanstring
lodmfjord Jun 18, 2024
e9efa7c
Update __config.mjs
thordurhhh Jun 18, 2024
5fe9c24
Merge branch 'main' into service-portal/notifications-locale-cleanstring
kodiakhq[bot] Jun 18, 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
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
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 @@ -32,8 +32,8 @@ fragment NotificationDataFields on Notification {
}
}

query GetUserNotifications($input: NotificationsInput!) {
userNotifications(input: $input) {
query GetUserNotifications($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 Down Expand Up @@ -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 @@ -54,9 +54,14 @@ const UserNotifications = () => {
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
Loading