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 | 4x 4x | import React, { useEffect, useState } from 'react';
const styles = require('./Basket.module.css')
import { useTranslation } from 'react-i18next';
import { useCartContext } from '../../contexts';
import { Loading } from 'ag-ems-ui-library';
import { BasketProducts } from './BasketProducts';
import { BasketTotal } from './BasketTotal';
import { BasketCode } from './BasketCode';
export const Basket = () => {
const { t } = useTranslation();
const { positions, loading } = useCartContext();
const [preloader, setPreloader] = useState(false);
useEffect(() => {
console.log('loading cart', loading);
}, [loading]);
return (
<>
<header className={`${styles.BasketHeader}`}>
<h1>{`${t('cart.cart')} ${loading ? '' : `(${positions.length})`}`}</h1>
</header>
<div className={`${styles.Basket}`}>
{(preloader || loading) && <Loading color="#007c00" />}
{positions && positions.length ? (
<>
<BasketTotal button={{ text: t('cart.toPayment'), link: '/checkout' }} />
{/* <BasketCode setPreloader={setPreloader} /> */}
<BasketProducts products={positions} setPreloader={setPreloader} />
</>
) : (
!loading && <p className={styles.BasketText}>{t('cart.emptyText')}</p>
)}
</div>
</>
);
}; |