Skip to content

Commit 6b59f01

Browse files
authored
feat: 내 호선만 보기 필터를 실 데이터로 반영 (#325) (#327)
* feat: community 글쓰기 이미지 첨부 관련 코드 수정 (#325) * feat: 내 호선만 보기 필터 기능 (#325)
1 parent a3e00df commit 6b59f01

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ export const fetchUserFavoriteStations = async () => {
3535

3636
return data;
3737
};
38+
39+
// export const createUserFavoriteStations = () => {}

services/ahhachul.com/src/pages/my/setting.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CloseIcon, SearchIcon } from '@/assets/icons/system';
99
import { LayoutComponent } from '@/components';
1010
import { subwayLineHexColors, subwayLineOptions } from '@/constants';
1111
import { useFetchSubwayLines } from '@/services/subway';
12+
import { useFetchUserFavoriteStations } from '@/services/user';
1213
import { useFlow } from '@/stackflow';
1314
import { useUserStationStore } from '@/stores/subway';
1415
import type { Stations, SubwayLineType, UserStationList } from '@/types';
@@ -29,6 +30,9 @@ const LABEL_OPTIONS = [
2930
const SettingPage: ActivityComponentType = () => {
3031
const { pop } = useFlow();
3132
const { data: DEFAULT_STATIONS } = useFetchSubwayLines();
33+
const { data: FAVORIT_STATIONS } = useFetchUserFavoriteStations();
34+
console.log('FAVORIT_STATIONS:', FAVORIT_STATIONS);
35+
3236
const [searchTerm, setSearchTerm] = useState('');
3337
const [selectedStation, setSelectedStation] = useState<string | null>(null);
3438
const [labeledStations, setLabeledStations] = useState<StationLabel[]>([]);
@@ -203,6 +207,7 @@ const SettingPage: ActivityComponentType = () => {
203207
alert('역을 하나 이상 선택해주세요.');
204208
return;
205209
}
210+
206211
const formattedStations = labeledStations.map(station => ({
207212
name: station.stationName,
208213
label: LABEL_OPTIONS.find(l => l.id === station.label)?.text || '',

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import { removeFalsyValues } from '@ahhachul/utils';
1010
import * as api from '@/apis/request';
1111
import { TIMESTAMP } from '@/constants';
1212
import { useFlow } from '@/stackflow';
13+
import { useUserStationStore } from '@/stores/subway';
1314
import {
1415
CommunityType,
1516
type CommunityForm,
1617
type CommunityEditForm,
1718
type CommunityListParams,
1819
type SubwayLineFilterOptions,
1920
} from '@/types';
20-
import { formatSubwayFilterOption } from '@/utils';
21+
import { formatSubwayFilterOption, getFirstParentLineId } from '@/utils';
2122

2223
export const communityKeys = {
2324
all: ['community'] as const,
@@ -31,7 +32,9 @@ export const communityKeys = {
3132
};
3233

3334
export const useFetchCommunityList = (filters: CommunityListParams<SubwayLineFilterOptions>) => {
34-
const favoriteLine = 2;
35+
const state = useUserStationStore(state => state);
36+
const favoriteLine = getFirstParentLineId(state.stations);
37+
3538
const req = removeFalsyValues(
3639
{
3740
categoryType: filters.categoryType,

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { removeFalsyValues } from '@ahhachul/utils';
1010
import * as api from '@/apis/request';
1111
import { TIMESTAMP } from '@/constants';
1212
import { useFlow } from '@/stackflow';
13+
import { useUserStationStore } from '@/stores/subway';
1314
import { SubwayLineFilterOptions } from '@/types';
1415
import type { ComplaintForm, ComplaintListParams } from '@/types/complaint';
15-
import { formatSubwayFilterOption } from '@/utils';
16+
import { formatSubwayFilterOption, getFirstParentLineId } from '@/utils';
1617
import { extractTextFromLexical } from '@/utils/lexical';
1718

1819
export const complaintKeys = {
@@ -27,7 +28,9 @@ export const complaintKeys = {
2728
};
2829

2930
export const useFetchComplaintList = (filters: ComplaintListParams<SubwayLineFilterOptions>) => {
30-
const favoriteLine = 3;
31+
const state = useUserStationStore(state => state);
32+
const favoriteLine = getFirstParentLineId(state.stations);
33+
3134
const req = removeFalsyValues(
3235
{
3336
keyword: filters.keyword,

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import { removeFalsyValues } from '@ahhachul/utils';
1010
import * as api from '@/apis/request';
1111
import { TIMESTAMP } from '@/constants';
1212
import { useFlow } from '@/stackflow';
13+
import { useUserStationStore } from '@/stores/subway';
1314
import {
1415
LostFoundType,
1516
type LostFoundForm,
1617
type LostFoundEditForm,
1718
type LostFoundListParams,
1819
type SubwayLineFilterOptions,
1920
} from '@/types';
20-
import { formatSubwayFilterOption } from '@/utils';
21+
import { formatSubwayFilterOption, getFirstParentLineId } from '@/utils';
2122

2223
export const lostFoundKeys = {
2324
all: ['lostFound'] as const,
@@ -31,7 +32,9 @@ export const lostFoundKeys = {
3132
};
3233

3334
export const useFetchLostFoundList = (filters: LostFoundListParams<SubwayLineFilterOptions>) => {
34-
const favoriteLine = 3;
35+
const state = useUserStationStore(state => state);
36+
const favoriteLine = getFirstParentLineId(state.stations);
37+
3538
const req = removeFalsyValues(
3639
{
3740
lostType: filters.lostType,

services/ahhachul.com/src/utils/format.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
import { Stations, SubwayLineFilterOptions, SubwayLineServerModel } from '@/types';
1+
import {
2+
type Stations,
3+
type SubwayLineServerModel,
4+
type UserStationList,
5+
SubwayLineFilterOptions,
6+
} from '@/types';
27

38
export const formatSubwayFilterOption = (
49
lineFilter: SubwayLineFilterOptions,
5-
favoriteLine: number,
10+
favoriteLine?: number,
611
) => {
712
switch (lineFilter) {
813
case SubwayLineFilterOptions.ALL_LINES:
@@ -46,3 +51,7 @@ export const formatSubwayLineInfo = (subwayResponse: SubwayLineServerModel) => {
4651
}, {} as Stations);
4752
return possibleDuplicatedStations;
4853
};
54+
55+
export const getFirstParentLineId = (stations: UserStationList): number | undefined => {
56+
return stations[0]?.stationInfos[0]?.parentLineId;
57+
};

0 commit comments

Comments
 (0)