Skip to content

Commit 14340b7

Browse files
authored
Merge branch 'develop' into feat/#355
2 parents 27fc657 + 2532a98 commit 14340b7

File tree

6 files changed

+57
-32
lines changed

6 files changed

+57
-32
lines changed

src/components/user/mypage/activityLog/inquiries/Inquiries.styled.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ export const InquiriesTableHeadContainer = styled.div`
1616
padding-top: 1rem;
1717
top: 0;
1818
background: ${({ theme }) => theme.color.lightgrey};
19+
z-index: 10000;
1920
`;
2021

2122
export const InquiriesTableHeadWrapper = styled.div`
2223
width: 100%;
2324
display: grid;
24-
grid-template-columns: 8% 15% 65% 17%;
25+
grid-template-columns: 8% 15% 65% 12%;
2526
font-size: 1.3rem;
2627
font-weight: 600;
2728
margin-bottom: 0.5rem;
@@ -51,4 +52,8 @@ export const InquiriesWrapper = styled.div`
5152
gap: 1.5rem;
5253
`;
5354

55+
export const MyInquiriesWrapper = styled.div`
56+
scroll-margin-top: 65px;
57+
`;
58+
5459
export const WrapperNoContentAppliedProjects = styled(WrapperNoContent)``;

src/components/user/mypage/activityLog/inquiries/Inquiries.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
import { useParams } from 'react-router-dom';
1+
import { useLocation, useParams } from 'react-router-dom';
22
import useGetUserActivity from '../../../../../hooks/admin/useGetAllUserActivity';
33
import ContentBorder from '../../../../common/contentBorder/ContentBorder';
44
import NoContent from '../../../../common/noContent/NoContent';
55
import Spinner from '../../Spinner';
66
import * as S from './Inquiries.styled';
77
import Inquiry from './inquiry/Inquiry';
88
import type { MyInquiries } from '../../../../../models/activityLog';
9+
import { useLayoutEffect, useRef } from 'react';
910

1011
export default function Inquiries() {
1112
const { userId } = useParams();
13+
const { state } = useLocation();
14+
const { id } = state || {};
1215
const { userActivityData, isLoading } = useGetUserActivity(
1316
Number(userId),
1417
'inquiries'
1518
);
19+
const inquiriesRef = useRef<(HTMLDivElement | null)[]>([]);
20+
21+
useLayoutEffect(() => {
22+
if (!id || !userActivityData) return;
23+
const idx = userActivityData?.findIndex((item) => item.id == id);
24+
const targetRef =
25+
idx !== undefined && idx >= 0 ? inquiriesRef.current[idx] : null;
26+
if (inquiriesRef?.current && targetRef) {
27+
targetRef.scrollIntoView({ behavior: 'smooth', block: 'start' });
28+
}
29+
}, [userActivityData, id]);
1630

1731
if (isLoading) {
1832
return (
@@ -49,11 +63,12 @@ export default function Inquiries() {
4963
</S.InquiriesTableHeadContainer>
5064
<S.InquiriesWrapper>
5165
{myInquiriesData.map((list, index) => (
52-
<Inquiry
66+
<S.MyInquiriesWrapper
67+
ref={(el) => (inquiriesRef.current[index] = el)}
5368
key={`${index}-${list.title}`}
54-
list={list}
55-
no={myInquiriesData.length - index}
56-
/>
69+
>
70+
<Inquiry list={list} no={myInquiriesData.length - index} />
71+
</S.MyInquiriesWrapper>
5772
))}
5873
</S.InquiriesWrapper>
5974
</S.InquiriesContainer>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const InquiryTitleWrapper = styled.button`
99
text-align: start;
1010
font-size: 1.1rem;
1111
display: grid;
12-
grid-template-columns: 8% 15% 65% 17%;
12+
grid-template-columns: 8% 15% 65% 12%;
1313
cursor: pointer;
1414
`;
1515

@@ -34,8 +34,8 @@ export const InquiryStateSpan = styled.span<{ $isCompletedAnswer: boolean }>`
3434
$isCompletedAnswer &&
3535
css`
3636
background: ${({ theme }) => theme.color.navy};
37-
border-radius: ${({ theme }) => theme.borderRadius.small};
38-
padding: 0.2rem;
37+
border-radius: ${({ theme }) => theme.borderRadius.large};
38+
padding: 0.2rem 0.5rem;
3939
`}
4040
`;
4141

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { useState } from 'react';
1+
import { useEffect, 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';
55
import ContentBorder from '../../../../../common/contentBorder/ContentBorder';
66
import { ChevronRightIcon } from '@heroicons/react/24/outline';
7+
import { useLocation } from 'react-router-dom';
78

89
interface InquiryProps {
910
list: MyInquiries;
@@ -16,26 +17,29 @@ interface IsImageOpen {
1617
}
1718

1819
export default function Inquiry({ list, no }: InquiryProps) {
20+
const { state } = useLocation();
21+
const { id } = state || {};
1922
const [isOpen, setIsOpen] = useState<boolean>(false);
2023
const [isImageOpen, setIsImageOpen] = useState<IsImageOpen>({
2124
isImageOpen: false,
2225
url: '',
2326
});
2427
const answer = list.answer || '';
25-
// const answerRef = useRef<HTMLTextAreaElement>(null);
2628

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-
// };
29+
const divRef = useRef<HTMLDivElement>(null);
30+
31+
useEffect(() => {
32+
if (list.id === id) {
33+
setIsOpen(true);
34+
}
35+
}, [list.id, id]);
3336

3437
return (
35-
<S.Container>
38+
<S.Container ref={divRef}>
3639
<S.InquiryTitleWrapper
3740
type='button'
3841
onClick={() => setIsOpen((prev) => !prev)}
42+
data-id={list.id}
3943
>
4044
<S.InquiryNumber>{no}</S.InquiryNumber>
4145
<S.InquiryCategory>{`[${list.category}]`}</S.InquiryCategory>

src/components/user/mypage/notifications/all/All.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@ import { useAlarmDelete } from '../../../../../hooks/user/useAlarmDelete';
66
import { useAlarmPatch } from '../../../../../hooks/user/useAlarmPatch';
77
import useAlarmList from '../../../../../hooks/user/useAlarmList';
88
import NoContent from '../../../../common/noContent/NoContent';
9+
import { ROUTES } from '../../../../../constants/routes';
910

1011
export default function All() {
1112
const { alarmListData, isLoading } = useAlarmList();
1213
const { filterId }: { filterId: number } = useOutletContext();
1314
const { mutate: deleteAlarm } = useAlarmDelete();
1415
const { mutate: patchAlarm } = useAlarmPatch();
1516

16-
const linkUrl = (id: number, filter: number, replier = 0) => {
17-
// 문의, 신고 답변시 추후 수정
17+
const linkUrl = (id: number, filter: number) => {
1818
if (filter === 1 || filter === 3) {
19-
if (replier === 3) {
20-
return `/activity-log/inquiries`;
21-
} else {
22-
return `/project-detail/${id}`;
23-
}
19+
return `${ROUTES.projectDetail}/${id}`;
2420
} else if (filter === 2) {
25-
return `/manage/${id}`;
21+
return `${ROUTES.manageProjectsRoot}/${id}`;
22+
} else if (filter === 4) {
23+
return `${ROUTES.mypage}/${ROUTES.myPageActivityLog}/${ROUTES.activityInquiries}`;
2624
} else {
27-
return `/mypage/notification`;
25+
return `${ROUTES.mypage}/${ROUTES.myPageNotifications}`;
2826
}
2927
};
3028

@@ -45,7 +43,7 @@ export default function All() {
4543
return false;
4644
}).length;
4745

48-
if (!alarmListData || alarmListData.length === 0 || filterLength === 0) {
46+
if (!alarmListData?.length || filterLength === 0) {
4947
return (
5048
<S.WrapperNoContent data-type='noContent'>
5149
<NoContent type='notification' />
@@ -60,6 +58,8 @@ export default function All() {
6058
.filter((list) => {
6159
if (filterId === 0) {
6260
return true;
61+
} else if (filterId === 3 && list.alarmFilterId === 4) {
62+
return true;
6363
} else if (list.alarmFilterId === filterId) {
6464
return true;
6565
}
@@ -70,7 +70,8 @@ export default function All() {
7070
{/* 신고하기 알림 구별 */}
7171
{list.alarmFilterId !== 5 ? (
7272
<Link
73-
to={linkUrl(list.routingId, list.alarmFilterId, list.replier)}
73+
to={linkUrl(list.routingId, list.alarmFilterId)}
74+
state={list.alarmFilterId === 4 && { id: list.routingId }}
7475
onClick={() => patchAlarm(list.id)}
7576
>
7677
<S.SpanNotification

src/constants/user/myPageFilter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ export const NOTIFICATION_FILTER = [
66
title: '지원한 프로젝트',
77
url: ROUTES.notificationsAppliedProjects,
88
id: 1,
9-
linkUrl: `/project-detail`,
9+
linkUrl: ROUTES.projectDetail,
1010
},
1111
{
1212
title: '지원자 확인',
1313
url: ROUTES.notificationsCheckedApplicants,
1414
id: 2,
15-
linkUrl: `/project-detail`,
15+
linkUrl: ROUTES.projectDetail,
1616
},
1717
{
1818
title: '댓글&답변',
1919
url: ROUTES.comments,
2020
id: 3,
21-
linkUrl: `/project-detail`,
21+
linkUrl: ROUTES.projectDetail,
2222
},
2323
] as const;
2424

0 commit comments

Comments
 (0)