import * as React from 'react';
import { Disclosure } from '@usercentrics/cmp-browser-sdk';
import { Icon } from '../../components/Icon';
import { useUsercentrics } from '../../contexts/UsercentricsContext';
const Item = ({
title,
children,
}: React.PropsWithChildren<{
title: string;
}>) => {
return (
{title}:
{children}
);
};
type Props = {
disclosures: Disclosure[];
};
export const StoredInformation = ({ disclosures }: Props): JSX.Element => {
const { settings, settingsLabels } = useUsercentrics();
const [isOpen, setIsOpen] = React.useState(false);
const toggle = () => setIsOpen(!isOpen);
if (!settings || disclosures.length === 0) {
return <>>;
}
const labels = settingsLabels?.cookieInformation;
return (
{labels?.storedInformation}
{isOpen &&
disclosures.map((disclosure, index) => {
const durationInMonth = disclosure.maxAgeSeconds
? Math.floor(disclosure.maxAgeSeconds / (60 * 60 * 24 * 30))
: 0;
return (
{disclosure.name}
{disclosure.description}
- {`${durationInMonth} ${
durationInMonth > 1 ? labels?.months : labels?.month
}`}
- {disclosure.type}
);
})}
);
};