Skip to content

Commit ebef691

Browse files
authored
Merge pull request #342 from devpalsPlus/feat/#338
유저 활동기록 문의하기 답변완료시 ui 수정 ( #issue 338 )
2 parents 8a14be7 + 8487c8d commit ebef691

File tree

9 files changed

+96
-22
lines changed

9 files changed

+96
-22
lines changed

src/components/admin/adminInquiry/AdminInquiryAnswer.styled.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { SendButton } from '../../user/customerService/inquiry/Inquiry.styled';
1010

1111
export const InquiryAnswerContentContainer = styled(
1212
AdminInquiryContentContainer
13-
)``;
13+
)`
14+
margin-bottom: 5rem;
15+
`;
1416

1517
export const InquiryAnswerContentWrapper = styled(AdminInquiryContentWrapper)``;
1618

src/components/admin/adminInquiry/AdminInquiryAnswer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function AdminInquiryAnswer() {
1515
useOutletContext();
1616

1717
const [answer, setAnswer] = useState<string>('');
18-
const selectButton: LinkType = answer === null ? '작성하기' : '수정하기';
18+
const selectButton: LinkType = answerData === null ? '작성하기' : '수정하기';
1919

2020
useEffect(() => {
2121
if (answerData === null) {

src/components/admin/adminInquiry/AdminInquiryAnswerWrite.styled.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export const SpinnerWrapper = styled(SpinnerWrapperStyled)``;
1515

1616
export const InquiryAnswerContentContainer = styled(
1717
AdminInquiryContentContainer
18-
)``;
18+
)`
19+
margin-bottom: 5rem;
20+
`;
1921

2022
export const InquiryAnswerWriteWrapper = styled(AdminInquiryContentWrapper)``;
2123

@@ -39,7 +41,6 @@ export const InquiryAnswerWriteButton = styled(InquiryAnswerButton)`
3941
export const InquiryAnswerWriteButtonSpan = styled.span``;
4042

4143
export const InquiryAnswerWrite = styled(InquiryContent)`
42-
resize: none;
4344
border: 1px solid ${({ theme }) => theme.color.placeholder};
4445
border-radius: ${({ theme }) => theme.borderRadius.primary};
4546
padding: 1rem;

src/components/admin/adminInquiry/AdminInquiryAnswerWrite.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ export default function AdminInquiryAnswerWrite() {
4545
}
4646
}, [answerData]);
4747

48+
useEffect(() => {
49+
if (inputRef && inputRef.current) {
50+
inputRef.current.style.height = 'auto';
51+
inputRef.current.style.height = `${inputRef.current.scrollHeight}px`;
52+
}
53+
}, [answer]);
54+
4855
if (isLoading) {
4956
return (
5057
<S.SpinnerWrapper $isAdmin={true}>
@@ -94,7 +101,7 @@ export default function AdminInquiryAnswerWrite() {
94101
value={answer}
95102
ref={inputRef}
96103
onChange={handleChangeAnswer}
97-
></S.InquiryAnswerWrite>
104+
/>
98105
</S.InquiryAnswerWriteWrapper>
99106
<Modal isOpen={isOpen} onClose={handleModalClose}>
100107
{message}

src/components/admin/adminInquiry/AdminInquiryDetailContent.styled.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export const InquiryDeleteButton = styled(SendButton)`
4545
export const InquiryContent = styled.div`
4646
font-size: 1.1rem;
4747
width: 100%;
48+
white-space: pre-line;
49+
overflow: hidden;
4850
`;
4951

5052
export const InquiryFileImgBlowUpButton = styled.button``;

src/components/common/admin/sidebar/AdminSidebar.styled.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const SidebarContainer = styled.section`
1717
position: fixed;
1818
padding: 1rem;
1919
width: 15rem;
20+
height: 100%;
2021
border-right: 1px solid ${({ theme }) => theme.color.grey};
2122
`;
2223

src/components/user/mypage/activityLog/inquiries/inquiry/Inquiry.styled.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled from 'styled-components';
1+
import styled, { css } from 'styled-components';
22

33
export const Container = styled.div`
44
width: 100%;
@@ -25,6 +25,20 @@ export const InquiryState = styled.div`
2525
text-align: center;
2626
`;
2727

28+
export const InquiryStateSpan = styled.span<{ $isCompletedAnswer: boolean }>`
29+
width: fit-content;
30+
color: ${({ $isCompletedAnswer, theme }) =>
31+
$isCompletedAnswer ? theme.color.white : theme.color.green};
32+
33+
${({ $isCompletedAnswer }) =>
34+
$isCompletedAnswer &&
35+
css`
36+
background: ${({ theme }) => theme.color.navy};
37+
border-radius: ${({ theme }) => theme.borderRadius.small};
38+
padding: 0.2rem;
39+
`}
40+
`;
41+
2842
export const InquiryContentWrapper = styled.div`
2943
margin: 0.5rem 0;
3044
background: ${({ theme }) => theme.color.white};
@@ -55,6 +69,30 @@ export const MessageWrapper = styled.div`
5569
font-size: 0.8rem;
5670
`;
5771

72+
export const InquiryAnswerContentContainer = styled.div`
73+
margin-top: 1rem;
74+
`;
75+
76+
export const InquiryAnswerContentWrapper = styled.div`
77+
margin-top: 2rem;
78+
display: flex;
79+
gap: 0.5rem;
80+
`;
81+
82+
export const InquiryAnswerIconWrapper = styled.div`
83+
align-items: start;
84+
svg {
85+
width: 1rem;
86+
height: 1rem;
87+
}
88+
`;
89+
90+
export const InquiryAnswerContent = styled.div`
91+
font-weight: 400;
92+
font-size: 1.1rem;
93+
white-space: pre-line;
94+
`;
95+
5896
export const ModalImgContainer = styled.div`
5997
position: fixed;
6098
top: 0;

src/components/user/mypage/activityLog/inquiries/inquiry/Inquiry.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { useState } from 'react';
1+
import React, { useRef, useState } from 'react';
22
import type { MyInquiries } from '../../../../../../models/activityLog';
33
import * as S from './Inquiry.styled';
44
import { My_INQUIRIES_MESSAGE } from '../../../../../../constants/user/customerService';
5+
import ContentBorder from '../../../../../common/contentBorder/ContentBorder';
6+
import { ChevronRightIcon } from '@heroicons/react/24/outline';
57

68
interface InquiryProps {
79
list: MyInquiries;
@@ -19,6 +21,15 @@ export default function Inquiry({ list, no }: InquiryProps) {
1921
isImageOpen: false,
2022
url: '',
2123
});
24+
const answer = list.answer || '';
25+
const answerRef = useRef<HTMLTextAreaElement>(null);
26+
27+
const handleChangeAnswerRef = () => {
28+
if (answerRef && answerRef.current) {
29+
answerRef.current.style.height = 'auto';
30+
answerRef.current.style.height = `${answerRef.current.scrollHeight}px`;
31+
}
32+
};
2233

2334
return (
2435
<S.Container>
@@ -29,7 +40,11 @@ export default function Inquiry({ list, no }: InquiryProps) {
2940
<S.InquiryNumber>{no}</S.InquiryNumber>
3041
<S.InquiryCategory>{`[${list.category}]`}</S.InquiryCategory>
3142
<S.InquiryTitle>{list.title}</S.InquiryTitle>
32-
<S.InquiryState>{list.state ? '답변완료' : '확인중'}</S.InquiryState>
43+
<S.InquiryState>
44+
<S.InquiryStateSpan $isCompletedAnswer={list.state ? true : false}>
45+
{list.state ? '답변완료' : '확인중'}
46+
</S.InquiryStateSpan>
47+
</S.InquiryState>
3348
</S.InquiryTitleWrapper>
3449
{isOpen && (
3550
<S.InquiryContentWrapper>
@@ -56,6 +71,17 @@ export default function Inquiry({ list, no }: InquiryProps) {
5671
</S.MessageWrapper>
5772
</S.InquiryImgContainer>
5873
)}
74+
{answer && (
75+
<S.InquiryAnswerContentContainer>
76+
<ContentBorder />
77+
<S.InquiryAnswerContentWrapper>
78+
<S.InquiryAnswerIconWrapper>
79+
<ChevronRightIcon />
80+
</S.InquiryAnswerIconWrapper>
81+
<S.InquiryAnswerContent>{answer}</S.InquiryAnswerContent>
82+
</S.InquiryAnswerContentWrapper>
83+
</S.InquiryAnswerContentContainer>
84+
)}
5985
{isImageOpen.isImageOpen && (
6086
<S.ModalImgContainer>
6187
<S.ModalImgWrapper

src/hooks/admin/useAdminInquiry.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,19 @@ export const useAdminInquiry = ({
2727
const handleButtonState = (state: State, isDeleteApi: boolean = false) => {
2828
switch (state) {
2929
case 'success':
30-
{
31-
if (!isDeleteApi) {
32-
handleModalOpen(ADMIN_MODAL_MESSAGE.writeSuccess);
30+
if (!isDeleteApi) {
31+
handleModalOpen(ADMIN_MODAL_MESSAGE.writeSuccess);
32+
} else {
33+
handleConfirm?.();
34+
handleModalOpen(ADMIN_MODAL_MESSAGE.writeDeleteSuccess);
35+
}
36+
setTimeout(() => {
37+
if (id) {
38+
return navigate(`/admin/inquiries/detail/${id}`);
3339
} else {
34-
handleConfirm?.();
35-
handleModalOpen(ADMIN_MODAL_MESSAGE.writeDeleteSuccess);
40+
return navigate(-1);
3641
}
37-
const timer = setTimeout(() => {
38-
if (id) {
39-
return navigate(`/admin/inquiries/detail/${id}`);
40-
} else {
41-
return navigate(-1);
42-
}
43-
}, 1000);
44-
clearTimeout(timer);
45-
}
42+
}, 1000);
4643
break;
4744
case 'fail':
4845
if (!isDeleteApi) {

0 commit comments

Comments
 (0)