diff --git a/src/components/PrintingRow/PrintingRow.jsx b/src/components/PrintingRow/PrintingRow.jsx index 06a0fbb..1787ddf 100644 --- a/src/components/PrintingRow/PrintingRow.jsx +++ b/src/components/PrintingRow/PrintingRow.jsx @@ -1,24 +1,21 @@ -import React, { useContext, useState } from 'react'; +import React, { useContext } from 'react'; import { CardContext } from '../../context/CardContext'; import { updateCardAmount } from '../../services/api'; function PrintingRow({ card_id, printing, cols, zebra }) { const { ownedAmounts, updateAmount } = useContext(CardContext); - const [loading, setLoading] = useState(false); const key = `${printing.set_id}-${printing.rarity_id}`; const current = ownedAmounts[card_id]?.[key] ?? printing.amount_owned ?? 0; const save = async (next) => { if (card_id == null || printing.set_id == null || printing.rarity_id == null) return; - setLoading(true); + updateAmount(card_id, key, next); try { await updateCardAmount(card_id, printing.set_id, printing.rarity_id, next); - updateAmount(card_id, key, next); } catch (err) { console.error('Failed to update amount', err); - } finally { - setLoading(false); + updateAmount(card_id, key, current); } }; @@ -26,7 +23,7 @@ function PrintingRow({ card_id, printing, cols, zebra }) {