diff --git a/src/App.tsx b/src/App.tsx index f7d013ef..afc66018 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ import Home from '@pages/Home'; import MajorDecision from '@pages/MajorDecision'; import Map from '@pages/Map'; import My from '@pages/My'; +import SuggestionPage from '@pages/Suggestion'; import Tip from '@pages/Tip'; import RouteChangeTracker from '@utils/routeChangeTracker'; import { Routes, Route } from 'react-router-dom'; @@ -27,6 +28,7 @@ const App = () => { } /> } /> } /> + } /> }> } /> diff --git a/src/apis/suggestion/post-suggestion.ts b/src/apis/suggestion/post-suggestion.ts new file mode 100644 index 00000000..7905f71a --- /dev/null +++ b/src/apis/suggestion/post-suggestion.ts @@ -0,0 +1,18 @@ +import http from '@apis/http'; +import { SERVER_URL } from '@config/index'; + +const postSuggestion = async (value: string | undefined) => { + await http.post( + `${SERVER_URL}/api/suggestion`, + { + content: value, + }, + { + headers: { + 'Content-Type': 'application/json', + }, + }, + ); +}; + +export default postSuggestion; diff --git a/src/pages/Suggestion/index.tsx b/src/pages/Suggestion/index.tsx new file mode 100644 index 00000000..9c80b82e --- /dev/null +++ b/src/pages/Suggestion/index.tsx @@ -0,0 +1,79 @@ +import postSuggestion from '@apis/suggestion/post-suggestion'; +import Button from '@components/Common/Button'; +import InformUpperLayout from '@components/InformUpperLayout'; +import { MODAL_BUTTON_MESSAGE, MODAL_MESSAGE } from '@constants/modal-messages'; +import PLCACEHOLDER_MESSAGES from '@constants/placeholder-message'; +import { css } from '@emotion/react'; +import styled from '@emotion/styled'; +import useModals, { modals } from '@hooks/useModals'; +import { THEME } from '@styles/ThemeProvider/theme'; +import React, { useRef, useState } from 'react'; + +const SuggestionPage = () => { + const { openModal, closeModal } = useModals(); + const areaRef = useRef(null); + const [isInValidInput, setIsInValidInput] = useState(true); + + const onChange = (e: React.ChangeEvent) => { + if (!e.currentTarget.value || e.currentTarget.value.length < 5) { + setIsInValidInput(true); + return; + } + setIsInValidInput(false); + }; + + const onButtonClick = () => { + postSuggestion(areaRef.current?.value); + openModal(modals.alert, { + message: MODAL_MESSAGE.SUCCEED.POST_SUGGESTION, + buttonMessage: MODAL_BUTTON_MESSAGE.CONFIRM, + onClose: () => closeModal(modals.alert), + }); + }; + + return ( + <> + + + + + + + + ); +}; + +export default SuggestionPage; + +const StyledTextArea = styled.textarea` + display: block; + padding: 20px; + width: 80%; + margin: 0 auto; + margin-bottom: 2rem; + line-height: 1.5; + resize: none; + font-size: 16px; + border-radius: 20px; + overflow-y: scoll; + border: 1px solid ${THEME.TEXT.GRAY}; + + &::placeholder { + color: ${THEME.TEXT.GRAY}; + } +`;