Merge branch 'develop-frontend' into feature-frontend-top

feature-frontend-tobuydialog
Haru.Kusano 4 months ago
commit 05c9808115
  1. 8
      backend/src/main/java/com/example/todoapp/repository/RecipeStuffsRepository.java
  2. 6
      backend/src/main/java/com/example/todoapp/repository/ToBuysRepository.java
  3. 14
      frontend/src/pages/AddRecipe.tsx
  4. 1043
      frontend/src/pages/StockPage.tsx

@ -7,6 +7,13 @@ import org.springframework.data.jpa.repository.JpaRepository;
import com.example.todoapp.model.RecipeStuffs;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* レシピ食材関連データのリポジトリインターフェース
* <p>
@ -31,4 +38,5 @@ public interface RecipeStuffsRepository extends JpaRepository<RecipeStuffs, Long
* @return 関連情報存在する場合
*/
Optional<RecipeStuffs> findByRecipesRecipeIdAndStuffStuffId(Long recipeId, Long stuffId);
}

@ -40,13 +40,13 @@ public interface ToBuysRepository extends JpaRepository<ToBuys, Integer> {
ToBuys findByTobuyId(Long tobuyId);
/**
* 指定されたユーザーIDに基づいて買うものリストを取得する
* 指定されたユーザーIDに基づいて買うものリストを取得する_tobuyIdの順番
*
* @param userId ユーザーID
* @return 買うものリスト
*/
@Query("SELECT t FROM ToBuys t WHERE t.user.id = ?1")
List<ToBuys> findByUserIdOrderByTobuyIdAsc(Long userId);
@Query("SELECT t FROM ToBuys t WHERE t.user.id = :userId ORDER BY t.tobuyId ASC")
List<ToBuys> findByUserIdOrderByTobuyIdAsc(@Param("userId") Long userId);
/**
* 指定された買うものIDに基づいて買うものリストを削除

@ -71,6 +71,16 @@ const AddRecipe: React.FC = () => {
const handleSaveRecipe = async () => {
if (!recipeName) {
alert('レシピ名が入力されていません!')
return false;
}
if (!items.length) {
alert('材料が追加されていません!')
return false;
}
if (!recipeId) {
// 新規追加
const response = await recipeApi.addRecipe({
@ -94,11 +104,13 @@ const AddRecipe: React.FC = () => {
const handleSubmit = async () => {
const recipeId = await handleSaveRecipe();
// alert('レシピが保存されました!');
if (!recipeId) return;
navigate('/recipeList');
}
const handleSubmitAndAddToBuy = async () => {
const recipeId = await handleSaveRecipe();
if (!recipeId) return false;
await toBuyApi.addByRecipe(recipeId);
// alert('レシピが保存されて買うものリストに追加されました!');
navigate('/tasks');
@ -188,7 +200,7 @@ const AddRecipe: React.FC = () => {
</Fab>
</div>
<div style={{ position: "fixed", left: "50%", transform: 'translateX(-50%)', bottom: "2%" }}>
<div style={{ position: "fixed", left: "50%", transform: 'translateX(-50%)', bottom: "2%", whiteSpace: 'nowrap' }}>
<Button variant='contained' color="primary" onClick={handleSubmit} sx={{ marginRight: "1rem" }}>
<SaveIcon sx={{ fontSize: "1.5rem", marginRight: "0.5rem" }} />

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save