All files / src/components/Profile LeftMenu.tsx

28.57% Statements 2/7
0% Branches 0/8
0% Functions 0/2
28.57% Lines 2/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46  4x                 4x                                                                      
import React, { FC } from 'react';
const styles = require('./Profile.module.css')
import { LocalizedLink as Link } from 'gatsby-theme-i18n';
import { useTranslation } from 'react-i18next';
import { useUserContext } from '../../contexts';
import { ProfilePage } from './types';
 
export const LeftMenu: FC<{
  classes?: string;
  current?: ProfilePage;
}> = ({ classes, current }) => {
  const { t } = useTranslation();
  const { signout } = useUserContext();
 
  const logout = () => {
    signout();
  };
 
  return (
    <div className={`${styles.ProfileMenu} ${classes ?? ''}`}>
      <ul className={styles.ProfileMenuList}>
        <li>
          <Link
            className={`${styles.ProfileMenuItem} ${current === 'profile' ? styles.current : ''}`}
            to="/profile"
          >{t('profile.myData')}</Link>
        </li>
        <li>
          <Link
            className={`${styles.ProfileMenuItem} ${current === 'addresses' ? styles.current : ''}`}
            to="/profile/addresses"
          >{t('profile.myAddresses')}</Link>
        </li>
        <li>
          <Link
            className={`${styles.ProfileMenuItem} ${current === 'orders' ? styles.current : ''}`}
            to="/profile/orders"
          >{t('profile.myOrders')}</Link>
        </li>
        <li>
          <button className={styles.ProfileMenuItem} type="button" onClick={logout}>{t('logout')}</button>
        </li>
      </ul>
    </div>
  );
};