ページ遷移時に入力された料理名を表示するよう変更

dev-frontend-add_dishes
masato.fujita 5 months ago
parent 13cefbc829
commit 7e9759b376
  1. 5
      frontend/src/pages/AddDishes1.tsx
  2. 30
      frontend/src/pages/AddDishes2.tsx

@ -39,7 +39,8 @@ const AddDishes1: React.FC = () => {
setError(true);
} else {
alert("送信成功!");
navigate('/add2'); // タスク一覧ページにリダイレクト
localStorage.setItem("dishName", dish);
navigate('/add2', { state: dish }); // タスク一覧ページにリダイレクト
}
};
@ -59,7 +60,7 @@ const AddDishes1: React.FC = () => {
InputLabelProps={{ style: { fontSize: "40px" }}}
style={{width: "80%" }}
InputProps={{ style: { fontSize: "40px"} }}
// name="username"
name="dish_name"
// autoComplete="username"
autoFocus
value={dish}

@ -3,13 +3,35 @@
*
*/
import React from 'react';
import { Box } from '@mui/material';
import { useLocation } from "react-router-dom";
import {
AppBar,
Toolbar,
Typography,
Container,
Box,
Button,
Drawer,
List,
ListItemText,
ListItemIcon,
ListItemButton,
Divider,
IconButton,
TextField,
Paper,
Alert,
Link,
Grid,
} from '@mui/material';
const AddDishes2: React.FC = () => {
const receivedData = localStorage.getItem("dishName");
return (
<Box>
{/* 白紙のページ - 何も表示しない */}
</Box>
<div>
<h1></h1>
<p style={{fontSize: "40px"}}>{receivedData}</p>
</div>
);
};

Loading…
Cancel
Save