Skip to content

Commit 455a90e

Browse files
DOMA-3719 New version of notification
1 parent ffd47aa commit 455a90e

File tree

6 files changed

+54
-38
lines changed

6 files changed

+54
-38
lines changed

apps/condo/domains/common/components/TrackingContext.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ interface IUseTracking {
6767
}
6868

6969
const useTracking: IUseTracking = () => {
70-
const { route } = useRouter()
70+
const router = useRouter()
71+
const route = get(router, 'route', '')
7172
const { trackerInstances, eventProperties, userProperties } = useTrackingContext()
7273

7374
const logEvent = useCallback(({ eventName, eventProperties: localEventProperties = {}, denyDuplicates }: ITrackerLogEventType) => {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React, { useCallback, useEffect } from 'react'
2+
import Router from 'next/router'
3+
import { notification } from 'antd'
4+
import { useIntl } from '@core/next/intl'
5+
import { Button } from '@condo/domains/common/components/Button'
6+
import { useCurrentBuild } from './useCurrentBuild'
7+
import { usePrevious } from './usePrevious'
8+
9+
10+
11+
export function useHotCodeReload (): void {
12+
const intl = useIntl()
13+
const NotificationTitle = intl.formatMessage({ id: 'HotCodeReload.title' })
14+
const NotificationMessage = intl.formatMessage({ id: 'HotCodeReload.message' })
15+
const ButtonLabel = intl.formatMessage({ id: 'HotCodeReload.action' })
16+
17+
const buildId = useCurrentBuild()
18+
const previousBuildId = usePrevious<string>(buildId)
19+
20+
const handleNotificationClose = useCallback(() => {
21+
Router.reload()
22+
}, [])
23+
24+
useEffect(() => {
25+
if (buildId && previousBuildId && previousBuildId !== buildId) {
26+
const btn: React.ReactNode = (
27+
<Button
28+
type={'sberDefaultGradient'}
29+
onClick={handleNotificationClose}
30+
>
31+
{ButtonLabel}
32+
</Button>
33+
)
34+
notification.success({
35+
key: buildId,
36+
btn,
37+
message: NotificationTitle,
38+
description: NotificationMessage,
39+
duration: null,
40+
closeIcon: React.Fragment,
41+
})
42+
}
43+
}, [buildId, previousBuildId, NotificationTitle, NotificationMessage, ButtonLabel, handleNotificationClose])
44+
}

apps/condo/domains/common/hooks/useHotUpdate.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

apps/condo/lang/en/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@
7070
"example.Email": "name@example.org",
7171
"example.Name": "Jon Johnson",
7272
"example.Phone": "+1 (300) 300 22 22",
73-
"HotReload.title": "System update!",
74-
"HotReload.message": "We have updated the system, so this page will now reload",
73+
"HotCodeReload.title": "System update",
74+
"HotCodeReload.message": "We've improved some features, but you'll need to reload the page for the changes to take effect",
75+
"HotCodeReload.action": "Got it, reload",
7576
"ExportAsExcel": "Export to Excel",
7677
"FiltersLabel": "Filters",
7778
"field.AccountNumberShort": "Account Number",

apps/condo/lang/ru/ru.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@
7070
"example.Email": "name@example.org",
7171
"example.Name": "Иванов Сергей",
7272
"example.Phone": "+7 (900) 800 22 22",
73-
"HotReload.title": "Обновление системы!",
74-
"HotReload.message": "Мы обновили систему, поэтому данная страница сейчас перезагрузится",
73+
"HotCodeReload.title": "Обновление системы",
74+
"HotCodeReload.message": "Мы улучшили некоторые функции, но чтобы изменения заработали — страницу нужно перезагрузить",
75+
"HotCodeReload.action": "Понятно, перезагрузить",
7576
"ExportAsExcel": "Выгрузить в Excel",
7677
"FiltersLabel": "Фильтры",
7778
"field.AccountNumberShort": "ЛС",

apps/condo/pages/_app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import JivoSiteWidget from '@condo/domains/common/components/JivoSiteWidget'
4949
import { TasksContextProvider } from '@condo/domains/common/components/tasks/TasksContextProvider'
5050
import { useMiniappTaskUIInterface } from '@condo/domains/common/hooks/useMiniappTaskUIInterface'
5151
import { useTicketExportTaskUIInterface } from '@condo/domains/ticket/hooks/useTicketExportTask'
52-
import { useHotUpdate } from '@condo/domains/common/hooks/useHotUpdate'
52+
import { useHotCodeReload } from '@condo/domains/common/hooks/useHotCodeReload'
5353
import { TASK_STATUS } from '@condo/domains/common/components/tasks'
5454
import { GlobalAppsContainer } from '../domains/miniapp/components/GlobalApps/GlobalAppsContainer'
5555

@@ -151,7 +151,7 @@ const MenuItems: React.FC = () => {
151151

152152
const MyApp = ({ Component, pageProps }) => {
153153
const intl = useIntl()
154-
useHotUpdate()
154+
useHotCodeReload()
155155
dayjs.locale(intl.locale)
156156

157157
const LayoutComponent = Component.container || BaseLayout

0 commit comments

Comments
 (0)