From 45040b78804f6a43055c7e12b880bdc46a219faf Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Tue, 3 Jun 2025 16:09:31 +0900 Subject: [PATCH 01/15] =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=89=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.tsx | 25 +++++++++++++++++++++++++ frontend/src/components/Layout.tsx | 29 +++++++++++++++++++---------- frontend/src/pages/StockPage.tsx | 16 ++++++++++++++++ 3 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 frontend/src/pages/StockPage.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 7141e87..d4d6caf 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -9,6 +9,7 @@ import Layout from './components/Layout'; import LoginPage from './pages/LoginPage'; import RegisterPage from './pages/RegisterPage'; import TaskListPage from './pages/TaskListPage'; +import StockPage from './pages/StockPage'; import './App.css'; /** @@ -93,6 +94,30 @@ const App: React.FC = () => { } /> + }> + {/* ルートパスへのアクセスはタスク一覧にリダイレクト */} + } /> + + {/* タスク一覧は認証が必要なため、PrivateRouteでラップ */} + + + + } + /> + + {/* テストページへのルートを追加 */} + + + + } + /> + diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx index e8696a9..eb3612f 100644 --- a/frontend/src/components/Layout.tsx +++ b/frontend/src/components/Layout.tsx @@ -3,13 +3,13 @@ * ヘッダー(AppBar)とメインコンテンツ領域を含む基本的なページ構造を定義 */ import React, { useState } from 'react'; -import { - AppBar, - Toolbar, - Typography, - Container, - Box, - Button, +import { + AppBar, + Toolbar, + Typography, + Container, + Box, + Button, Drawer, List, ListItemText, @@ -18,9 +18,10 @@ import { Divider, IconButton } from '@mui/material'; -import { +import { Menu as MenuIcon, ListAlt as ListAltIcon, + Inventory as InventoryIcon, // テストページ用のアイコン } from '@mui/icons-material'; import { useNavigate, Outlet, useLocation } from 'react-router-dom'; @@ -91,13 +92,21 @@ const Layout: React.FC = () => { role="presentation" > - handleNavigate('/tasks')} + handleNavigate('/tasks')} selected={isSelected('/tasks')} > + {/* テストページへのリンクを追加 */} + handleNavigate('/stock')} + selected={isSelected('/stock')} + > + + + diff --git a/frontend/src/pages/StockPage.tsx b/frontend/src/pages/StockPage.tsx new file mode 100644 index 0000000..8de8bd9 --- /dev/null +++ b/frontend/src/pages/StockPage.tsx @@ -0,0 +1,16 @@ +/** + * テストページコンポーネント + * 白紙の状態で表示されるテスト用のページ + */ +import React from 'react'; +import { Box } from '@mui/material'; + +const StockPage: React.FC = () => { + return ( + + {/* 白紙のページ - 何も表示しない */} + + ); +}; + +export default StockPage; \ No newline at end of file From 3d0c02886996a39c7fd184b2b695dab7b76bfdf9 Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Wed, 4 Jun 2025 15:10:58 +0900 Subject: [PATCH 02/15] =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=AE?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/package-lock.json | 15 ++++++ frontend/package.json | 1 + frontend/src/pages/TaskListPage.tsx | 84 ++++++++++++++++++++++------- 3 files changed, 81 insertions(+), 19 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b073615..0488d5f 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -21,6 +21,7 @@ "@types/react-dom": "^18.2.18", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-icons": "^5.5.0", "react-router-dom": "^6.21.1", "react-scripts": "5.0.1", "typescript": "^4.9.5", @@ -13444,6 +13445,14 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.1.0.tgz", "integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==" }, + "node_modules/react-icons": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", + "integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -26113,6 +26122,12 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.1.0.tgz", "integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==" }, + "react-icons": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", + "integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==", + "requires": {} + }, "react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index d268744..afa6af2 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -18,6 +18,7 @@ "@types/react-dom": "^18.2.18", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-icons": "5.3.0", "react-router-dom": "^6.21.1", "react-scripts": "5.0.1", "typescript": "^4.9.5", diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index c537f37..2f49ef0 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -7,6 +7,7 @@ import { taskApi } from '../services/api'; import { Container, Typography, + Tooltip, List, ListItem, ListItemText, @@ -22,9 +23,16 @@ import { Button, Box, } from '@mui/material'; -import { Add as AddIcon, Delete as DeleteIcon } from '@mui/icons-material'; +import { + Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon, + SoupKitchen as SoupKitchenIcon +} from '@mui/icons-material'; import { Task } from '../types/types'; import { TASK_ERRORS } from '../constants/errorMessages'; +//import { FaCarrot } from "react-icons/fa6"; //エラー起きる いったん保留 + + + // 新規タスクの初期状態 const EMPTY_TASK = { title: '', description: '', completed: false }; @@ -106,7 +114,7 @@ const TaskListPage: React.FC = () => { タスク一覧 {/* タスク一覧表示エリア - 青い背景のコンテナ */} -
+
{/* タスク一覧をマップして各タスクをリストアイテムとして表示 */} {tasks.map((task) => ( @@ -132,39 +140,77 @@ const TaskListPage: React.FC = () => { textDecoration: task.completed ? 'line-through' : 'none', }} /> - {/* タスク削除ボタン */} + {/* 買い物リスト:食材情報記入ボタン */} - handleDeleteTask(task.id)} + + handleDeleteTask(task.id)} + > + + + + {/* 買い物リスト:食材削除ボタン */} + - - + + handleDeleteTask(task.id)} + > + + + + ))}
- {/* 新規タスク作成ボタン - 画面下部に固定表示 */} - setOpenDialog(true)} - > - - + {/* 新規材料作成ボタン - 画面下部に固定表示 */} + + setOpenDialog(true)} + > + + + + {/*新規料理追加ボタン - 画面下部に固定表示 */} + + setOpenDialog(true)} + > + + + {/* 新規タスク作成ダイアログ */} setOpenDialog(false)} disableScrollLock={true}> - 新規タスク + 材料の追加 {/* タスクタイトル入力フィールド */} setNewTask({ ...newTask, title: e.target.value })} From 104132d7fb4c829383ca419e09eab17e2f444a54 Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 09:46:18 +0900 Subject: [PATCH 03/15] =?UTF-8?q?=E3=83=97=E3=83=AB=E3=83=80=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/DropDown.tsx | 28 ++++++++++++++++++++++++ frontend/src/pages/TaskListPage.tsx | 32 +++++++++++++++++++++------- 2 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 frontend/src/components/DropDown.tsx diff --git a/frontend/src/components/DropDown.tsx b/frontend/src/components/DropDown.tsx new file mode 100644 index 0000000..dcab0d5 --- /dev/null +++ b/frontend/src/components/DropDown.tsx @@ -0,0 +1,28 @@ +import React, { useState } from "react"; +import MenuItem from "@mui/material/MenuItem"; +import Select from "@mui/material/Select"; +import FormControl from "@mui/material/FormControl"; +import InputLabel from "@mui/material/InputLabel"; + +const DropDown = () => { + const [selectedValue, setSelectedValue] = useState(""); // 選択された値の状態管理 + + return ( + + カテゴリ + + + ); +}; + +export default DropDown; \ No newline at end of file diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index 2f49ef0..b09759c 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -22,6 +22,10 @@ import { TextField, Button, Box, + MenuItem, + Select, + FormControl, + InputLabel } from '@mui/material'; import { Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon, @@ -30,12 +34,13 @@ import { import { Task } from '../types/types'; import { TASK_ERRORS } from '../constants/errorMessages'; //import { FaCarrot } from "react-icons/fa6"; //エラー起きる いったん保留 +import DropDown from "../components/DropDown"; // 新規タスクの初期状態 -const EMPTY_TASK = { title: '', description: '', completed: false }; +const EMPTY_TASK = { id: 0, title: '', amount: 0, completed: false }; const TaskListPage: React.FC = () => { // タスク一覧の状態管理 @@ -206,6 +211,8 @@ const TaskListPage: React.FC = () => { 材料の追加 + {/*材料カテゴリ選択 */} + {/* タスクタイトル入力フィールド */} { fullWidth value={newTask.title} onChange={(e) => setNewTask({ ...newTask, title: e.target.value })} + sx={{ marginBottom: 2 }} /> - {/* タスク説明入力フィールド - 複数行入力可能 */} + {/* 数量入力フィールド */} setNewTask({ ...newTask, description: e.target.value })} + value={newTask.amount} + onChange={(e) => { + const value = e.target.value; + const parsedValue = parseInt(value, 10); // 数値に変換 + if (!isNaN(parsedValue)) { + setNewTask({ ...newTask, amount: parsedValue }); // number型で保存 + } + }} + sx={{ width: "20%" }} + type="number" + inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }} // ここで整数のみ許可 + /> From 9fdcb045981384666bb06f1f2bb1b1d07db87164 Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 09:51:33 +0900 Subject: [PATCH 04/15] =?UTF-8?q?=E5=90=8D=E5=89=8D=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/CategoryDropDown.tsx | 28 ++++++++++++++++++++ frontend/src/pages/TaskListPage.tsx | 4 +-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 frontend/src/components/CategoryDropDown.tsx diff --git a/frontend/src/components/CategoryDropDown.tsx b/frontend/src/components/CategoryDropDown.tsx new file mode 100644 index 0000000..fce3e55 --- /dev/null +++ b/frontend/src/components/CategoryDropDown.tsx @@ -0,0 +1,28 @@ +import React, { useState } from "react"; +import MenuItem from "@mui/material/MenuItem"; +import Select from "@mui/material/Select"; +import FormControl from "@mui/material/FormControl"; +import InputLabel from "@mui/material/InputLabel"; + +const CategoryDropDown = () => { + const [selectedValue, setSelectedValue] = useState(""); // 選択された値の状態管理 + + return ( + + カテゴリ + + + ); +}; + +export default CategoryDropDown; \ No newline at end of file diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index b09759c..76040a1 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -34,7 +34,7 @@ import { import { Task } from '../types/types'; import { TASK_ERRORS } from '../constants/errorMessages'; //import { FaCarrot } from "react-icons/fa6"; //エラー起きる いったん保留 -import DropDown from "../components/DropDown"; +import CategoryDropDown from "../components/CategoryDropDown"; @@ -212,7 +212,7 @@ const TaskListPage: React.FC = () => { {/*材料カテゴリ選択 */} - + {/* タスクタイトル入力フィールド */} Date: Thu, 5 Jun 2025 11:58:02 +0900 Subject: [PATCH 05/15] =?UTF-8?q?=E8=B2=B7=E3=81=86=E3=82=82=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/TaskListPage.tsx | 78 +++++++++++++----------- frontend/src/services/api.ts | 93 ++++++++++++++++++++++++++++- frontend/src/types/types.ts | 12 ++++ 3 files changed, 147 insertions(+), 36 deletions(-) diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index 76040a1..2b7a4a4 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -3,7 +3,7 @@ * タスクの表示、作成、完了状態の切り替え、削除などの機能を提供 */ import React, { useState, useEffect } from 'react'; -import { taskApi } from '../services/api'; +import { toBuyApi } from '../services/api'; import { Container, Typography, @@ -31,7 +31,7 @@ import { Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon, SoupKitchen as SoupKitchenIcon } from '@mui/icons-material'; -import { Task } from '../types/types'; +import { ToBuy } from '../types/types'; import { TASK_ERRORS } from '../constants/errorMessages'; //import { FaCarrot } from "react-icons/fa6"; //エラー起きる いったん保留 import CategoryDropDown from "../components/CategoryDropDown"; @@ -40,15 +40,21 @@ import CategoryDropDown from "../components/CategoryDropDown"; // 新規タスクの初期状態 -const EMPTY_TASK = { id: 0, title: '', amount: 0, completed: false }; +const EMPTY_TASK: Omit & {category: string} = { + stuff_id: 0, + stuff_name: '', + amount: 0, + shop: '', + category: '', +} const TaskListPage: React.FC = () => { // タスク一覧の状態管理 - const [tasks, setTasks] = useState([]); + const [tobuys, setToBuys] = useState([]); // 新規タスク作成ダイアログの表示状態 const [openDialog, setOpenDialog] = useState(false); // 新規タスクの入力内容 - const [newTask, setNewTask] = useState(EMPTY_TASK); + const [newToBuy, setNewToBuy] = useState(EMPTY_TASK); // コンポーネントマウント時にタスク一覧を取得 useEffect(() => { @@ -61,36 +67,36 @@ const TaskListPage: React.FC = () => { */ const fetchTasks = async () => { try { - const tasks = await taskApi.getTasks(); - setTasks(tasks); + const tobuys = await toBuyApi.getToBuys(); + setToBuys(tobuys.tobuy_array); } catch (error) { console.error(`${TASK_ERRORS.FETCH_FAILED}:`, error); } }; - /** - * タスクの完了状態を切り替えるハンドラー - * 対象タスクの完了状態を反転させてAPIに更新を要求 - */ - const handleToggleComplete = async (taskId: number) => { - try { - const task = tasks.find(t => t.id === taskId); - if (!task) return; + // /** + // * タスクの完了状態を切り替えるハンドラー + // * 対象タスクの完了状態を反転させてAPIに更新を要求 + // */ + // const handleToggleComplete = async (taskId: number) => { + // try { + // const task = tasks.find(t => t.id === taskId); + // if (!task) return; - await taskApi.updateTask(taskId, { ...task, completed: !task.completed }); - fetchTasks(); // 更新後のタスク一覧を再取得 - } catch (error) { - console.error(`${TASK_ERRORS.UPDATE_FAILED}:`, error); - } - }; + // await toBuyApi.updateTask(taskId, { ...task, completed: !task.completed }); + // fetchTasks(); // 更新後のタスク一覧を再取得 + // } catch (error) { + // console.error(`${TASK_ERRORS.UPDATE_FAILED}:`, error); + // } + // }; /** * タスクを削除するハンドラー * 指定されたIDのタスクをAPIを通じて削除 */ - const handleDeleteTask = async (taskId: number) => { + const handleDeleteTask = async (toBuyId: number) => { try { - await taskApi.deleteTask(taskId); + await toBuyApi.deleteToBuy(toBuyId); fetchTasks(); // 削除後のタスク一覧を再取得 } catch (error) { console.error(`${TASK_ERRORS.DELETE_FAILED}:`, error); @@ -104,9 +110,9 @@ const TaskListPage: React.FC = () => { */ const handleCreateTask = async () => { try { - await taskApi.createTask(newTask); + await toBuyApi.addToBuy(newToBuy); setOpenDialog(false); // ダイアログを閉じる - setNewTask(EMPTY_TASK); // 入力内容をリセット + setNewToBuy(EMPTY_TASK); // 入力内容をリセット fetchTasks(); // 作成後のタスク一覧を再取得 } catch (error) { console.error(`${TASK_ERRORS.CREATE_FAILED}:`, error); @@ -122,9 +128,9 @@ const TaskListPage: React.FC = () => {
{/* タスク一覧をマップして各タスクをリストアイテムとして表示 */} - {tasks.map((task) => ( + {tobuys.map((tobuy) => ( { }} > {/* タスク完了状態を切り替えるチェックボックス */} + {/*} handleToggleComplete(task.id)} /> + */} {/* タスクのタイトルと説明 - 完了状態に応じて取り消し線を表示 */} {/* 買い物リスト:食材情報記入ボタン */} @@ -174,7 +182,7 @@ const TaskListPage: React.FC = () => { handleDeleteTask(task.id)} + onClick={() => handleDeleteTask(tobuy.tobuy_id)} > @@ -219,8 +227,8 @@ const TaskListPage: React.FC = () => { margin="dense" label="材料名" fullWidth - value={newTask.title} - onChange={(e) => setNewTask({ ...newTask, title: e.target.value })} + value={newToBuy.stuff_name} + onChange={(e) => setNewToBuy({ ...newToBuy, stuff_name: e.target.value })} sx={{ marginBottom: 2 }} /> {/* 数量入力フィールド */} @@ -228,12 +236,12 @@ const TaskListPage: React.FC = () => { margin="dense" label="数量" fullWidth - value={newTask.amount} + value={newToBuy.amount} onChange={(e) => { const value = e.target.value; const parsedValue = parseInt(value, 10); // 数値に変換 if (!isNaN(parsedValue)) { - setNewTask({ ...newTask, amount: parsedValue }); // number型で保存 + setNewToBuy({ ...newToBuy, amount: parsedValue }); // number型で保存 } }} sx={{ width: "20%" }} diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index d963bbe..4919343 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -3,7 +3,7 @@ * バックエンドAPIとの通信を担当するモジュール * 認証、タスク管理などの機能を提供 */ -import { LoginCredentials, RegisterCredentials, AuthResponse, Task } from '../types/types'; +import { LoginCredentials, RegisterCredentials, AuthResponse, Task, ToBuy } from '../types/types'; import { AUTH_ERRORS, TASK_ERRORS } from '../constants/errorMessages'; // APIのベースURL - 環境変数から取得するか、デフォルト値を使用 @@ -82,7 +82,98 @@ export const authApi = { }, }; + +/** + * 買うものリスト管理関連のAPI機能を提供するオブジェクト + * 買うものリストの取得、作成、更新、削除などの機能を含む + */ +export const toBuyApi = { + /** + * 全タスクを取得 + * @returns タスク一覧 + */ + getToBuys: async (): Promise<{ "tobuy_array": ToBuy[] }> => { + // const response = await fetch(`${API_BASE_URL}/api/tobuy/get`, { + // headers: getHeaders(), // 認証トークンを含むヘッダー + // }); + + // if (!response.ok) { + // throw new Error(TASK_ERRORS.FETCH_FAILED); + // } + + // return response.json(); + + return { + "tobuy_array": [ + { + "tobuy_id": 1, + "stuff_id": 2, + "stuff_name": "じゃがいも", + "amount": 3, + "shop": "shopXXX" + }, + { + "tobuy_id": 2, + "stuff_id": 5, + "stuff_name": "にんじん", + "amount": 1 + } + ] + } + + }, + + /** + * 買うものリストへの材料追加 + * @param tobuy 作成する材料情報 + * @returns 作成された材料情報 + */ + addToBuy: async (tobuy: Omit & { category: string }): Promise => { + // const response = await fetch(`${API_BASE_URL}/api/tasks`, { + // method: 'POST', + // headers: getHeaders(), + // body: JSON.stringify(tobuy), + // }); + + // if (!response.ok) { + // throw new Error(TASK_ERRORS.CREATE_FAILED); + // } + + // return response.json(); + + return { + "result": true, + "tobuy_id": 1, + "stuff_id": 6, + "message": "追加に成功しました", + } + + }, + + /** + * 買うものリストを削除 + * @param id 削除対象の買うものリストID + */ + deleteToBuy: async (tobuy_id: number): Promise<{ result: boolean }> => { + // const response = await fetch(`${API_BASE_URL}/api/tobuy/delete`, { + // method: 'DELETE', + // headers: getHeaders(), + // body: JSON.stringify({tobuy_id}), + // }); + + // if (!response.ok) { + // throw new Error(TASK_ERRORS.DELETE_FAILED); + // } + + return { + "result": true + } + }, +} + + /** + * (サンプル,実際には不要) * タスク管理関連のAPI機能を提供するオブジェクト * タスクの取得、作成、更新、削除などの機能を含む */ diff --git a/frontend/src/types/types.ts b/frontend/src/types/types.ts index d3b1186..2304c92 100644 --- a/frontend/src/types/types.ts +++ b/frontend/src/types/types.ts @@ -12,6 +12,18 @@ export interface Task { updatedAt: string; // タスク更新日時 } +/** + * タスク情報を表す型定義 + * タスクの基本情報と状態を管理 + */ +export interface ToBuy { + tobuy_id: number, + stuff_id: number, + stuff_name: string, + amount: number, + shop?: string, +} + /** * ユーザー情報を表す型定義 * ユーザーの基本情報を管理 From 1f43448fcb7ad3d9c57612f94e6d73a16a9000af Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 13:08:14 +0900 Subject: [PATCH 06/15] =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=83=9C=E3=83=83=E3=82=AF=E3=82=B9=E3=81=AE=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/TaskListPage.tsx | 30 ++++++++++++++++++----------- frontend/src/services/api.ts | 8 ++++---- frontend/src/types/types.ts | 11 ++++++++--- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index 76040a1..dd61853 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -22,10 +22,8 @@ import { TextField, Button, Box, - MenuItem, - Select, - FormControl, - InputLabel + FormControlLabel, + FormGroup } from '@mui/material'; import { Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon, @@ -40,7 +38,7 @@ import CategoryDropDown from "../components/CategoryDropDown"; // 新規タスクの初期状態 -const EMPTY_TASK = { id: 0, title: '', amount: 0, completed: false }; +const EMPTY_TASK = { id: 0, stuff_id: 0, stuff_name: '', amount: 0, price: 0, buyDate: new Date('2000-06-22'), expirationDate: new Date('2020-06-22'), newAddition: false, completed: false }; const TaskListPage: React.FC = () => { // タスク一覧の状態管理 @@ -104,7 +102,7 @@ const TaskListPage: React.FC = () => { */ const handleCreateTask = async () => { try { - await taskApi.createTask(newTask); + await taskApi.addStuff(newTask); setOpenDialog(false); // ダイアログを閉じる setNewTask(EMPTY_TASK); // 入力内容をリセット fetchTasks(); // 作成後のタスク一覧を再取得 @@ -139,8 +137,8 @@ const TaskListPage: React.FC = () => { /> {/* タスクのタイトルと説明 - 完了状態に応じて取り消し線を表示 */} { {/* 新規タスク作成ダイアログ */} setOpenDialog(false)} disableScrollLock={true}> - 材料の追加 + + 材料の追加 + + + } + label="食材を新規追加" + checked={newTask.newAddition} + /> + + {/*材料カテゴリ選択 */} @@ -219,8 +227,8 @@ const TaskListPage: React.FC = () => { margin="dense" label="材料名" fullWidth - value={newTask.title} - onChange={(e) => setNewTask({ ...newTask, title: e.target.value })} + value={newTask.stuff_name} + onChange={(e) => setNewTask({ ...newTask, stuff_name: e.target.value })} sx={{ marginBottom: 2 }} /> {/* 数量入力フィールド */} diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index d963bbe..7fec836 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -121,12 +121,12 @@ export const taskApi = { }, /** - * 新規タスクを作成 - * @param task 作成するタスク情報(ID、ユーザーID、作成日時、更新日時は除外) + * 新規材料を作成 + * @param task 作成するタスク情報(価格,作成日時、更新日時は除外) * @returns 作成されたタスク情報 */ - createTask: async (task: Omit): Promise => { - const response = await fetch(`${API_BASE_URL}/api/tasks`, { + addStuff: async (task: Omit): Promise => { + const response = await fetch(`${API_BASE_URL}/api/tubuy/add`, { method: 'POST', headers: getHeaders(), body: JSON.stringify(task), diff --git a/frontend/src/types/types.ts b/frontend/src/types/types.ts index d3b1186..aa87525 100644 --- a/frontend/src/types/types.ts +++ b/frontend/src/types/types.ts @@ -4,12 +4,17 @@ */ export interface Task { id: number; // タスクの一意識別子 - title: string; // タスクのタイトル - description?: string; // タスクの詳細説明(任意) + stuff_name: string; // タスクのタイトル + amount: number; //材料の数量 + price: number; //材料の値段 + buyDate:Date; //購入日時 + expirationDate: Date; //賞味・消費期限 + //description?: string; // タスクの詳細説明(任意) completed: boolean; // タスクの完了状態 userId: number; // タスクの所有者ID createdAt: string; // タスク作成日時 - updatedAt: string; // タスク更新日時 + newAddition: boolean //材料を新規追加するかどうか + //updatedAt: string; // タスク更新日時 } /** From a8112ff4fddc669560aba1246c75410c095dd915 Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 13:08:29 +0900 Subject: [PATCH 07/15] =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=83=9C=E3=83=83=E3=82=AF=E3=82=B9=E3=81=AE=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/TaskListPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index dd61853..81b3da5 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -209,7 +209,6 @@ const TaskListPage: React.FC = () => { 材料の追加 - } label="食材を新規追加" From f15b912d4f28b443cb7e635300b8a80b65264a6e Mon Sep 17 00:00:00 2001 From: "akito.nishiwaki" Date: Thu, 5 Jun 2025 13:10:03 +0900 Subject: [PATCH 08/15] =?UTF-8?q?=E5=9C=A8=E5=BA=AB=E7=99=BB=E9=8C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/TaskListPage.tsx | 68 +++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index c537f37..42262dc 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -27,7 +27,7 @@ import { Task } from '../types/types'; import { TASK_ERRORS } from '../constants/errorMessages'; // 新規タスクの初期状態 -const EMPTY_TASK = { title: '', description: '', completed: false }; +const EMPTY_TASK = { title: '', description: '', price: 0, buy_date: new Date(), completed: false }; const TaskListPage: React.FC = () => { // タスク一覧の状態管理 @@ -36,6 +36,12 @@ const TaskListPage: React.FC = () => { const [openDialog, setOpenDialog] = useState(false); // 新規タスクの入力内容 const [newTask, setNewTask] = useState(EMPTY_TASK); + //在庫登録ダイアログの表示状態 + const [openInfoDialog, setOpenInfoDialog] = useState(false); + + const [selectedTask, setSelectedTask] = useState(); + + // コンポーネントマウント時にタスク一覧を取得 useEffect(() => { @@ -131,15 +137,26 @@ const TaskListPage: React.FC = () => { sx={{ textDecoration: task.completed ? 'line-through' : 'none', }} - /> - {/* タスク削除ボタン */} + /> + + {/*在庫登録ボタン */} + { + setSelectedTask(task); + setOpenInfoDialog(true);}} + > + + + {/* タスク削除ボタン */} handleDeleteTask(task.id)} > - + @@ -188,7 +205,50 @@ const TaskListPage: React.FC = () => { + + {/*在庫登録のための数値入力ダイアログ */} + setOpenInfoDialog(false)} disableScrollLock={true}> + 在庫登録 + + + {/* 価格入力フィールド */} + + {/* 消費・賞味期限入力フィールド */} + + {/* 購入日入力フィールド */} + + + + + + + + + ); }; From b7b073042e2a3dbedc68c40fd621c72c0623ab46 Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 13:13:33 +0900 Subject: [PATCH 09/15] =?UTF-8?q?=E5=90=8D=E5=89=8D=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/DropDown.tsx | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 frontend/src/components/DropDown.tsx diff --git a/frontend/src/components/DropDown.tsx b/frontend/src/components/DropDown.tsx deleted file mode 100644 index dcab0d5..0000000 --- a/frontend/src/components/DropDown.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React, { useState } from "react"; -import MenuItem from "@mui/material/MenuItem"; -import Select from "@mui/material/Select"; -import FormControl from "@mui/material/FormControl"; -import InputLabel from "@mui/material/InputLabel"; - -const DropDown = () => { - const [selectedValue, setSelectedValue] = useState(""); // 選択された値の状態管理 - - return ( - - カテゴリ - - - ); -}; - -export default DropDown; \ No newline at end of file From ea753380ab91888a5dc64bdfbc9069aaa9f701f1 Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 13:15:34 +0900 Subject: [PATCH 10/15] =?UTF-8?q?pacage=E3=81=AE=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/package-lock.json | 15 --------------- frontend/package.json | 1 - 2 files changed, 16 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0488d5f..b073615 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -21,7 +21,6 @@ "@types/react-dom": "^18.2.18", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-icons": "^5.5.0", "react-router-dom": "^6.21.1", "react-scripts": "5.0.1", "typescript": "^4.9.5", @@ -13445,14 +13444,6 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.1.0.tgz", "integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==" }, - "node_modules/react-icons": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", - "integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==", - "peerDependencies": { - "react": "*" - } - }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -26122,12 +26113,6 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.1.0.tgz", "integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==" }, - "react-icons": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", - "integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==", - "requires": {} - }, "react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index afa6af2..d268744 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -18,7 +18,6 @@ "@types/react-dom": "^18.2.18", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-icons": "5.3.0", "react-router-dom": "^6.21.1", "react-scripts": "5.0.1", "typescript": "^4.9.5", From b3002ec2975b242f47217909425d87c6fd7e9642 Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 13:45:01 +0900 Subject: [PATCH 11/15] =?UTF-8?q?=E3=83=9E=E3=83=BC=E3=82=B8=E5=BE=8C?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/TaskListPage.tsx | 5 +++-- package-lock.json | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 package-lock.json diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index 83cd6f4..80ef225 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -29,7 +29,7 @@ import { Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon, SoupKitchen as SoupKitchenIcon } from '@mui/icons-material'; -import { ToBuy } from '../types/types'; +import { Task, ToBuy } from '../types/types'; import { TASK_ERRORS } from '../constants/errorMessages'; //import { FaCarrot } from "react-icons/fa6"; //エラー起きる いったん保留 import CategoryDropDown from "../components/CategoryDropDown"; @@ -38,12 +38,13 @@ import CategoryDropDown from "../components/CategoryDropDown"; // 新規タスクの初期状態 -const EMPTY_TASK: Omit & {category: string} = { +const EMPTY_TASK: Omit & {category: string} & {newAddition: boolean} = { stuff_id: 0, stuff_name: '', amount: 0, shop: '', category: '', + newAddition: false } const TaskListPage: React.FC = () => { diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..dbdf2f4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,24 @@ +{ + "name": "joint_exc", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/react": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", + "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-icons": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", + "integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==", + "peerDependencies": { + "react": "*" + } + } + } +} From e163415c469e111df45e988dec231e35576ed2bc Mon Sep 17 00:00:00 2001 From: "Masaharu.Kato" Date: Thu, 5 Jun 2025 15:17:14 +0900 Subject: [PATCH 12/15] =?UTF-8?q?=E3=82=AB=E3=83=86=E3=82=B4=E3=83=AA?= =?UTF-8?q?=E5=88=A5=E3=81=AE=E4=BB=AEAPI=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/services/api.ts | 23 +++++++++++++++++++++-- frontend/src/types/types.ts | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index 854e67f..658bee1 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -3,7 +3,7 @@ * バックエンドAPIとの通信を担当するモジュール * 認証、タスク管理などの機能を提供 */ -import { LoginCredentials, RegisterCredentials, AuthResponse, Task, ToBuy } from '../types/types'; +import { LoginCredentials, RegisterCredentials, AuthResponse, Task, ToBuy, Stuff } from '../types/types'; import { AUTH_ERRORS, TASK_ERRORS } from '../constants/errorMessages'; // APIのベースURL - 環境変数から取得するか、デフォルト値を使用 @@ -171,6 +171,25 @@ export const toBuyApi = { }, } +export const stuffApi = { + getStuffs: async (category: string): Promise<{ stuff_array: Stuff[] }> => { + return { + "stuff_array": [ + { + "stuff_id": 6, + "stuff_name": "鯖", + "category": "魚" + }, + { + "stuff_id": 10, + "stuff_name": "鯛", + "category": "魚", + } + ] + } + } +} + /** * (サンプル,実際には不要) @@ -216,7 +235,7 @@ export const taskApi = { * @param task 作成するタスク情報(価格,作成日時、更新日時は除外) * @returns 作成されたタスク情報 */ - addStuff: async (task: Omit): Promise => { + addStuff: async (task: Omit): Promise => { const response = await fetch(`${API_BASE_URL}/api/tubuy/add`, { method: 'POST', headers: getHeaders(), diff --git a/frontend/src/types/types.ts b/frontend/src/types/types.ts index 42b1cfe..8d6a10c 100644 --- a/frontend/src/types/types.ts +++ b/frontend/src/types/types.ts @@ -29,6 +29,12 @@ export interface ToBuy { shop?: string, } +export interface Stuff { + stuff_id: number, + stuff_name: string, + category: string, +} + /** * ユーザー情報を表す型定義 * ユーザーの基本情報を管理 From cca656158ad7601fcb7515207ebc6ee85b832ce9 Mon Sep 17 00:00:00 2001 From: "Masaharu.Kato" Date: Thu, 5 Jun 2025 15:29:18 +0900 Subject: [PATCH 13/15] make test case --- frontend/src/services/api.ts | 47 +++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index 658bee1..aa0a620 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -173,19 +173,42 @@ export const toBuyApi = { export const stuffApi = { getStuffs: async (category: string): Promise<{ stuff_array: Stuff[] }> => { + const data = [ + { "stuff_id": 1, "stuff_name": "牛乳", "category": "乳製品" }, + { "stuff_id": 2, "stuff_name": "ヨーグルト", "category": "乳製品" }, + { "stuff_id": 3, "stuff_name": "チーズ", "category": "乳製品" }, + { "stuff_id": 4, "stuff_name": "バター", "category": "乳製品" }, + { "stuff_id": 5, "stuff_name": "生クリーム", "category": "乳製品" }, + + { "stuff_id": 6, "stuff_name": "鮭", "category": "魚・肉" }, + { "stuff_id": 7, "stuff_name": "鶏むね肉", "category": "魚・肉" }, + { "stuff_id": 8, "stuff_name": "豚バラ肉", "category": "魚・肉" }, + { "stuff_id": 9, "stuff_name": "牛ひき肉", "category": "魚・肉" }, + { "stuff_id": 10, "stuff_name": "まぐろ", "category": "魚・肉" }, + + { "stuff_id": 11, "stuff_name": "にんじん", "category": "野菜" }, + { "stuff_id": 12, "stuff_name": "キャベツ", "category": "野菜" }, + { "stuff_id": 13, "stuff_name": "ほうれん草", "category": "野菜" }, + { "stuff_id": 14, "stuff_name": "玉ねぎ", "category": "野菜" }, + { "stuff_id": 15, "stuff_name": "ピーマン", "category": "野菜" }, + + { "stuff_id": 16, "stuff_name": "醤油", "category": "調味料" }, + { "stuff_id": 17, "stuff_name": "味噌", "category": "調味料" }, + { "stuff_id": 18, "stuff_name": "塩", "category": "調味料" }, + { "stuff_id": 19, "stuff_name": "砂糖", "category": "調味料" }, + { "stuff_id": 20, "stuff_name": "酢", "category": "調味料" }, + + { "stuff_id": 21, "stuff_name": "米", "category": "その他" }, + { "stuff_id": 22, "stuff_name": "パスタ", "category": "その他" }, + { "stuff_id": 23, "stuff_name": "小麦粉", "category": "その他" }, + { "stuff_id": 24, "stuff_name": "卵", "category": "その他" }, + { "stuff_id": 25, "stuff_name": "豆腐", "category": "その他" } + ] + + const filtered = data.filter(stuff => stuff.category == category) + return { - "stuff_array": [ - { - "stuff_id": 6, - "stuff_name": "鯖", - "category": "魚" - }, - { - "stuff_id": 10, - "stuff_name": "鯛", - "category": "魚", - } - ] + "stuff_array": filtered } } } From 5a3c49176a9ce703714db2ddd9241088d11489ce Mon Sep 17 00:00:00 2001 From: "Haru.Kusano" Date: Thu, 5 Jun 2025 15:30:41 +0900 Subject: [PATCH 14/15] =?UTF-8?q?=E4=BB=AE=EF=BC=9A=E6=9D=90=E6=96=99?= =?UTF-8?q?=E3=83=97=E3=83=AB=E3=83=80=E3=82=A6=E3=83=B3=E3=81=AE=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/StuffNameDropDown.tsx | 16 ++++++++++++++++ frontend/src/pages/TaskListPage.tsx | 13 +++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 frontend/src/components/StuffNameDropDown.tsx diff --git a/frontend/src/components/StuffNameDropDown.tsx b/frontend/src/components/StuffNameDropDown.tsx new file mode 100644 index 0000000..32b613a --- /dev/null +++ b/frontend/src/components/StuffNameDropDown.tsx @@ -0,0 +1,16 @@ +import React from "react"; +import { toBuyApi } from '../services/api'; +import { FormControl, InputLabel, Select, MenuItem } from "@mui/material"; + +const StuffNameDropDown = ({ value, onChange }) => { + return ( + + 材料を選択 + + + ); +}; + +export default StuffNameDropDown; \ No newline at end of file diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index 80ef225..d5d6aab 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -44,7 +44,7 @@ const EMPTY_TASK: Omit & {category: string} & {newAddition: b amount: 0, shop: '', category: '', - newAddition: false + newAddition: false, } const TaskListPage: React.FC = () => { @@ -52,12 +52,11 @@ const TaskListPage: React.FC = () => { const [tobuys, setToBuys] = useState([]); // 新規タスク作成ダイアログの表示状態 const [openDialog, setOpenDialog] = useState(false); - // 新規タスクの入力内容 - const [newTask, setNewTask] = useState(EMPTY_TASK); + //在庫登録ダイアログの表示状態 const [openInfoDialog, setOpenInfoDialog] = useState(false); - const [selectedTask, setSelectedTask] = useState(); + const [selectedTask, setSelectedTask] = useState(); const [newToBuy, setNewToBuy] = useState(EMPTY_TASK); @@ -165,6 +164,7 @@ const TaskListPage: React.FC = () => { setOpenInfoDialog(true)} //onClick={() => handleDeleteTask(task.id)} > @@ -228,7 +228,8 @@ const TaskListPage: React.FC = () => { } label="食材を新規追加" - checked={newTask.newAddition} + checked={newToBuy.newAddition} + onChange={(e) => setNewToBuy({ ...newToBuy, newAddition:(e.target as HTMLInputElement).checked })} /> @@ -306,7 +307,7 @@ const TaskListPage: React.FC = () => { - + ); }; diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index aa0a620..a77a601 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -128,7 +128,7 @@ export const toBuyApi = { * @param tobuy 作成する材料情報 * @returns 作成された材料情報 */ - addToBuy: async (tobuy: Omit & { category: string }): Promise => { + addToBuy: async (tobuy: Omit & { stuff_id: number | null, category: string }): Promise => { // const response = await fetch(`${API_BASE_URL}/api/tasks`, { // method: 'POST', // headers: getHeaders(),