在庫追加時のエラーを実装

feature-frontend-design-fix
Masaharu.Kato 4 months ago
parent 6ae78c5d43
commit c790bebb92
  1. 21
      frontend/src/pages/StockPage.tsx

@ -123,8 +123,21 @@ const StockPage: React.FC = () => {
if (newStock.newAddition) {
newStock.stuffId = null;
}
if (isNaN(newStock.amount)) return;
if (newStock.price === null || isNaN(newStock.price)) return;
if (!newStock.stuffId && !newStock.stuffName) {
showErrorMessage(GENERAL_ERRORS.INVALID_STUFF_NAME);
return;
}
if (isNaN(newStock.amount)) {
showErrorMessage(GENERAL_ERRORS.INVALID_AMOUNT);
return;
}
if (newStock.price === null || isNaN(newStock.price)) {
showErrorMessage(GENERAL_ERRORS.INVALID_PRICE);
return;
}
if (newStock.buyAmount !== null && isNaN(newStock.buyAmount)) {
newStock.buyAmount = null;
@ -684,7 +697,7 @@ const StockPage: React.FC = () => {
label="購入店舗"
fullWidth
value={newStock.shop}
onChange={(e) => setNewStock({...newStock, shop: e.target.value})}
onChange={(e) => setNewStock({ ...newStock, shop: e.target.value })}
/>
{/* 購入日・消費期限を横並びに */}
<Box sx={{ display: 'flex', gap: 2, mb: 2 }}>
@ -708,7 +721,7 @@ const StockPage: React.FC = () => {
return (
<Box sx={{ padding: "1rem" }}>
<Typography variant="h5" component="h1" gutterBottom
onClick={() => setOpenCategory({...openCategory, [category]: !openCategory[category]})}
onClick={() => setOpenCategory({ ...openCategory, [category]: !openCategory[category] })}
>
{!openCategory[category] ? <ArrowDownIcon color="primary" /> : <ArrowUpIcon color="primary" />}
{category}

Loading…
Cancel
Save