@@ -9,11 +9,11 @@ import { useSearchNavigation } from '@/navigation/SearchNavigation';
9
9
import { useAppDispatch , useAppSelect } from '@/store' ;
10
10
import { getSeletedStation } from '@/store/modules' ;
11
11
import { getSearchText } from '@/store/modules/subwaySearchModule' ;
12
- import { useAddResetSearch , useSearchStationName } from '@/global/apis/hook' ;
13
- import { SearchStationNameTypes } from '@/global/apis/entity' ;
12
+ import { useAddRecentSearch , useSearchStationName } from '@/global/apis/hook' ;
13
+ import { SearchHistoryStationNameTypes , SubwayLine } from '@/global/apis/entity' ;
14
14
15
15
interface SearchResultListProps {
16
- historyList : SearchStationNameTypes ;
16
+ historyList : SearchHistoryStationNameTypes [ ] ;
17
17
}
18
18
19
19
const SearchResultList = ( { historyList } : SearchResultListProps ) => {
@@ -25,16 +25,16 @@ const SearchResultList = ({ historyList }: SearchResultListProps) => {
25
25
) ;
26
26
27
27
const { searchResultData } = useSearchStationName ( searchText ) ;
28
- const { addRecentMutate } = useAddResetSearch ( {
29
- onSuccess : ( data ) => {
28
+ const { addRecentMutate } = useAddRecentSearch ( {
29
+ onSuccess : ( { stationLine , stationName } ) => {
30
30
saveStationData ( {
31
- name : data . stationName ,
32
- line : data . stationLine ,
31
+ stationName,
32
+ stationLine,
33
33
} ) ;
34
34
} ,
35
35
} ) ;
36
36
37
- const saveStationData = ( data : { name : string ; line : string } ) => {
37
+ const saveStationData = ( data : { stationName : string ; stationLine : SubwayLine } ) => {
38
38
dispatch ( getSearchText ( '' ) ) ;
39
39
if ( stationType === '출발역' ) {
40
40
dispatch (
@@ -43,7 +43,7 @@ const SearchResultList = ({ historyList }: SearchResultListProps) => {
43
43
stationData : data ,
44
44
} ) ,
45
45
) ;
46
- selectedStation . arrival . name
46
+ selectedStation . arrival . stationName
47
47
? searchNavigation . navigate ( 'SubwayPathResult' , {
48
48
departure : data ,
49
49
arrival : selectedStation . arrival ,
@@ -56,7 +56,7 @@ const SearchResultList = ({ historyList }: SearchResultListProps) => {
56
56
stationData : data ,
57
57
} ) ,
58
58
) ;
59
- selectedStation . departure . name
59
+ selectedStation . departure . stationName
60
60
? searchNavigation . navigate ( 'SubwayPathResult' , {
61
61
departure : selectedStation . departure ,
62
62
arrival : data ,
@@ -66,6 +66,7 @@ const SearchResultList = ({ historyList }: SearchResultListProps) => {
66
66
} ;
67
67
68
68
const stationBtnHandler = ( { stationName, stationLine } : ( typeof searchResultData ) [ 0 ] ) => {
69
+ if ( ! stationLine ) return ;
69
70
addRecentMutate ( { stationName, stationLine } ) ;
70
71
} ;
71
72
@@ -84,27 +85,27 @@ const SearchResultList = ({ historyList }: SearchResultListProps) => {
84
85
</ Header >
85
86
86
87
< Ul marginTop = "18px" >
87
- { historyList . data . map ( ( history ) => (
88
+ { historyList . map ( ( { id , stationName , stationLine } ) => (
88
89
< Li
89
- key = { history . id }
90
+ key = { id }
90
91
onPress = { ( ) =>
91
- saveStationData ( {
92
- name : history . stationName ,
93
- line : history . stationLine ,
92
+ stationBtnHandler ( {
93
+ stationName,
94
+ stationLine,
94
95
} )
95
96
}
96
97
>
97
98
< Icon name = "clock" size = { 25 } color = { COLOR . BE_GRAY } />
98
99
< StationInfoBox >
99
100
< FontText
100
- value = { history . stationName }
101
+ value = { stationName }
101
102
textSize = "16px"
102
103
textWeight = "Medium"
103
104
lineHeight = "21px"
104
105
textColor = "#000"
105
106
/>
106
107
< FontText
107
- value = { history . stationLine }
108
+ value = { stationLine ! }
108
109
textSize = "14px"
109
110
textWeight = "Regular"
110
111
lineHeight = "21px"
@@ -123,7 +124,7 @@ const SearchResultList = ({ historyList }: SearchResultListProps) => {
123
124
{ /* 입력어가 있고 && 검색 결과가 있으면 결과 표시 */ }
124
125
{ /* 입력어가 있고 && 검색 결과가 없으면 없음 표시 */ }
125
126
< Ul marginTop = "28px" >
126
- { searchResultData . map ( ( { stationLine , stationName } , idx ) => (
127
+ { searchResultData . map ( ( { stationName , stationLine } , idx ) => (
127
128
< Li key = { idx } onPress = { ( ) => stationBtnHandler ( { stationLine, stationName } ) } >
128
129
< LocateIcon source = { iconPath [ 'location_pin_gray' ] } width = { 25 } height = { 25 } />
129
130
< StationInfoBox >
@@ -135,7 +136,7 @@ const SearchResultList = ({ historyList }: SearchResultListProps) => {
135
136
textColor = "#000"
136
137
/>
137
138
< FontText
138
- value = { stationLine }
139
+ value = { stationLine ! }
139
140
textSize = "14px"
140
141
textWeight = "Regular"
141
142
lineHeight = "21px"
0 commit comments