Skip to content

Commit db5b381

Browse files
Fix/reported bugs fixing (#425)
* fix(notification-list): update notification title rendering to use link component * fix(ticket-list, notification-list): update rendering of titles * fix(ticket-details): update translation for ticket status 'OPEN' * style(ticket-details): update card background color and add new card-light variable * fix(service-details): update page IDs for service details in mocks * style(notification-list, ticket-list): add text truncation and alignment to button components * fix(filters): change flex direction to flex-col-reverse on mobile * feat(toggle-group): enhance ToggleGroupItem to support icons * fix(order-list): add missing status options in filters * chore(package-lock): update package versions to latest releases * feat(header): add sign-in button to desktop and mobile navigation based on user authentication state * feat(header): added sign-in label into desktop and mobile navigation components * refactor(Header): add shouldIncludeSignInButton prop to control sign-in button visibility * chore: restore @o2s/lint-staged-config in package-lock.json * chore: updating changelog --------- Co-authored-by: Marcin Krasowski <marcin.krasowski@hycom.pl>
1 parent fd6a271 commit db5b381

File tree

27 files changed

+166
-40
lines changed

27 files changed

+166
-40
lines changed

.changeset/gentle-eggs-report.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@o2s/integrations.contentful-cms': minor
3+
'@o2s/blocks.notification-list': minor
4+
'@o2s/integrations.strapi-cms': minor
5+
'@o2s/blocks.orders-summary': minor
6+
'@o2s/blocks.ticket-details': minor
7+
'@o2s/integrations.mocked': minor
8+
'@o2s/blocks.ticket-list': minor
9+
'@o2s/framework': minor
10+
'@o2s/frontend': minor
11+
'@o2s/ui': minor
12+
---
13+
14+
fixing various bugs related with blocks and ui components, adding sign-in button in navigation

apps/frontend/src/app/[locale]/(auth)/login/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default async function LoginPage({ params }: Readonly<Props>) {
9999
<body>
100100
<GlobalProvider config={init} labels={init.labels} locale={locale} themes={init.themes}>
101101
<div className="flex flex-col min-h-dvh">
102-
<Header data={init.common.header} />
102+
<Header data={init.common.header} shouldIncludeSignInButton={false} />
103103
<div className="flex flex-col grow">
104104
<AuthLayout>
105105
<SignInForm

apps/frontend/src/containers/Header/DesktopNavigation/DesktopNavigation.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use client';
22

3+
import { useSession } from 'next-auth/react';
34
import React from 'react';
45

56
import { Models } from '@o2s/framework/modules';
67

78
import { cn } from '@o2s/ui/lib/utils';
89

10+
import { Button } from '@o2s/ui/elements/button';
911
import {
1012
NavigationMenu,
1113
NavigationMenuContent,
@@ -19,6 +21,7 @@ import { Separator } from '@o2s/ui/elements/separator';
1921
import { Typography } from '@o2s/ui/elements/typography';
2022

2123
import { Link as NextLink, usePathname } from '@/i18n';
24+
import { LOGIN_PATH } from '@/i18n/routing';
2225

2326
import { DesktopNavigationProps } from './DesktopNavigation.types';
2427

@@ -29,9 +32,16 @@ export function DesktopNavigation({
2932
notificationSlot,
3033
userSlot,
3134
items,
35+
signInLabel,
36+
shouldIncludeSignInButton = true,
3237
}: DesktopNavigationProps) {
38+
const session = useSession();
39+
const isSignedIn = !!session.data?.user;
3340
const pathname = usePathname();
3441

42+
// Show sign in button if user is not signed in, container allows it, and signInLabel is available
43+
const showSignInButton = shouldIncludeSignInButton && !isSignedIn && signInLabel;
44+
3545
const activeNavigationGroup = items.find((item) => {
3646
if (item.__typename === 'NavigationGroup') {
3747
return item.items
@@ -174,6 +184,13 @@ export function DesktopNavigation({
174184
{/* Language Selector */}
175185
{localeSlot}
176186

187+
{/* Sign In Button */}
188+
{showSignInButton && (
189+
<Button asChild variant="tertiary">
190+
<NextLink href={LOGIN_PATH}>{signInLabel}</NextLink>
191+
</Button>
192+
)}
193+
177194
{/* Notification Button */}
178195
{notificationSlot}
179196

apps/frontend/src/containers/Header/DesktopNavigation/DesktopNavigation.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ export interface DesktopNavigationProps {
99
notificationSlot?: ReactNode;
1010
userSlot?: ReactNode;
1111
items: CMS.Model.Header.Header['items'];
12+
signInLabel?: CMS.Model.Header.Header['signInLabel'];
13+
shouldIncludeSignInButton?: boolean;
1214
}

apps/frontend/src/containers/Header/Header.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import { MobileNavigation } from './MobileNavigation/MobileNavigation';
2020
import { NotificationInfo } from './NotificationInfo/NotificationInfo';
2121
import { UserInfo } from './UserInfo/UserInfo';
2222

23-
export const Header: React.FC<HeaderProps> = ({ data, alternativeUrls, children }) => {
23+
export const Header: React.FC<HeaderProps> = ({
24+
data,
25+
alternativeUrls,
26+
children,
27+
shouldIncludeSignInButton = true,
28+
}) => {
2429
const session = useSession();
2530
const isSignedIn = !!session.data?.user;
2631

@@ -82,6 +87,8 @@ export const Header: React.FC<HeaderProps> = ({ data, alternativeUrls, children
8287
notificationSlot={NotificationSlot}
8388
userSlot={UserSlot}
8489
items={data.items}
90+
signInLabel={data.signInLabel}
91+
shouldIncludeSignInButton={shouldIncludeSignInButton}
8592
/>
8693
</div>
8794
<div className="md:hidden">
@@ -94,6 +101,8 @@ export const Header: React.FC<HeaderProps> = ({ data, alternativeUrls, children
94101
items={data.items}
95102
title={data.title}
96103
mobileMenuLabel={data.mobileMenuLabel}
104+
signInLabel={data.signInLabel}
105+
shouldIncludeSignInButton={shouldIncludeSignInButton}
97106
/>
98107
</div>
99108
</>

apps/frontend/src/containers/Header/Header.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export interface HeaderProps {
88
alternativeUrls?: {
99
[key: string]: string;
1010
};
11+
shouldIncludeSignInButton?: boolean;
1112
}

apps/frontend/src/containers/Header/MobileNavigation/MobileNavigation.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { Menu, X } from 'lucide-react';
4+
import { useSession } from 'next-auth/react';
45
import React, { useEffect, useState } from 'react';
56

67
import { Models } from '@o2s/framework/modules';
@@ -16,6 +17,7 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@o2s
1617
import { Typography } from '@o2s/ui/elements/typography';
1718

1819
import { Link as NextLink, usePathname } from '@/i18n';
20+
import { LOGIN_PATH } from '@/i18n/routing';
1921

2022
import { MobileNavigationProps } from './MobileNavigation.types';
2123

@@ -28,9 +30,16 @@ export function MobileNavigation({
2830
items,
2931
title,
3032
mobileMenuLabel,
33+
signInLabel,
34+
shouldIncludeSignInButton = true,
3135
}: MobileNavigationProps) {
36+
const session = useSession();
37+
const isSignedIn = !!session.data?.user;
3238
const pathname = usePathname();
3339

40+
// Show sign in button if user is not signed in, container allows it, and signInLabel is available
41+
const showSignInButton = shouldIncludeSignInButton && !isSignedIn && signInLabel;
42+
3443
const [isMenuOpen, setIsMenuOpen] = useState(false);
3544

3645
useEffect(() => {
@@ -108,6 +117,13 @@ export function MobileNavigation({
108117

109118
{/* Right Section */}
110119
<div className="flex gap-4">
120+
{/* Sign In Button */}
121+
{showSignInButton && (
122+
<Button asChild variant="tertiary">
123+
<NextLink href={LOGIN_PATH}>{signInLabel}</NextLink>
124+
</Button>
125+
)}
126+
111127
{/* Notification Button */}
112128
{notificationSlot}
113129

apps/frontend/src/containers/Header/MobileNavigation/MobileNavigation.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ export interface MobileNavigationProps {
1111
items: CMS.Model.Header.Header['items'];
1212
title?: CMS.Model.Header.Header['title'];
1313
mobileMenuLabel: CMS.Model.Header.Header['mobileMenuLabel'];
14+
signInLabel?: CMS.Model.Header.Header['signInLabel'];
15+
shouldIncludeSignInButton?: boolean;
1416
}

apps/frontend/src/i18n/routing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { defineRouting } from 'next-intl/routing';
33

44
export const DEFAULT_LOCALE = process.env.NEXT_PUBLIC_DEFAULT_LOCALE as string;
55
export const SUPPORTED_LOCALES = process.env.NEXT_PUBLIC_SUPPORTED_LOCALES?.split(',') ?? [];
6+
export const LOGIN_PATH = '/login';
67

78
export const routing = defineRouting({
89
locales: SUPPORTED_LOCALES,
910
defaultLocale: DEFAULT_LOCALE,
1011
pathnames: {
11-
'/login': {
12+
[LOGIN_PATH]: {
1213
en: '/sign-in',
1314
de: '/einloggen',
1415
pl: '/logowanie',

packages/blocks/notification-list/src/frontend/NotificationList.client.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ export const NotificationListPure: React.FC<NotificationListPureProps> = ({
8585
case 'title':
8686
return {
8787
...column,
88-
type: 'text',
89-
cellClassName: (notification: Model.Notification) =>
90-
cn('max-w-[200px] lg:max-w-md', notification.status.value === 'UNVIEWED' && 'font-semibold'),
88+
type: 'custom',
89+
cellClassName: 'max-w-[200px] lg:max-w-md',
90+
render: (_value: unknown, notification: Model.Notification) => (
91+
<Button asChild variant="link" size="none" className="truncate block text-left">
92+
<LinkComponent href={notification.detailsUrl}>{notification.title}</LinkComponent>
93+
</Button>
94+
),
9195
};
9296
case 'type':
9397
return {

0 commit comments

Comments
 (0)