diff --git a/Lab5/Bookfill/src/components/directions/Direction.jsx b/Lab5/Bookfill/src/components/directions/Direction.jsx new file mode 100644 index 0000000..1756c19 --- /dev/null +++ b/Lab5/Bookfill/src/components/directions/Direction.jsx @@ -0,0 +1,29 @@ +import PropTypes from 'prop-types'; +import { Heart } from 'react-bootstrap-icons'; +import '../lines/table/LinesTableRow.css'; + +const Direction = ({ index, line, onAddCart }) => { + const handleAnchorClick = (event, action) => { + event.preventDefault(); + action(); + }; + return ( + + {index + 1} + {line.book_name} + {line.type.name} + {line.author_name} + {parseFloat(line.price).toFixed(2)} + {line.book_name} + handleAnchorClick(event, onAddCart)}> + + ); +}; + +Direction.propTypes = { + index: PropTypes.number, + line: PropTypes.object, + onAddCart: PropTypes.func, +}; + +export default Direction; diff --git a/Lab5/Bookfill/src/components/directions/Directions.jsx b/Lab5/Bookfill/src/components/directions/Directions.jsx new file mode 100644 index 0000000..5c69f28 --- /dev/null +++ b/Lab5/Bookfill/src/components/directions/Directions.jsx @@ -0,0 +1,45 @@ +import { useState } from 'react'; +import TableDirect from './TableDirect.jsx'; +import Select from '../input/Select.jsx'; +import Direction from './Direction.jsx'; +import useLines from '../lines/hooks/LinesHook'; +import useCart from '../cart/CartHook'; +import Input from '../input/Input.jsx'; +import useTypeFilter from '../lines/hooks/LinesFilterHook'; + +const Directions = () => { + const { types, currentFilter, handleFilterChange } = useTypeFilter(); + const { lines } = useLines(currentFilter); + const [searchValue, setSearchValue] = useState(''); + const { addToCart } = useCart(); + + return ( + <> +
+ setSearchValue(e.target.value)} + type='text' required /> +