diff --git a/frontend/src/components/StuffNameDropDown.tsx b/frontend/src/components/StuffNameDropDown.tsx
deleted file mode 100644
index 32b613a..0000000
--- a/frontend/src/components/StuffNameDropDown.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-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 d5d6aab..e44bc7b 100644
--- a/frontend/src/pages/TaskListPage.tsx
+++ b/frontend/src/pages/TaskListPage.tsx
@@ -3,7 +3,7 @@
* タスクの表示、作成、完了状態の切り替え、削除などの機能を提供
*/
import React, { useState, useEffect } from 'react';
-import { toBuyApi } from '../services/api';
+import { toBuyApi, stuffApi } from '../services/api';
import {
Container,
Typography,
@@ -23,13 +23,17 @@ import {
Button,
Box,
FormControlLabel,
- FormGroup
+ FormGroup,
+ FormControl,
+ InputLabel,
+ Select,
+ MenuItem
} from '@mui/material';
import {
Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon,
SoupKitchen as SoupKitchenIcon
} from '@mui/icons-material';
-import { Task, ToBuy } from '../types/types';
+import { Task, ToBuy, Stuff } from '../types/types';
import { TASK_ERRORS } from '../constants/errorMessages';
//import { FaCarrot } from "react-icons/fa6"; //エラー起きる いったん保留
import CategoryDropDown from "../components/CategoryDropDown";
@@ -38,8 +42,8 @@ import CategoryDropDown from "../components/CategoryDropDown";
// 新規タスクの初期状態
-const EMPTY_TASK: Omit & {category: string} & {newAddition: boolean} = {
- stuff_id: 0,
+const EMPTY_TASK: Omit & { stuff_id: number | null, category: string } & { newAddition: boolean } = {
+ stuff_id: null,
stuff_name: '',
amount: 0,
shop: '',
@@ -55,12 +59,15 @@ const TaskListPage: React.FC = () => {
//在庫登録ダイアログの表示状態
const [openInfoDialog, setOpenInfoDialog] = useState(false);
-
+
const [selectedTask, setSelectedTask] = useState();
const [newToBuy, setNewToBuy] = useState(EMPTY_TASK);
+ const [stuffs, setStuffs] = useState([]);
+
+
// コンポーネントマウント時にタスク一覧を取得
useEffect(() => {
fetchTasks();
@@ -79,6 +86,12 @@ const TaskListPage: React.FC = () => {
}
};
+ const onChangeCategory = async (category: string) => {
+ setNewToBuy({ ...newToBuy, category })
+ const result = await stuffApi.getStuffs(category)
+ setStuffs(result.stuff_array)
+ }
+
// /**
// * タスクの完了状態を切り替えるハンドラー
// * 対象タスクの完了状態を反転させてAPIに更新を要求
@@ -222,23 +235,53 @@ 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(),