Skip to content

Commit

Permalink
Move products definition closer to where it's used
Browse files Browse the repository at this point in the history
  • Loading branch information
bespoyasov committed Jan 21, 2022
1 parent 03f879a commit 1bf8fb1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@ function Coupon({ onEnter }) {
}

function App() {
let products;
const [status, setStatus] = useState("idle");
const [error, setError] = useState(null);
const { user } = useUserStore();
const { cart } = useCart();

products = cart.products;

async function handleSubmitByValidatingDataAndCreatingOrder(e) {
e.preventDefault();
setStatus("loading");
Expand All @@ -79,6 +76,7 @@ function App() {
}

const _userId = user.name;
const products = cart.products;
let price = 0;
for (const p_i in products) {
price += products[p_i].price * products[p_i].count;
Expand Down

0 comments on commit 1bf8fb1

Please sign in to comment.