import React, { useContext, useEffect, useState } from "react"; import { Helmet } from "react-helmet-async"; import Form from "react-bootstrap/Form"; import Button from "react-bootstrap/Button"; import Container from "react-bootstrap/Container"; import { useNavigate } from "react-router-dom"; import { Store } from "../Store"; import CheckoutSteps from "../components/CheckoutSteps"; function ShippingAddressScreen() { const navigate = useNavigate(); const { state, dispatch: ctxDispatch } = useContext(Store); const { userInfo, cart: { shippingAddress }, } = state; const [fullName, setFullName] = useState(shippingAddress.fullName || ""); const [address, setAddress] = useState(shippingAddress.address || ""); const [city, setCity] = useState(shippingAddress.city || ""); const [postalCode, setPostalCode] = useState( shippingAddress.postalCode || "" ); const [country, setCountry] = useState(shippingAddress.country || ""); useEffect(() => { if (!userInfo) { navigate("/signin"); } }, [userInfo, navigate]); const submitHandler = (e) => { e.preventDefault(); ctxDispatch({ type: "SAVE_SHIPPING_ADDRESS", payload: { fullName, address, city, postalCode, country, }, }); localStorage.setItem( "shippingAddress", JSON.stringify({ fullName, address, city, postalCode, country, }) ); navigate("/payment"); }; return (
Адреса

Адреса

Име и Презиме setFullName(e.target.value)} required > Адреса setAddress(e.target.value)} required > Град setCity(e.target.value)} required > Поштенски код setPostalCode(e.target.value)} required > Држава setCountry(e.target.value)} required >
); } export default ShippingAddressScreen;