Skip to content

Commit 65a9273

Browse files
committed
feat: few codes for subway info test (#develop)
1 parent 7695a35 commit 65a9273

File tree

35 files changed

+4475
-59
lines changed

35 files changed

+4475
-59
lines changed

services/ahhachul.com/src/apis/request/community.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ export const fetchCommunityDetail = (id: number) =>
5353
axiosInstance.get<ApiResponse<CommunityDetail>>(`/community-posts/${id}`);
5454

5555
export const fetchCommunityCommentList = (id: number) =>
56-
axiosInstance.get<ApiResponse<CommentList>>(`/community-posts/${id}/comments`);
56+
axiosInstance.get<ApiResponse<CommentList>>(`/community-posts/${id}/comments`, {
57+
params: {
58+
sort: 'createdAt,asc',
59+
},
60+
});
5761

5862
export const editCommunity = async (id: number, req: CommunityEditForm) => {
5963
const formData = new FormData();

services/ahhachul.com/src/apis/request/complaint.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ export const fetchComplaintDetail = (id: number) =>
4646
axiosInstance.get<ApiResponse<ComplaintPostDetail>>(`/complaint-posts/${id}`);
4747

4848
export const fetchComplaintCommentList = (id: number) =>
49-
axiosInstance.get<ApiResponse<CommentList>>(`/complaint-posts/${id}/comments`);
49+
axiosInstance.get<ApiResponse<CommentList>>(`/complaint-posts/${id}/comments`, {
50+
params: {
51+
sort: 'createdAt,asc',
52+
},
53+
});

services/ahhachul.com/src/apis/request/lostFound.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export const fetchLostFoundDetail = (id: number) =>
5050
axiosInstance.get<ApiResponse<LostFoundPostDetail>>(`/lost-posts/${id}`);
5151

5252
export const fetchLostFoundCommentList = (id: number) =>
53-
axiosInstance.get<ApiResponse<CommentList>>(`/lost-posts/${id}/comments`);
53+
axiosInstance.get<ApiResponse<CommentList>>(`/lost-posts/${id}/comments`, {
54+
params: {
55+
sort: 'createdAt,asc',
56+
},
57+
});
5458

5559
export const editLostFound = async (id: number, req: LostFoundEditForm) => {
5660
const formData = new FormData();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import axiosInstance from '@/apis/fetcher';
2+
import { ITrain, WithSubwayLineId, WithSubwayStationId, type ApiResponse } from '@/types';
3+
4+
interface APITrainInfoParams extends WithSubwayLineId, WithSubwayStationId {}
5+
interface APITrainInfoResponse {
6+
trainRealTimes: ITrain[];
7+
}
8+
9+
export const fetchTrainInfo = (params: APITrainInfoParams) =>
10+
axiosInstance.get<ApiResponse<APITrainInfoResponse>>('/trains/real-times', { params });

services/ahhachul.com/src/assets/icons/system/ic_chevron.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 4 additions & 0 deletions
Loading

services/ahhachul.com/src/assets/icons/system/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { default as InfoIcon } from './ic_info.svg?react';
77
export { default as LogoIcon } from './ic_logo.svg?react';
88
export { default as HomeIcon } from './ic_home.svg?react';
99
export { default as PlusIcon } from './ic_plus.svg?react';
10+
export { default as RetryIcon } from './ic_retry.svg?react';
1011
export { default as ShareIcon } from './ic_share.svg?react';
1112
export { default as CloseIcon } from './ic_close.svg?react';
1213
export { default as CheckIcon } from './ic_check.svg?react';

services/ahhachul.com/src/components/common/comment/commentListItem/CommentListItem.styled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const ReplyButton = styled.button`
6060
export const readonlyEditorCss = css`
6161
padding: 0;
6262
63-
& > div {
63+
& > div > div {
6464
padding: 0;
6565
border: none;
6666
}

services/ahhachul.com/src/components/common/float/molecules/newBtn/newBtn.component.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ interface NewBtnProps {
1111
label?: string;
1212
type?: NewBtnType;
1313
replace?: boolean;
14+
checkAuth?: boolean;
1415
}
1516

16-
const NewBtn = ({ activityName, label = '글쓰기', type = 'new', replace = false }: NewBtnProps) => {
17+
const NewBtn = ({
18+
activityName,
19+
label = '글쓰기',
20+
type = 'new',
21+
replace = false,
22+
checkAuth = true,
23+
}: NewBtnProps) => {
1724
const { push, replace: replacePage } = useFlow();
1825
const { authService } = useAuth();
1926

2027
const onClick = () => {
2128
const action = replace ? replacePage : push;
2229
action(
23-
authService.isAuthenticated ? activityName : 'SignInPage',
30+
!checkAuth ? activityName : authService.isAuthenticated ? activityName : 'SignInPage',
2431
{},
2532
{
2633
animate: !replace,
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import { useMemo, useReducer, useCallback, useRef } from 'react';
2+
3+
import { motion } from 'motion/react';
4+
import { from, tap, map } from 'rxjs';
5+
6+
import { ChevronIcon } from '@/assets/icons/system';
7+
import useOnClickOutside from '@/hooks/useOnClickOutside';
8+
import { useUserStationStore } from '@/stores/subway';
9+
import type { UserStation } from '@/types';
10+
11+
import * as S from './HomeHeaderActions.styled';
12+
13+
const wrapperVariants = {
14+
open: {
15+
scaleX: 1,
16+
scaleY: 1,
17+
opacity: 1,
18+
transition: {
19+
stiffness: 300,
20+
damping: 20,
21+
when: 'beforeChildren',
22+
staggerChildren: 0.02,
23+
duration: 0.15,
24+
},
25+
},
26+
closed: {
27+
scaleX: 0.8,
28+
scaleY: 0.8,
29+
opacity: 0,
30+
transition: {
31+
duration: 0.4,
32+
staggerChildren: 0.5,
33+
},
34+
},
35+
};
36+
37+
const iconVariants = {
38+
open: { rotate: 180 },
39+
closed: { rotate: 0, transition: { duration: 0 } },
40+
};
41+
42+
const itemVariants = {
43+
open: {
44+
opacity: 1,
45+
y: 0,
46+
transition: {
47+
duration: 0,
48+
when: 'beforeChildren',
49+
},
50+
},
51+
closed: {
52+
opacity: 0,
53+
y: -15,
54+
transition: {
55+
duration: 0,
56+
when: 'afterChildren',
57+
},
58+
},
59+
};
60+
61+
const actionTextVariants = {
62+
open: { scale: 1, y: 0, transition: { duration: 0.15 } },
63+
closed: { scale: 0, y: -7, transition: { duration: 0.15 } },
64+
};
65+
66+
const Option = ({ station, onClick }: { station: UserStation; onClick: () => void }) => {
67+
return (
68+
<motion.li variants={itemVariants} css={S.option} onClick={onClick}>
69+
<motion.span variants={actionTextVariants}>{station.name}</motion.span>
70+
</motion.li>
71+
);
72+
};
73+
74+
const HomeHeaderActions = () => {
75+
const [openDialog, toggleDialog] = useReducer(open => !open, false);
76+
77+
const dialogRef = useRef<HTMLDivElement>(null);
78+
useOnClickOutside(dialogRef, toggleDialog);
79+
80+
const { stations, setUserStations } = useUserStationStore(state => state);
81+
const activatedStation = useMemo(() => stations[0], [stations]);
82+
83+
const handleStationClick = useCallback(
84+
(clickedStation: UserStation) => () => {
85+
if (!openDialog) return;
86+
if (activatedStation.name === clickedStation.name) {
87+
toggleDialog();
88+
return;
89+
}
90+
91+
from([clickedStation])
92+
.pipe(
93+
tap(() => toggleDialog()),
94+
map(clicked => [clicked, ...stations.filter(station => station.name !== clicked.name)]),
95+
tap(updatedStations => setUserStations(updatedStations)),
96+
)
97+
.subscribe();
98+
},
99+
[activatedStation.name, stations, setUserStations],
100+
);
101+
102+
return (
103+
<div css={S.container} ref={dialogRef}>
104+
<button css={S.button} onClick={toggleDialog}>
105+
<span>{activatedStation.name}</span>
106+
<motion.span variants={iconVariants}>
107+
<ChevronIcon />
108+
</motion.span>
109+
</button>
110+
<motion.div
111+
animate={openDialog ? 'open' : 'closed'}
112+
css={{
113+
position: 'relative',
114+
}}
115+
>
116+
<motion.ul
117+
initial={wrapperVariants.closed}
118+
variants={wrapperVariants}
119+
style={{
120+
originY: 'top',
121+
}}
122+
css={S.menu}
123+
>
124+
{stations.map(station => (
125+
<Option key={station.name} station={station} onClick={handleStationClick(station)} />
126+
))}
127+
</motion.ul>
128+
</motion.div>
129+
</div>
130+
);
131+
};
132+
133+
export default HomeHeaderActions;

0 commit comments

Comments
 (0)