diff --git a/frontend/src/components/BuyDialog.tsx b/frontend/src/components/BuyDialog.tsx index 27485fe..9546ffc 100644 --- a/frontend/src/components/BuyDialog.tsx +++ b/frontend/src/components/BuyDialog.tsx @@ -9,19 +9,19 @@ import { Box, } from '@mui/material'; import { NewStock } from '../types/types'; -import DatePicker, { registerLocale } from 'react-datepicker'; -import { ja } from 'date-fns/locale/ja'; // date-fnsの日本語ロケールをインポート +/*import DatePicker, { registerLocale } from 'react-datepicker'; +import { ja } from 'date-fns/locale/ja'; // date-fnsの日本語ロケールをインポート*/ -// 日付をyyyy-MM-dd形式で返す関数 +/*// 日付をyyyy-MM-dd形式で返す関数 const formatDateLocal = (date: Date) => { - const year = date.getFullYear(); - const month = (date.getMonth() + 1).toString().padStart(2, '0'); - const day = date.getDate().toString().padStart(2, '0'); - return `${year}-${month}-${day}`; -}; + const year = date.getFullYear(); + const month = (date.getMonth() + 1).toString().padStart(2, '0'); + const day = date.getDate().toString().padStart(2, '0'); + return `${year}-${month}-${day}`; +};*/ // 日本語ロケールを登録 - registerLocale('ja', ja); +//registerLocale('ja', ja); const BuyDialog = ({ openDialog, @@ -38,12 +38,12 @@ const BuyDialog = ({ setNewStock: (tobuy: NewStock) => void, onSubmit: () => void, }) => { - + return ( setOpenDialog(false)} disableScrollLock={true} PaperProps={{ sx: { minHeight: '600px', maxHeight: '80vh' } }} -> + > 在庫登録 @@ -54,7 +54,7 @@ const BuyDialog = ({ fullWidth value={stuffName} disabled - sx={{ marginBottom: 2 , marginTop: 2}} + sx={{ marginBottom: 2, marginTop: 2 }} /> {/* 価格入力フィールド */} @@ -75,7 +75,18 @@ const BuyDialog = ({ {/* 購入日・消費期限を横並びに */} {/* 購入日入力フィールド */} - + setNewStock({ ...newStock, buyDate: e.target.value }) + } + InputLabelProps={{ shrink: true }} + /> + {/* @@ -91,18 +102,26 @@ const BuyDialog = ({ } isClearable //withPortal // ← 他の文字との重なり対策 - /> - {/* - setNewStock({ ...newStock, buyDate: e.target.value })} - /> - */} + />*/} + {/* 消費・賞味期限入力フィールド */} - + setNewStock({ ...newStock, expDate: e.target.value }) + } + InputLabelProps={{ shrink: true }} + InputProps={{ + inputProps: { + min: newStock.buyDate ? newStock.buyDate.substring(0, 10) : undefined, + } + }} + /> + {/* @@ -118,7 +137,7 @@ const BuyDialog = ({ } isClearable //withPortal - /> + />*/} {/* 購入店舗入力フィールド */} {/* TODO: 実装 */} diff --git a/frontend/src/pages/StockPage.tsx b/frontend/src/pages/StockPage.tsx index bdcde90..5cf9e3c 100644 --- a/frontend/src/pages/StockPage.tsx +++ b/frontend/src/pages/StockPage.tsx @@ -27,17 +27,17 @@ import { MenuItem, } from '@mui/material'; import { STOCK_ERRORS } from '../constants/errorMessages'; -import DatePicker, { registerLocale } from 'react-datepicker'; -import { ja } from 'date-fns/locale/ja'; // date-fnsの日本語ロケールをインポート +/*import DatePicker, { registerLocale } from 'react-datepicker'; +import { ja } from 'date-fns/locale/ja'; // date-fnsの日本語ロケールをインポート*/ import { useMessage } from '../components/MessageContext'; -// 日付をyyyy-MM-dd形式で返す関数 +/*// 日付をyyyy-MM-dd形式で返す関数 const formatDateLocal = (date: Date) => { const year = date.getFullYear(); const month = (date.getMonth() + 1).toString().padStart(2, '0'); const day = date.getDate().toString().padStart(2, '0'); return `${year}-${month}-${day}`; -}; +};*/ // 新規在庫の初期状態 const EMPTY_STOCK: Omit & { stuffId: number | null } & { newAddition: boolean } = { @@ -54,7 +54,7 @@ const EMPTY_STOCK: Omit & { stuffId: number | null } // 日本語ロケールを登録 -registerLocale('ja', ja); +//registerLocale('ja', ja); const StockPage: React.FC = () => { @@ -380,7 +380,17 @@ const StockPage: React.FC = () => { {/* 購入日・消費期限を横並びに */} {/* 購入日 */} - setEditStock({ ...editStock, buyDate: e.target.value })} + InputLabelProps={{ shrink: true }} + /> + {/* { if (editStock) { @@ -400,9 +410,25 @@ const StockPage: React.FC = () => { /> } isClearable - /> + />*/} {/* 消費・賞味期限 */} - setEditStock({ ...editStock, expDate: e.target.value })} + InputLabelProps={{ shrink: true }} + InputProps={{ + inputProps: { + min: newStock.buyDate ? newStock.buyDate.substring(0, 10) : undefined, + } + }} + /> + + {/* { if (editStock) { @@ -422,7 +448,7 @@ const StockPage: React.FC = () => { /> } isClearable - /> + />*/}