Skip to content

Commit

Permalink
Merge pull request #218 from NatalyKrvch/refactoring
Browse files Browse the repository at this point in the history
ref
  • Loading branch information
NatalyKrvch authored Mar 7, 2024
2 parents 4f54f12 + 143e0c3 commit e56b11c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/pages/ProductCardPage/ProductCardPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ProductCardPage = () => {
const [currentURL, setCurrentURL] = useState('');
const [show, setShow] = useState(false);
const [orderingData, setOrderingData] = useState('');

const { id } = useParams();
const navigate = useNavigate();
const dispatch = useDispatch();
Expand All @@ -47,16 +48,19 @@ const ProductCardPage = () => {
const productCode = currentProduct.productCode;
const textForShare = `${productName} у магазині Світ світла`;

const handleClose = () => setShow(false);
const handleShow = () => setShow(true);

const dataToSend = {
Customer: orderingData,
Product: productName,
Article: productCode,
}

// implement Email.js function
const allImgsURL = [
currentProduct.productCoverURL || ProductImgPlug,
...currentProduct.productPhotoURL,
];

const handleClose = () => setShow(false);
const handleShow = () => setShow(true);

const sendData = () => {
if (dataToSend) {
Expand All @@ -73,7 +77,7 @@ const ProductCardPage = () => {
userID,
)
.then((response) => {
toast.success("Ваше замовлення успішно надіслано");
toast.success("Ваше замовлення успішно надіслано. Менеджер зконтактує з вами протягом робочого дня");
console.log(
response.status,
response.text,
Expand All @@ -88,7 +92,6 @@ const ProductCardPage = () => {

const handleOrderSubmit = () => {
handleClose();
console.log('orderingData',orderingData)
sendData();
}

Expand All @@ -97,14 +100,9 @@ const ProductCardPage = () => {
setCurrentURL(window.location.href);
window.scrollTo(0, 0);
}, []);

if (currentProduct === null) return;

const allImgsURL = [
currentProduct.productCoverURL || ProductImgPlug,
...currentProduct.productPhotoURL,
];


return (
<Container>
{isLoading ? (
Expand Down

0 comments on commit e56b11c

Please sign in to comment.