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

feat: [P4PU-884] footer refactored and TOS and PP available again to unlogged user #251

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 16 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ const router = createBrowserRouter([
element: <AuthCallback />,
loader: ({ request }) => getTokenOneidentity(request)
},
{
path: ArcRoutes.TOS,
element: (
<PreLoginLayout>
<Resources resource="tos" />
</PreLoginLayout>
)
},
{
path: ArcRoutes.PRIVACY_POLICY,
element: (
<PreLoginLayout>
<Resources resource="pp" />
</PreLoginLayout>
)
},
{
path: ArcRoutes.COURTESY_PAGE.replace(':error', ''),
element: <PreLoginLayout />,
Expand Down Expand Up @@ -173,14 +189,6 @@ const router = createBrowserRouter([
}
]
: []),
{
path: ArcRoutes.TOS,
element: <Resources resource="tos" />
},
{
path: ArcRoutes.PRIVACY_POLICY,
element: <Resources resource="pp" />
},
{
path: ArcRoutes.COURTESY_PAGE,
loader: ({ params }) => Promise.resolve(params.error),
Expand Down
1 change: 0 additions & 1 deletion src/components/Footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ i18nTestSetup({});
describe('Footer Component', () => {
it('renders without errors', () => {
render(<Footer />);
expect(screen.getByRole('contentinfo')).toBeInTheDocument();
});

it('uses correct text elements', () => {
Expand Down
197 changes: 45 additions & 152 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,166 +1,59 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import lang from '../translations/lang';
import { Footer as MUIFooter } from '@pagopa/mui-italia';
import { FooterPostLogin, FooterLegal } from '@pagopa/mui-italia';
import { ArcRoutes } from 'routes/routes';
import { useLanguage } from 'hooks/useLanguage';
import './Footer.css';

interface FooterProps {
loggedUser?: boolean;
}
export const Footer = (props: FooterProps) => {
const LINK_PERSONAL_DATA_PROTECTION =
'https://privacyportal-de.onetrust.com/webform/77f17844-04c3-4969-a11d-462ee77acbe1/9ab6533d-be4a-482e-929a-0d8d2ab29df8';

const openExternalLink = (url: string) => window.open(url, '_blank')?.focus();

export const Footer = () => {
const { t } = useTranslation();
const { loggedUser = true } = props;
const { language, changeLanguage } = useLanguage();

return (
<MUIFooter
loggedUser={loggedUser}
companyLink={{ ariaLabel: 'PagoPA SPA' }}
legalInfo={
<>
<b>{t('general.PagoPA')}</b> - {t('ui.footer.legalInfo')}
</>
}
postLoginLinks={[
{
label: t('ui.footer.privacy'),
ariaLabel: t('ui.footer.privacy'),
href: ArcRoutes.PRIVACY_POLICY,
linkType: 'external'
},
{
label: t('ui.footer.personalData'),
ariaLabel: t('ui.footer.personalData'),
linkType: 'external',
href: 'https://privacyportal-de.onetrust.com/webform/77f17844-04c3-4969-a11d-462ee77acbe1/9ab6533d-be4a-482e-929a-0d8d2ab29df8'
},
{
label: t('ui.footer.termsAndConditions'),
ariaLabel: t('ui.footer.termsAndConditions'),
href: ArcRoutes.TOS,
linkType: 'external'
},
{ label: t('aria.a11y'), ariaLabel: t('aria.a11y'), linkType: 'internal' }
]}
preLoginLinks={{
aboutUs: {
links: [
{
label: t('ui.footer.who'),
ariaLabel: t('ui.footer.who'),
linkType: 'internal'
},
{
label: t('ui.footer.pnrr'),
ariaLabel: t('ui.footer.pnrr'),
linkType: 'internal'
},
{
label: t('ui.footer.media'),
ariaLabel: t('ui.footer.media'),
linkType: 'internal'
},
{
label: t('ui.footer.products'),
ariaLabel: t('ui.footer.products'),
linkType: 'internal'
},
{
label: t('ui.footer.workWithUs'),
ariaLabel: t('ui.footer.workWithUs'),
linkType: 'internal'
}
]
},
resources: {
title: t('ui.footer.resources'),
links: [
{
label: t('ui.footer.privacy'),
ariaLabel: t('ui.footer.privacy'),
href: ArcRoutes.PRIVACY_POLICY,

linkType: 'external'
},
{
label: t('ui.footer.terms'),
ariaLabel: t('ui.footer.terms'),
href: ArcRoutes.TOS,
linkType: 'external'
},
{
label: t('ui.footer.certifications'),
ariaLabel: t('ui.footer.certifications'),
linkType: 'internal'
},
{
label: t('ui.footer.security'),
ariaLabel: t('ui.footer.security'),
linkType: 'internal'
},
{
label: t('ui.footer.dataProtectionRights'),
ariaLabel: t('ui.footer.dataProtectionRights'),
linkType: 'internal'
},
{
label: t('ui.footer.cookie'),
ariaLabel: t('ui.footer.cookie'),
linkType: 'internal'
},
{
label: t('ui.footer.transparentCompany'),
ariaLabel: t('ui.footer.transparentCompany'),
linkType: 'internal'
},
{
label: t('ui.footer.dislosurePolicy'),
ariaLabel: t('ui.footer.dislosurePolicy'),
linkType: 'internal'
},
{
label: t('ui.footer.231'),
ariaLabel: t('ui.footer.231'),
linkType: 'internal'
}
]
},
followUs: {
title: t('ui.footer.followUs'),
socialLinks: [
{
icon: 'linkedin',
title: 'Linkedin',
ariaLabel: 'Linkedin'
},
{
icon: 'instagram',
title: 'Instagram',
ariaLabel: 'Instagram'
},
{
icon: 'twitter',
title: 'Twitter',
ariaLabel: 'Twitter'
},
{
icon: 'medium',
title: 'Medium',
ariaLabel: 'Medium'
}
],
links: [
{ label: t('ui.footer.a11y'), ariaLabel: t('ui.footer.a11y'), linkType: 'internal' }
]
<>
<FooterPostLogin
companyLink={{ ariaLabel: 'PagoPA SPA' }}
links={[
{
label: t('ui.footer.privacy'),
ariaLabel: t('ui.footer.privacy'),
href: ArcRoutes.PRIVACY_POLICY,
linkType: 'external',
onClick: () => openExternalLink(ArcRoutes.PRIVACY_POLICY)
},
{
label: t('ui.footer.personalData'),
ariaLabel: t('ui.footer.personalData'),
linkType: 'external',
href: LINK_PERSONAL_DATA_PROTECTION,
onClick: () => openExternalLink(LINK_PERSONAL_DATA_PROTECTION)
},
{
label: t('ui.footer.termsAndConditions'),
ariaLabel: t('ui.footer.termsAndConditions'),
href: ArcRoutes.TOS,
linkType: 'external',
onClick: () => window.open(ArcRoutes.TOS, '_blank')?.focus()
},
{ label: t('aria.a11y'), ariaLabel: t('aria.a11y'), linkType: 'internal' }
]}
currentLangCode={language}
languages={lang}
onLanguageChanged={changeLanguage}
/>
<FooterLegal
content={
<>
<b>{t('general.PagoPA')}</b> - {t('ui.footer.legalInfo')}
</>
}
}}
currentLangCode={language}
languages={lang}
productsJsonUrl="https://selfcare.pagopa.it/assets/products.json"
hideProductsColumn={false}
onLanguageChanged={changeLanguage}
/>
/>
</>
);
};
16 changes: 5 additions & 11 deletions src/routes/Resources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const Resources = (props: Props) => {
const { resource } = props;
const resourceLink =
resource == 'tos'
? 'https://privacyportalde-cdn.onetrust.com/77f17844-04c3-4969-a11d-462ee77acbe1/privacy-notices/draft/3f089590-8e93-4a08-86d4-40387d57cbad.json'
: 'https://privacyportalde-cdn.onetrust.com/77f17844-04c3-4969-a11d-462ee77acbe1/privacy-notices/draft/8f1bdcb7-1b92-4f2f-bb03-43c2ab8bad58.json';
? 'https://privacyportalde-cdn.onetrust.com/77f17844-04c3-4969-a11d-462ee77acbe1/privacy-notices/draft/65d4c60f-2380-4d01-9ce2-0f6711de44b7.json'
: 'https://privacyportalde-cdn.onetrust.com/77f17844-04c3-4969-a11d-462ee77acbe1/privacy-notices/draft/d8bf2ad2-aa7c-47bb-90d6-76baa6501e6a.json';

const divId =
resource == 'tos'
? 'otnotice-3f089590-8e93-4a08-86d4-40387d57cbad'
: 'otnotice-8f1bdcb7-1b92-4f2f-bb03-43c2ab8bad58';
? 'otnotice-65d4c60f-2380-4d01-9ce2-0f6711de44b7'
: 'otnotice-d8bf2ad2-aa7c-47bb-90d6-76baa6501e6a';

useEffect(() => {
OneTrust?.NoticeApi?.Initialized.then(function () {
Expand All @@ -24,13 +24,7 @@ const Resources = (props: Props) => {
}, []);

return (
<Grid
item
display={'flex'}
marginTop={16}
marginBottom={16}
flexWrap={'wrap'}
justifyContent={'center'}>
<Grid item display={'flex'} flexWrap={'wrap'} justifyContent={'center'}>
<Box width={'100%'}>
<Stack textAlign={'center'} justifyContent={'center'} alignItems={'center'} spacing={4}>
<Stack spacing={2} paddingX={1}></Stack>
Expand Down
Loading