Skip to content

Commit

Permalink
Merge branch 'dev/FE' into feat/614
Browse files Browse the repository at this point in the history
  • Loading branch information
guridaek committed Oct 8, 2023
1 parent e79aebb commit 53a05c0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions frontend/src/components/SendMessageModal/SendMessageModal.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import React from 'react';
import React, { useState } from 'react';
import { styled } from 'styled-components';
import Button from '../common/Button/Button';
import TextArea from '../Textarea/Textarea';
import useViewport from '@/hooks/useViewport';

interface Props {
messageState: string;
handleChangeMessage: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
placeholder: string;
closeModal: () => void;
handleClickSendButton: () => void;
sendMessage: (message: string) => void;
}

const SendMessageModal = ({
messageState,
handleChangeMessage,
placeholder,
closeModal,
handleClickSendButton,
}: Props) => {
const SendMessageModal = ({ placeholder, closeModal, sendMessage }: Props) => {
const { isMobile } = useViewport();
const [message, setMessage] = useState('');

const handleChangeInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setMessage(e.target.value);
};

const handleClickSendButton = () => {
sendMessage(message);
};

return (
<S.SendMessageModalContainer>
Expand All @@ -31,8 +32,8 @@ const SendMessageModal = ({
maxLength={500}
padding="0"
placeholder={placeholder}
handleInputTextState={handleChangeMessage}
inputTextState={messageState}
handleInputTextState={handleChangeInput}
inputTextState={message}
/>
<S.ButtonContainer>
<Button
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const TextArea = ({
return (
<S.InputContainer $width={width} $height={height} $padding={padding}>
<S.InputBox
value={inputTextState}
onChange={handleInputTextState}
maxLength={maxLength}
$fontSize={fontSize}
Expand All @@ -31,7 +32,7 @@ const TextArea = ({
/>
{maxLength && (
<S.InputTextLength>
{inputTextState?.length ?? 0} / {maxLength}
{inputTextState.length} / {maxLength}
</S.InputTextLength>
)}
</S.InputContainer>
Expand Down
13 changes: 4 additions & 9 deletions frontend/src/pages/RunnerPostDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react';
import React, { useState, useContext } from 'react';
import { styled } from 'styled-components';
import { useParams } from 'react-router-dom';
import { usePageRouter } from '@/hooks/usePageRouter';
Expand Down Expand Up @@ -41,7 +41,7 @@ const RunnerPostPage = () => {
const { mutate: deleteRunnerPost } = useRunnerPostDelete();
const { mutate: suggestReview, isPending: isPendingSuggestion } = useReviewSuggestion();

const sendMessage = () => {
const sendMessage = (message: string) => {
try {
validateMessage(message);
} catch (error) {
Expand All @@ -51,13 +51,10 @@ const RunnerPostPage = () => {
return;
}

closeModal();
suggestReview({ runnerPostId, message });
};

const handleChangeMessage = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setMessage(e.target.value);
};

const handleClickDeleteButton = () => {
closeModal();

Expand All @@ -84,11 +81,9 @@ const RunnerPostPage = () => {

openModal(
<SendMessageModal
messageState={message}
handleChangeMessage={handleChangeMessage}
placeholder="๋Ÿฌ๋„ˆ์—๊ฒŒ ๋ณด๋‚ผ ๋ฉ”์„ธ์ง€๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
closeModal={closeModal}
handleClickSendButton={sendMessage}
sendMessage={sendMessage}
/>,
);
};
Expand Down

0 comments on commit 53a05c0

Please sign in to comment.