Skip to content

Commit

Permalink
chore(footer): Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Jan 23, 2025
1 parent 95cf5ca commit 3e47db8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
11 changes: 1 addition & 10 deletions client/src/components/footer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import React from 'react';

import SwitchLanguage from '../switch-language';
import useLocalStorage from '../../hooks/useLocalStorage';

export function FooterTop({ children }) {
return <div className="fr-footer__top">{children}</div>;
Expand Down Expand Up @@ -63,8 +62,6 @@ export function FooterBody({
children,
description,
}) {
const [locale, setLocale] = useLocalStorage('works-magnet-locale', 'en');

const languages = [
{ shortName: 'FR', fullName: 'Français', key: 'fr' },
{ shortName: 'EN', fullName: 'English', key: 'en' },
Expand All @@ -86,13 +83,6 @@ export function FooterBody({
{description ? (
<p className="fr-footer__content-desc">{description}</p>
) : null}
{/* <div>
Language:
{' '}
{locale}
<button onClick={() => setLocale('fr')} type="button">Set language FR</button>
<button onClick={() => setLocale('en')} type="button">Set language EN</button>
</div> */}
<SwitchLanguage languages={languages} />
{links.length ? (
<ul className="fr-footer__content-list">
Expand All @@ -107,6 +97,7 @@ export function FooterBody({
</div>
);
}

FooterBody.defaultProps = {
description: undefined,
};
Expand Down
10 changes: 9 additions & 1 deletion client/src/components/switch-language/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import PropTypes from 'prop-types';
import { useId } from 'react';

import useLocalStorage from '../../hooks/useLocalStorage';

export default function SwitchLanguage({ languages }) {
// const { locale, setLocale } = useDSFRConfig();
const id = useId();
const [locale, setLocale] = useLocalStorage('works-magnet-locale', 'en');
const currentLanguage = languages.find(({ key }) => key === locale);
Expand Down Expand Up @@ -53,3 +53,11 @@ export default function SwitchLanguage({ languages }) {
</nav>
);
}

SwitchLanguage.defaultProps = {
languages: [],
};

SwitchLanguage.propTypes = {
languages: PropTypes.array,
};
6 changes: 2 additions & 4 deletions client/src/pages/home.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { Col, Container, Row, Title } from '@dataesr/dsfr-plus';
import { useState } from 'react';
import { FormattedMessage } from 'react-intl';

import DatasetsTile from '../components/tiles/datasets';
Expand All @@ -11,9 +11,7 @@ import Header from '../layout/header';
export default function Home() {
const [isExpanded, setIsExpanded] = useState(false);

const toggleExpand = () => {
setIsExpanded(!isExpanded);
};
const toggleExpand = () => setIsExpanded(!isExpanded);

return (
<>
Expand Down

0 comments on commit 3e47db8

Please sign in to comment.