Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d6ff225
WS-2008-account-header
SantaZena Jan 26, 2026
595001c
Updating storybook and test files
SantaZena Jan 27, 2026
b2bd0ee
Updating storybook and test files nr2
SantaZena Jan 27, 2026
79a4ac4
Updating styles
SantaZena Jan 27, 2026
d818b76
Updating test
SantaZena Jan 27, 2026
65368d7
Merge branch 'WS-2007-idcta-integration-accountprovider' of github.co…
elvinasv Jan 27, 2026
a7dc537
Merge branch 'WS-2007-idcta-integration-accountprovider' into WS-2008…
elvinasv Jan 27, 2026
4356d8f
refactor: delete old Account Provider
elvinasv Jan 27, 2026
2b850a5
test: fix test
elvinasv Jan 27, 2026
f1804ce
Changing a to text and adding translations
SantaZena Jan 28, 2026
dcc0911
Adding second test
SantaZena Jan 28, 2026
01da157
Update test
SantaZena Jan 28, 2026
bf350dc
Merge branch 'WS-2007-idcta-integration-accountprovider' into WS-2008…
elvinasv Jan 28, 2026
10ed611
Added use() insted of useContext(), added translations for Hindi, upd…
SantaZena Jan 28, 2026
6eba149
Merge branch 'WS-2007-idcta-integration-accountprovider' into WS-2008…
SantaZena Jan 28, 2026
c3ff93b
Correcting from idIdctaAvailable to isIdctaAvailable
SantaZena Jan 28, 2026
38adffe
Merge branch 'WS-2007-idcta-integration-accountprovider' into WS-2008…
SantaZena Jan 29, 2026
f100a9f
Merge branch 'WS-2007-idcta-integration-accountprovider' into WS-2008…
SantaZena Jan 29, 2026
3c0fa84
Adding object parameters
SantaZena Jan 29, 2026
4218832
Story update
SantaZena Jan 29, 2026
3c25708
Updated story with correct spaces
SantaZena Jan 29, 2026
45b4191
Merge branch 'WS-2007-idcta-integration-accountprovider' into WS-2008…
SantaZena Jan 30, 2026
322fc8a
Switch AccountHeader tests to renderer with providers
SantaZena Jan 30, 2026
63710fc
Simplify AccountHeader tests
SantaZena Jan 30, 2026
560359d
Simplify AccountHeader tests nr2
SantaZena Jan 30, 2026
e107e75
Simplify AccountHeader tests nr3
SantaZena Feb 2, 2026
5e8cb9f
Merge branch 'WS-2007-idcta-integration-accountprovider' into WS-2008…
SantaZena Feb 2, 2026
1356f8e
Sign In with capital I
SantaZena Feb 2, 2026
8d0775b
Sign In with capital I in test
SantaZena Feb 2, 2026
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
16 changes: 16 additions & 0 deletions src/app/components/Account/AccountHeader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# AccountHeader

Displays the account entry point in the header.

## Behaviour
- Shows **“Sign in”** when the user is signed out
- Shows **“For you”** when the user is signed in

## Data source
- Uses `AccountContext` to determine signed-in state

## Storybook
- `Signed Out`
- `Signed In`

This is an initial MVP version. Styling and IDCTA integration will follow in later tickets.
34 changes: 34 additions & 0 deletions src/app/components/Account/AccountHeader/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import ThemeProvider from '#app/components/ThemeProvider';
import { ServiceContextProvider } from '#app/contexts/ServiceContext';
import { AccountContext } from '#app/contexts/AccountContext';
import AccountHeader from '.';

type WithProvidersArgs = {
isSignedIn: boolean;
};

Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line creates unnecessary whitespace. Remove this line to maintain consistent code formatting.

Suggested change

Copilot uses AI. Check for mistakes.
const withProviders =
({ isSignedIn }: WithProvidersArgs) =>
() => (
<ThemeProvider service="ws">
<ServiceContextProvider service="ws">
<AccountContext.Provider
value={{
isSignedIn,
signInUrl: 'https://example.com/signin',
forYouUrl: 'https://example.com/for-you',
isIdctaAvailable: true,
}}
>
<AccountHeader />
</AccountContext.Provider>
</ServiceContextProvider>
</ThemeProvider>
);
export default {
title: 'Account/AccountHeader',
component: AccountHeader,
};

export const SignedOut = withProviders({ isSignedIn: false });
export const SignedIn = withProviders({ isSignedIn: true });
22 changes: 22 additions & 0 deletions src/app/components/Account/AccountHeader/index.styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Theme } from '@emotion/react';

const styles = {
wrapper: {
marginInlineStart: 'auto',
width: '100%',
display: 'flex',
justifyContent: 'flex-end',
paddingInlineStart: '1rem',
},

link: ({ palette }: Theme) => ({
color: palette.WHITE,
textDecoration: 'none',

'&:hover, &:focus': {
textDecoration: 'underline',
},
}),
};

export default styles;
52 changes: 52 additions & 0 deletions src/app/components/Account/AccountHeader/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Cookie from 'js-cookie';
import { screen } from '@testing-library/react';
import { render } from '#app/components/react-testing-library-with-providers';
import { IdctaConfig } from '#app/models/types/account';
import AccountHeader from '.';

const idctaConfig: IdctaConfig = {
'id-availability': 'GREEN',
unavailable_url: 'https://example.com/unavailable',
signin_url: 'https://example.com/signin',
register_url: 'https://example.com/register',
settings_url: 'https://example.com/settings',
signout_url: 'https://example.com/signout',
foryou_url: 'https://example.com/foryou',
identity: {
idSignedInCookieName: 'ckns_id',
},
};

const renderWithProviders = () =>
render(<AccountHeader />, {
service: 'ws',
idctaConfig,
});

describe('AccountHeader', () => {
afterEach(() => {
Cookie.remove('ckns_id');
});

it('shows Sign in when signed out', async () => {
renderWithProviders();

const link = await screen.findByRole('link', { name: 'Sign In' });
expect(link).toHaveAttribute(
'href',
expect.stringContaining('https://example.com/signin'),
);
});

it('shows For you when signed in', async () => {
Cookie.set('ckns_id', '1');

renderWithProviders();

const link = await screen.findByRole('link', { name: 'For you' });
expect(link).toHaveAttribute(
'href',
expect.stringContaining('https://example.com/foryou'),
);
});
});
27 changes: 27 additions & 0 deletions src/app/components/Account/AccountHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { use } from 'react';
import { AccountContext } from '#contexts/AccountContext';
import { ServiceContext } from '#contexts/ServiceContext';
import Text from '#app/components/Text';
import styles from './index.styles';

const AccountHeader = () => {
const { isSignedIn, signInUrl, forYouUrl } = use(AccountContext);
const { translations } = use(ServiceContext);

const href = isSignedIn ? forYouUrl : signInUrl;
if (!href) return null;

const label = isSignedIn
? (translations?.account?.forYou ?? 'For you')
: (translations?.account?.signIn ?? 'Sign In');

return (
<div css={styles.wrapper}>
<Text as="a" css={styles.link} href={href}>
{label}
</Text>
</div>
);
};

export default AccountHeader;
4 changes: 4 additions & 0 deletions src/app/lib/config/services/hindi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export const service: DefaultServiceConfig = {
instructions: 'You can download and view today’s news.',
title: 'File Download',
},
account: {
signIn: 'Sign In',
forYou: 'For you',
Comment on lines +106 to +107
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Hindi service configuration contains English text instead of Hindi translations. These should be translated to Hindi (e.g., 'साइन इन' for Sign In and 'आपके लिए' for For you) to match the service language.

Copilot uses AI. Check for mistakes.
},
gist: 'सारांश',
error: {
404: {
Expand Down
4 changes: 4 additions & 0 deletions src/app/lib/config/services/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const service: DefaultServiceConfig = {
title: 'File Download',
},
gist: 'At a glance',
account: {
signIn: 'Sign In',
forYou: 'For you',
},
error: {
404: {
statusCode: '404',
Expand Down
4 changes: 4 additions & 0 deletions src/app/models/types/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface Translations {
title?: string;
};
gist?: string;
account?: {
signIn?: string;
forYou?: string;
};
error: {
home?: string;
currentPage?: string;
Expand Down
Loading