diff --git a/src/App.test.jsx b/src/App.test.jsx index 3d85f28..e15f2d3 100644 --- a/src/App.test.jsx +++ b/src/App.test.jsx @@ -34,6 +34,10 @@ describe('App', () => { reason: '', wantToGet: '', }, + studyReviewFields: { + rating: 3, + review: '', + }, }, authReducer: { register: { diff --git a/src/components/introduce/StudyReviewForm.jsx b/src/components/introduce/StudyReviewForm.jsx index 39cb278..77d77f2 100644 --- a/src/components/introduce/StudyReviewForm.jsx +++ b/src/components/introduce/StudyReviewForm.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React from 'react'; import styled from '@emotion/styled'; @@ -44,11 +44,15 @@ const StudyReviewFormButton = styled(Button)` const isValidateUserInfo = (user) => (participants) => !!participants .find(({ id, confirm }) => id === user && confirm && confirm === true); -const StudyReviewForm = ({ group, user, time }) => { +const StudyReviewForm = ({ + group, user, time, fields, onChangeReview, +}) => { const { participants, personnel, applyEndDate, } = group; + const { rating, review } = fields; + const applyEndTime = changeDateToTime(applyEndDate); const valid = { @@ -59,10 +63,20 @@ const StudyReviewForm = ({ group, user, time }) => { return null; } - const [rating, setRating] = useState(0); + const handleChangeRating = (newRating, name) => { + onChangeReview({ + name, + value: newRating, + }); + }; + + const handleChangeReview = (event) => { + const { name, value } = event.target; - const changeRating = (newRating) => { - setRating(newRating); + onChangeReview({ + name, + value, + }); }; return ( @@ -76,7 +90,7 @@ const StudyReviewForm = ({ group, user, time }) => { starDimension="35px" starSpacing="0" starHoverColor="#ffc816" - changeRating={changeRating} + changeRating={handleChangeRating} name="rating" /> @@ -84,7 +98,10 @@ const StudyReviewForm = ({ group, user, time }) => {