Skip to content

Commit

Permalink
[NO-ISSUE] Fix: $selectedIngredient 초기화 잘 되도록 수정 (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
minsour authored Feb 9, 2024
1 parent 725aaca commit ca741f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/shared/AddIngredientsToMyTteokgukModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ const AddIngredientsToMyTteokgukModal = ({
),
)}
</ol>
<Button color="primary.100" applyColorTo="background">
<Button
disabled={selectedIngredients.length === 0}
color="primary.100"
applyColorTo="background"
>
추가하기
</Button>
</form>
Expand Down
15 changes: 14 additions & 1 deletion src/components/shared/SendIngredientToOthersTteokgukModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Button from "../common/Button";
import CreateCheerMessageModal from "./CreateCheerMessageModal";

import { $updateSelectedIngredient } from "@/store/ingredient";
import { useEffect } from "react";

interface Props {
isOpen: boolean;
Expand Down Expand Up @@ -45,6 +46,7 @@ const SendIngredientsToOthersTteokgukModal = ({
<CreateCheerMessageModal
isOpen={isOpen}
onClose={() => {
updateSelectedIngredient(null);
handleCloseCheerMessageModal();
onClose();
}}
Expand All @@ -58,6 +60,12 @@ const SendIngredientsToOthersTteokgukModal = ({
onClose();
};

useEffect(() => {
return () => {
updateSelectedIngredient(null);
};
}, [updateSelectedIngredient]);

return (
isOpen && (
<Modal className={styles.container}>
Expand All @@ -81,7 +89,12 @@ const SendIngredientsToOthersTteokgukModal = ({
),
)}
</ol>
<Button onClick={handleClickNextButton} color="primary.100" applyColorTo="background">
<Button
disabled={!selectedIngredient}
onClick={handleClickNextButton}
color="primary.100"
applyColorTo="background"
>
다음
</Button>
</Modal.Body>
Expand Down

0 comments on commit ca741f0

Please sign in to comment.