Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #722

Merged
merged 8 commits into from
Sep 24, 2023
47 changes: 46 additions & 1 deletion client/src/components/SearchPage/SearchResultPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useRecoilState } from "recoil";
import { comment } from "../../util/recoilState";
import axios from "axios";
import { useLocation } from "react-router-dom";
import { Button, Form, Card, Container, Row, Col } from "react-bootstrap";
import { Button, Form, Card, Container, Row, Col, Modal } from "react-bootstrap";
import StarRating from "./util/StarRating";
import Navbar from "../Navbar/Navbar";
import Kakao from "../../util/KakaoMap";
Expand Down Expand Up @@ -40,6 +40,10 @@ function SearchResultPage(props) {

const [recoilComment, setRecoilComment] = useRecoilState(comment);

const [requestAccompanyModal, setRequestAccompanyModal] = useState(false);

const [requestContent, setRequestContent] = useState(""); // 동행 신청 내용

useEffect(() => {
console.log(recoilComment);

Expand All @@ -58,6 +62,14 @@ function SearchResultPage(props) {
});
}, []);

const handleOpenModal = () => {
setRequestAccompanyModal(true);
}

const handleCloseModal = () => {
setRequestAccompanyModal(false);
}

const handleReviewChange = (event) => {
setReview(event.target.value);
}
Expand Down Expand Up @@ -90,6 +102,23 @@ function SearchResultPage(props) {
}
}

const handleRequestContent = (event) => {
setRequestContent(event.target.value);
}

const handleRequestAccompany = () => {
const postToServer = {
review: requestContent,
tripUUID: tripUuid
}

axios.post(`http://localhost:8080/api/trip/requestAccompany`, postToServer, {
headers: {'Authorization': `Bearer ${token}`}
}).then((res) => {
alert("동행 신청이 완료되었습니다.")
}).catch((res) => alert('동행 신청에 오류가 발생하였습니다.'))
}


return (
<div>
Expand All @@ -107,6 +136,22 @@ function SearchResultPage(props) {
</Card.Subtitle>
<br />
<Card.Text>내용: {content}</Card.Text>
<Button onClick={handleOpenModal}>동행 신청</Button>
<Modal style={{width: '600px', height: '600px'}}
show={requestAccompanyModal}
onHide={handleCloseModal}>
<Modal.Header closeButton>
<Modal.Title>동행 신청</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form>
<Form.Control type="textarea" style={{height: '300px'}} placeholder="신청서를 작성해주세요" onChange={handleRequestContent}/>
<Button variant="primary" type="submit" onClick={handleRequestAccompany}>
신청하기
</Button>
</Form>
</Modal.Body>
</Modal>
</Card.Body>
</Card>
</div>
Expand Down
Loading