File tree Expand file tree Collapse file tree 7 files changed +33
-15
lines changed Expand file tree Collapse file tree 7 files changed +33
-15
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ const BaseVehicleFields: React.FunctionComponent<Props> = ({
64
64
< Select
65
65
label = { t ( 'label.make' ) }
66
66
fluid
67
- searchable
67
+ searchable = { false }
68
68
loading = { loadingMakes }
69
69
placeholder = { t ( 'placeholder.make' ) }
70
70
isRequired = { includes ( requiredFields , fieldTypes . make ) }
@@ -76,7 +76,7 @@ const BaseVehicleFields: React.FunctionComponent<Props> = ({
76
76
< Select
77
77
label = { t ( 'label.model' ) }
78
78
fluid
79
- searchable
79
+ searchable = { false }
80
80
loading = { loadingModels }
81
81
placeholder = { t ( 'placeholder.model' ) }
82
82
name = { fieldTypes . model }
Original file line number Diff line number Diff line change @@ -116,20 +116,24 @@ const SelectComponent = ({
116
116
const ref = useRef ( null )
117
117
const searchInputRef = useRef ( null )
118
118
119
+ const debouncedValue = useDebounce ( value , 500 )
120
+
119
121
const isActive = ( key ) => ( multiple ? includes ( value , key ) : value === key )
120
122
const handleOnChange = ( val ) => {
121
123
if ( input . onChange ) input . onChange ( val )
122
124
if ( onChange ) onChange ( val )
123
125
}
124
126
125
127
useEffect ( ( ) => {
126
- if ( value === '' && searchable ) {
127
- setSearchValue ( '' )
128
- }
129
- if ( searchable && searchValue === '' && value && value !== '' ) {
130
- handleOnChange ( '' )
128
+ if ( searchable ) {
129
+ if ( debouncedValue === '' ) {
130
+ setSearchValue ( '' )
131
+ }
132
+ // if (searchValue === '' && debouncedValue && debouncedValue !== '') {
133
+ // handleOnChange('')
134
+ // }
131
135
}
132
- } , [ value , searchable ] )
136
+ } , [ debouncedValue , searchable ] )
133
137
134
138
useOutsideClick ( { ref, isOpen : open , setOpen } )
135
139
const handleOptionClick = ( key , label ) => {
@@ -239,7 +243,6 @@ const SelectComponent = ({
239
243
/>
240
244
</ div >
241
245
) }
242
-
243
246
< InputErrorText error = { active ? null : error } />
244
247
</ div >
245
248
< div className = { styles . wrapper } >
Original file line number Diff line number Diff line change 9
9
grid-gap : spacing (1 );
10
10
align-items : center ;
11
11
img {
12
- width : 44 px ;
13
- height : 44 px ;
12
+ width : 34 px ;
13
+ height : 34 px ;
14
14
object-fit : cover ;
15
15
border-radius : 50% ;
16
16
}
Original file line number Diff line number Diff line change 125
125
}
126
126
}
127
127
128
+ .restContent {
129
+ height : 60% ;
130
+ display : flex ;
131
+ flex-direction : column ;
132
+ justify-content : space-between ;
133
+ margin-top : auto ;
134
+ }
135
+
128
136
.vehicleDetails {
129
137
display : grid ;
130
138
grid-template-columns : 50% 50% ;
143
151
font-size : $font-size-span !important ;
144
152
}
145
153
@media (max-width : $tablet ) {
146
- max-height : 118px ;
154
+ // max-height: 118px;
147
155
overflow : auto ;
148
156
}
149
157
span {
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ const VehicleContent: React.FunctionComponent<VehicleOfTheDayProps> = ({
89
89
</ h3 >
90
90
</ div >
91
91
< VehicleDetails listing = { listing } />
92
+ < div className = { styles . restContent } >
92
93
< Avatar
93
94
userId = { listing . userId }
94
95
avatarSrc = { listing . user . profile ?. image ?. url }
@@ -112,6 +113,8 @@ const VehicleContent: React.FunctionComponent<VehicleOfTheDayProps> = ({
112
113
0
113
114
}
114
115
/>
116
+ </ div >
117
+
115
118
</ >
116
119
)
117
120
}
Original file line number Diff line number Diff line change 1
1
import { useRouter } from 'next/router'
2
2
// import get from 'lodash/get'
3
3
4
- const withAuth = ( WrappedComponent ) => {
4
+ const withAuth = ( WrappedComponent , { loginRequired = true } ) => {
5
5
return ( props ) => {
6
6
// checks whether we are on client / browser or server.
7
7
if ( typeof window !== 'undefined' ) {
@@ -12,7 +12,11 @@ const withAuth = (WrappedComponent) => {
12
12
// const isProtected = get(args, 'isProtected', true)
13
13
14
14
// If there is no access token we redirect to "/" page.
15
- if ( ! accessToken ) {
15
+ if ( ! accessToken && loginRequired ) {
16
+ Router . replace ( '/' )
17
+ return null
18
+ }
19
+ if ( accessToken && ! loginRequired ) {
16
20
Router . replace ( '/' )
17
21
return null
18
22
}
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ const SignInPage: React.FunctionComponent = () => {
11
11
)
12
12
}
13
13
14
- export default withAuth ( SignInPage )
14
+ export default withAuth ( SignInPage , { loginRequired : false } )
You can’t perform that action at this time.
0 commit comments