Skip to content

Commit c6093b6

Browse files
committed
fix listing creation
1 parent cb95279 commit c6093b6

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

components/Forms/parts/AdvVehicleFields.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const AdvVehicleFields: React.FunctionComponent<FormProps> = ({
226226
</div>
227227
{config?.data &&
228228
config.data.map(({ key, list }) => (
229-
<ItemDropDown title={t(`label.${key}`)}>
229+
<ItemDropDown title={t(`label.${key}`)} key={key}>
230230
{map(list, (item) => (
231231
/* @ts-ignore */
232232
<Detail key={item.key} item={item} />

components/Input/BaseInput.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-param-reassign */
22
import React, { memo, forwardRef } from 'react'
33
import PropTypes from 'prop-types'
4+
import omit from 'lodash/omit'
45
import toNumber from 'lodash/toNumber'
56
import classNames from 'classnames'
67
import styles from './Input.module.scss'
@@ -45,7 +46,7 @@ const BaseInput = forwardRef(
4546
const isTextAreaInput = type === 'textarea'
4647

4748
const inputProps = {
48-
...rest,
49+
...omit(rest, ['loading']),
4950
id: hasLabel ? name : null,
5051
disabled,
5152
type,

components/Input/Select.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const SelectComponent = ({
4949
if (input.onChange) input.onChange(val)
5050
if (onChange) onChange(val)
5151
}
52-
5352
const Title = () => {
5453
const title =
5554
get(
@@ -188,7 +187,7 @@ const SelectComponent = ({
188187

189188
SelectComponent.propTypes = {
190189
disabled: PropTypes.bool,
191-
options: PropTypes.objectOf(PropTypes.any),
190+
options: PropTypes.any,
192191
className: PropTypes.string,
193192
name: PropTypes.string,
194193
onChange: PropTypes.func,
@@ -283,7 +282,7 @@ export default Select
283282

284283
Select.propTypes = {
285284
visible: PropTypes.bool,
286-
options: PropTypes.objectOf(PropTypes.any), // { key: { label: string, value: 1 }}
285+
options: PropTypes.any, // { key: { label: string, value: 1 }}
287286
className: PropTypes.string,
288287
disabled: PropTypes.bool,
289288
name: PropTypes.string,

store/listing/sagas.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function* handleCreateListing(action) {
3131
try {
3232
const { data } = action
3333
const { month, year } = data
34+
const images = get(data, 'images', [])
3435
const vehicle = yield call(vehiclesService.create, {
3536
...data,
3637
regDate: new Date(toNumber(year), toNumber(month)),
@@ -39,6 +40,11 @@ function* handleCreateListing(action) {
3940
},
4041
modelId: get(data, 'model'),
4142
makeId: get(data, 'make'),
43+
images: images.map((image, index) => ({
44+
imageId: image._id,
45+
order: index,
46+
...image,
47+
})),
4248
})
4349
const result = yield call(listingsService.create, {
4450
...data,
@@ -54,7 +60,7 @@ function* handleCreateListing(action) {
5460
})
5561
setTimeout(() => {
5662
Router.push('/')
57-
}, 300)
63+
}, 900)
5864
} catch (error) {
5965
console.error(error)
6066
yield put({ type: Types.CREATE_LISTING_FAILURE })

0 commit comments

Comments
 (0)