Skip to content

Commit a6c3725

Browse files
committed
handle message throttles
1 parent 2ddaf93 commit a6c3725

File tree

19 files changed

+252
-184
lines changed

19 files changed

+252
-184
lines changed

β€Ž.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
API_URL=https://forautobackend.herokuapp.com
1+
API_URL=http://localhost:3030
22
ENV=development

β€Žcomponents/Cards/VehicleCard.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import get from 'lodash/get'
55
import classNames from 'classnames'
66
import { LazyLoadImage } from 'react-lazy-load-image-component'
77
import { useTranslation } from 'react-i18next'
8+
import { bodyType as bodyTypes } from '~consts/vehicle'
89
import {
910
FiMapPin,
1011
FiMoreVertical,
1112
FiGitPullRequest,
1213
FiDisc,
1314
} from 'react-icons/fi'
1415
import { GiCarWheel, GiGasPump, GiElectric } from 'react-icons/gi'
16+
import { FiCalendar } from 'react-icons/fi'
1517
import Lottie from 'lottie-react'
1618
import { BaseButton, VehicleDetail } from '~components'
1719
import {
@@ -69,6 +71,7 @@ const VehicleCard = (props) => {
6971
const image = find(images, (image) => image.order === 0) || head(images)
7072
const { t } = useTranslation()
7173
const vehicleBodyYear = formatVehicleMainLabel(bodyType, regDate, t, isMobile)
74+
const vehicleBody = t(`vehicle.${bodyTypes[bodyType]}`);
7275
const vehicleMileage = isMobile ? mileage : formatMillage(mileage, t)
7376
const heartRef = useRef(null)
7477
const vehicleTitle = getVehicleTitle({ make, model, power, capacity }, t)
@@ -154,7 +157,7 @@ const VehicleCard = (props) => {
154157
{vehicleTitle}
155158
</BaseButton>
156159
<div className={styles.features}>
157-
<VehicleDetail icon={<GiCarWheel />}>{vehicleBodyYear}</VehicleDetail>
160+
<VehicleDetail icon={<FiCalendar />}>{vehicleBodyYear}</VehicleDetail>
158161
<VehicleDetail
159162
icon={fuel === fuelTypes.electric ? <GiElectric /> : <GiGasPump />}
160163
>
@@ -167,6 +170,7 @@ const VehicleCard = (props) => {
167170
<VehicleDetail
168171
icon={<FiMapPin />}
169172
>{`${city}, ${countryCode}`}</VehicleDetail>
173+
<VehicleDetail mobileOnly icon={<GiCarWheel />}>{vehicleBody}</VehicleDetail>
170174
</div>
171175
</div>
172176
<div className={styles.footer}>

β€Žcomponents/Cards/VehicleCard.module.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@
9090
// grid-template-rows: repeat(auto-fill, calc(50% - 4px));
9191
grid-gap: spacing(0.5);
9292
padding-top: spacing(0.5);
93-
> div:last-child {
94-
grid-column: 1/3;
95-
}
93+
// > div:last-child {
94+
// grid-column: 1/3;
95+
// }
9696
> div:nth-child(even) {
9797
justify-self: flex-end;
9898
}

β€Žcomponents/Carousels/ListingsCarousel.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Props = {
2525
title: string
2626
type?: 'FEATURED' | 'RECOMMENDED' | 'DEFAULT' | 'CUSTOM'
2727
loading?: boolean
28+
hideOnEmpty?: boolean
2829
listings?: ListingType[]
2930
}
3031

@@ -33,6 +34,7 @@ const ListingsCarousel: React.FunctionComponent<Props> = ({
3334
type,
3435
loading,
3536
listings,
37+
hideOnEmpty,
3638
}) => {
3739
const { isMobile } = useViewport()
3840
const { t } = useTranslation()
@@ -98,6 +100,10 @@ const ListingsCarousel: React.FunctionComponent<Props> = ({
98100
},
99101
}
100102

103+
if (hideOnEmpty && !currentLoading && isEmpty(currentListings)) {
104+
return null;
105+
}
106+
101107
return (
102108
<div className={styles.container}>
103109
<div className={styles.wrapper}>

β€Žcomponents/Forms/OfferForm.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import React from 'react'
2-
import { reduxForm } from 'redux-form'
2+
import { reduxForm, change } from 'redux-form'
33
import { useTranslation } from 'react-i18next'
44
import get from 'lodash/get'
55
import toNumber from 'lodash/toNumber'
6+
import { fieldTypes } from '~/utils/formValidators'
67
import { useDispatch } from 'react-redux'
78
import { Button, Input } from '~components'
89
import ChatCreators from '~store/chats/creators'
910
import styles from './OfferForm.module.scss'
1011

12+
const form = 'offerForm';
13+
1114
const OfferForm = ({ handleSubmit, listingId, disabled }) => {
1215
const { t } = useTranslation()
1316
const dispatch = useDispatch()
@@ -22,6 +25,7 @@ const OfferForm = ({ handleSubmit, listingId, disabled }) => {
2225
redirect: false,
2326
})
2427
)
28+
dispatch(change(form, fieldTypes.offer, null))
2529
}
2630
}
2731
return (
@@ -52,7 +56,7 @@ const OfferForm = ({ handleSubmit, listingId, disabled }) => {
5256
}
5357

5458
const Offer = reduxForm({
55-
form: 'offerForm',
59+
form,
5660
})(OfferForm)
5761

5862
export default Offer

β€Žcomponents/Vehicle/VehicleDetail.module.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
}
1616
}
1717

18+
.mobile {
19+
display: flex;
20+
@media (min-width: $tablet) {
21+
display: none;
22+
}
23+
}
24+
1825
.detail {
1926
display: flex;
20-
align-items: center;
2127
span {
2228
text-align: left;
2329
white-space: nowrap;

β€Žcomponents/Vehicle/VehicleDetail.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ type Props = {
99
title?: any
1010
children?: any
1111
className?: string
12+
mobileOnly?: boolean
1213
}
1314

1415
const VehicleDetail: React.FunctionComponent<Props> = ({
1516
icon,
1617
title,
1718
children,
1819
className,
20+
mobileOnly,
1921
}) => {
2022
return (
21-
<div className={classNames(styles.container, className)}>
23+
<div className={classNames(styles.container, className, mobileOnly && styles.mobile)}>
2224
{title && <h6>{title}</h6>}
2325
<div className={styles.detail}>
2426
{icon ? icon : <FiTag />}

β€Ži18n/translations/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
"weakPassword": "πŸ€– Weak password",
1212
"invalidMileage": "πŸ”§ Invalid mileage",
1313
"oops": "🐞 Oops! Something happened",
14+
"tooManyRequestsTryAgain": "πŸ˜” Notso fast! Try again in a minute",
1415
"invalidUsername": "😑 Invalid username"
1516
},
1617
"snackbar": {
1718
"welcome": "πŸ‘‹ Welcome",
1819
"deleteSuccessful": "πŸ—‘οΈ Delete successful!",
1920
"listingCreated": "πŸ™Œ Listing created",
20-
"link_copied": "Link copied!"
21+
"link_copied": "Link copied!",
22+
"offerSent": "Offer sent! πŸ™Œ"
2123
},
2224
"titles": {
2325
"vehicle_of_the_day": "Vehicle of the day",

β€Žnext-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/// <reference types="next" />
22
/// <reference types="next/types/global" />
3+
/// <reference types="next/image-types/global" />

β€Žnext.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = withPlugins([withFonts, withSvgr], {
1010
sassOptions: {
1111
includePaths: ['./styles'],
1212
},
13+
webpack5: false,
1314
webpack(config) {
1415
const tempConfig = config
1516
return tempConfig

0 commit comments

Comments
Β (0)