diff --git a/frontend/src/features/admin-form/common/components/AdminFormNavbar/AdminFormNavbar.tsx b/frontend/src/features/admin-form/common/components/AdminFormNavbar/AdminFormNavbar.tsx
index d5ae273f5f..6c3bbae6cd 100644
--- a/frontend/src/features/admin-form/common/components/AdminFormNavbar/AdminFormNavbar.tsx
+++ b/frontend/src/features/admin-form/common/components/AdminFormNavbar/AdminFormNavbar.tsx
@@ -5,6 +5,7 @@ import {
BiShow,
BiUserPlus,
} from 'react-icons/bi'
+import { GoPrimitiveDot } from 'react-icons/go'
import { Link as ReactLink, useLocation } from 'react-router-dom'
import {
Box,
@@ -18,6 +19,7 @@ import {
Flex,
Grid,
GridItem,
+ Icon,
Skeleton,
Text,
useBreakpointValue,
@@ -25,6 +27,7 @@ import {
} from '@chakra-ui/react'
import format from 'date-fns/format'
+import { SeenFlags } from '~shared/types'
import { AdminFormDto } from '~shared/types/form/form'
import {
@@ -40,6 +43,11 @@ import IconButton from '~components/IconButton'
import Tooltip from '~components/Tooltip'
import { NavigationTab, NavigationTabList } from '~templates/NavigationTabs'
+import { SeenFlagsMapVersion } from '~features/user/constants'
+import { useUserMutations } from '~features/user/mutations'
+import { useUser } from '~features/user/queries'
+import { getShowFeatureFlagLastSeen } from '~features/user/utils'
+
import { AdminFormNavbarBreadcrumbs } from './AdminFormNavbarBreadcrumbs'
export interface AdminFormNavbarProps {
@@ -68,6 +76,13 @@ export const AdminFormNavbar = ({
const { isOpen, onClose, onOpen } = useDisclosure()
const { pathname } = useLocation()
+ const { user, isLoading: isUserLoading } = useUser()
+ const { updateLastSeenFlagMutation } = useUserMutations()
+ const shouldShowSettingsReddot = useMemo(() => {
+ if (isUserLoading || !user) return false
+ return getShowFeatureFlagLastSeen(user, SeenFlags.SettingsNotification)
+ }, [isUserLoading, user])
+
const tabResponsiveVariant = useBreakpointValue({
base: 'line-dark',
xs: 'line-dark',
@@ -171,8 +186,25 @@ export const AdminFormNavbar = ({
hidden={viewOnly}
to={ADMINFORM_SETTINGS_SUBROUTE}
isActive={checkTabActive(ADMINFORM_SETTINGS_SUBROUTE)}
+ onClick={() => {
+ if (shouldShowSettingsReddot) {
+ updateLastSeenFlagMutation.mutate({
+ flag: SeenFlags.SettingsNotification,
+ version: SeenFlagsMapVersion[SeenFlags.SettingsNotification],
+ })
+ }
+ }}
>
Settings
+ {shouldShowSettingsReddot ? (
+
+ ) : null}
JSX.Element
path: string
showRedDot?: boolean
- onClick?: () => void
}
export const SettingsPage = (): JSX.Element => {
const { formId, settingsTab } = useParams()
const { data: settings } = useAdminFormSettings()
- const { user, isLoading: isUserLoading } = useUser()
- const { updateLastSeenFlagMutation } = useUserMutations()
- const shouldShowSettingsEmailNotiReddot = useMemo(() => {
- if (isUserLoading || !user) return false
- return getShowFeatureFlagLastSeen(user, SeenFlags.SettingsEmailNotification)
- }, [isUserLoading, user])
if (!formId) throw new Error('No formId provided')
@@ -81,16 +69,7 @@ export const SettingsPage = (): JSX.Element => {
icon: BiMailSend,
component: SettingsEmailsPage,
path: 'email-notifications',
- showRedDot: shouldShowSettingsEmailNotiReddot,
- onClick: () => {
- if (shouldShowSettingsEmailNotiReddot) {
- updateLastSeenFlagMutation.mutate({
- flag: SeenFlags.SettingsEmailNotification,
- version:
- SeenFlagsMapVersion[SeenFlags.SettingsEmailNotification],
- })
- }
- },
+ showRedDot: true,
}
: null
@@ -129,11 +108,7 @@ export const SettingsPage = (): JSX.Element => {
]
return baseConfig.filter(isNonEmpty)
- }, [
- settings?.responseMode,
- shouldShowSettingsEmailNotiReddot,
- updateLastSeenFlagMutation,
- ])
+ }, [settings?.responseMode])
const { ref, onMouseDown } = useDraggable()
@@ -157,7 +132,7 @@ export const SettingsPage = (): JSX.Element => {
index={tabIndex === -1 ? 0 : tabIndex}
onChange={(index) => {
handleTabChange(index)
- tabConfig[index].onClick?.()
+ tabConfig[index]
}}
>
{
key={tab.label}
label={tab.label}
icon={tab.icon}
- showRedDot={tab.showRedDot}
+ showNewBadge={tab.showRedDot}
/>
))}
diff --git a/frontend/src/features/admin-form/settings/components/SettingsTab.tsx b/frontend/src/features/admin-form/settings/components/SettingsTab.tsx
index 7d7c28e267..414d440334 100644
--- a/frontend/src/features/admin-form/settings/components/SettingsTab.tsx
+++ b/frontend/src/features/admin-form/settings/components/SettingsTab.tsx
@@ -1,32 +1,29 @@
-import { GoPrimitiveDot } from 'react-icons/go'
import { As, Box, Icon, Tab } from '@chakra-ui/react'
+import Badge from '~components/Badge'
+
export interface SettingsTabProps {
label: string
icon: As
- showRedDot?: boolean
+ showNewBadge?: boolean
}
export const SettingsTab = ({
label,
icon,
- showRedDot,
+ showNewBadge = false,
}: SettingsTabProps): JSX.Element => {
return (
- {showRedDot ? (
-
- ) : null}
{label}
+ {showNewBadge ? (
+
+ New
+
+ ) : null}
)
}
diff --git a/frontend/src/features/user/constants.ts b/frontend/src/features/user/constants.ts
index 25fe0146f1..10876206f7 100644
--- a/frontend/src/features/user/constants.ts
+++ b/frontend/src/features/user/constants.ts
@@ -8,6 +8,6 @@ const LegacySeenFlags = {
export const SeenFlagsMapVersion: { [key in SeenFlags]: number } = {
...LegacySeenFlags,
- [SeenFlags.SettingsEmailNotification]: 0, // stub
- [SeenFlags.CreateBuilderMrfWorkflow]: 0, // stub
+ [SeenFlags.SettingsNotification]: 0,
+ [SeenFlags.CreateBuilderMrfWorkflow]: 0,
}
diff --git a/frontend/src/templates/NavigationTabs/NavigationTab.tsx b/frontend/src/templates/NavigationTabs/NavigationTab.tsx
index a949f7e806..dad73ab0aa 100644
--- a/frontend/src/templates/NavigationTabs/NavigationTab.tsx
+++ b/frontend/src/templates/NavigationTabs/NavigationTab.tsx
@@ -7,6 +7,7 @@ const Link = chakra(ReactLink)
interface NavigationTabProps extends ComponentProps {
isActive?: boolean
isDisabled?: boolean
+ showReddot?: boolean
}
/** Must be nested inside NavigationTabList component, uses styles provided by that component. */
diff --git a/shared/types/user.ts b/shared/types/user.ts
index eebf900f97..23e8c855e3 100644
--- a/shared/types/user.ts
+++ b/shared/types/user.ts
@@ -7,7 +7,7 @@ export type UserId = Tagged
export enum SeenFlags {
LastSeenFeatureUpdateVersion = 'lastSeenFeatureUpdateVersion',
- SettingsEmailNotification = 'settingsEmailNotification',
+ SettingsNotification = 'settingsNotification',
CreateBuilderMrfWorkflow = 'createBuilderMrfWorkflow',
}