mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 20:53:24 +10:00
First run after prettier upgrade
This commit is contained in:
parent
447943b1bf
commit
4ebd5445b2
7 changed files with 74 additions and 88 deletions
|
|
@ -11,17 +11,16 @@ const TITLE_MAX_LENGTH = 60;
|
|||
|
||||
// readImage returns a promise which is resolved
|
||||
// when FileReader has loaded given file as dataURL
|
||||
const readImage = file =>
|
||||
new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => resolve(e.target.result);
|
||||
reader.onerror = e => {
|
||||
// eslint-disable-next-line
|
||||
console.error(`Error ${e} happened while reading ${file.name}: ${e.target.result}`);
|
||||
reject(new Error(`Error reading ${file.name}: ${e.target.result}`));
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
const readImage = file => new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => resolve(e.target.result);
|
||||
reader.onerror = e => {
|
||||
// eslint-disable-next-line
|
||||
console.error(`Error ${e} happened while reading ${file.name}: ${e.target.result}`);
|
||||
reject(new Error(`Error reading ${file.name}: ${e.target.result}`));
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
|
||||
// Custom inputs with validator messages
|
||||
const RenderField = ({ input, label, type, meta }) => {
|
||||
|
|
@ -119,12 +118,9 @@ class EditListingForm extends Component {
|
|||
submitting,
|
||||
} = this.props;
|
||||
const requiredStr = intl.formatMessage({ id: 'EditListingForm.required' });
|
||||
const maxLengthStr = intl.formatMessage(
|
||||
{ id: 'EditListingForm.maxLength' },
|
||||
{
|
||||
maxLength: TITLE_MAX_LENGTH,
|
||||
},
|
||||
);
|
||||
const maxLengthStr = intl.formatMessage({ id: 'EditListingForm.maxLength' }, {
|
||||
maxLength: TITLE_MAX_LENGTH,
|
||||
});
|
||||
const maxLength60 = maxLength(maxLengthStr, TITLE_MAX_LENGTH);
|
||||
const imageRequiredStr = intl.formatMessage({ id: 'EditListingForm.imageRequired' });
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@ import { HeroSearchForm } from '../../containers';
|
|||
import { changeLocationFilter } from '../../ducks/LocationFilter.duck';
|
||||
import css from './LandingPage.css';
|
||||
|
||||
const createSubmitHandler = onLocationChanged =>
|
||||
formData => {
|
||||
onLocationChanged(formData.location);
|
||||
};
|
||||
const createSubmitHandler = onLocationChanged => formData => {
|
||||
onLocationChanged(formData.location);
|
||||
};
|
||||
|
||||
export const LandingPageComponent = props => {
|
||||
const { onLocationChanged, filter } = props;
|
||||
|
|
|
|||
|
|
@ -80,20 +80,19 @@ export const loadListings = {
|
|||
# { id: 123, type: 'user', attributes: { name: "John" }},
|
||||
```
|
||||
*/
|
||||
const lookupMap = included =>
|
||||
included.reduce(
|
||||
(memo, resource) => {
|
||||
const { type, id } = resource;
|
||||
const lookupMap = included => included.reduce(
|
||||
(memo, resource) => {
|
||||
const { type, id } = resource;
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
memo[type] = memo[type] || {};
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
memo[type][id.uuid] = resource;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
memo[type] = memo[type] || {};
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
memo[type][id.uuid] = resource;
|
||||
|
||||
return memo;
|
||||
},
|
||||
{},
|
||||
);
|
||||
return memo;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
// Format the data as ListingCard component expects it and
|
||||
// add some fake data
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ import { watchAuthInfo, watchAuth } from './ducks/Auth.duck';
|
|||
import { watchLoadListings } from './containers/SearchPage/SearchPage.duck';
|
||||
import { watchSdk } from './ducks/sdk.duck';
|
||||
|
||||
const createRootSaga = sdk =>
|
||||
function* rootSaga() {
|
||||
yield [watchAuthInfo(sdk), watchAuth(sdk), watchLoadListings(sdk), watchSdk(sdk)];
|
||||
};
|
||||
const createRootSaga = sdk => function* rootSaga() {
|
||||
yield [watchAuthInfo(sdk), watchAuth(sdk), watchLoadListings(sdk), watchSdk(sdk)];
|
||||
};
|
||||
|
||||
export default createRootSaga;
|
||||
|
|
|
|||
|
|
@ -30,28 +30,25 @@ const placeBounds = place => {
|
|||
* @return {Promise<util.propTypes.place>} Promise that
|
||||
* resolves to the detailed place, rejects if the request failed
|
||||
*/
|
||||
export const getPlaceDetails = placeId =>
|
||||
new Promise((resolve, reject) => {
|
||||
const serviceStatus = window.google.maps.places.PlacesServiceStatus;
|
||||
const el = document.createElement('div');
|
||||
const service = new window.google.maps.places.PlacesService(el);
|
||||
export const getPlaceDetails = placeId => new Promise((resolve, reject) => {
|
||||
const serviceStatus = window.google.maps.places.PlacesServiceStatus;
|
||||
const el = document.createElement('div');
|
||||
const service = new window.google.maps.places.PlacesService(el);
|
||||
|
||||
service.getDetails({ placeId }, (place, status) => {
|
||||
if (status !== serviceStatus.OK) {
|
||||
reject(
|
||||
new Error(
|
||||
`Could not get details for place id "${placeId}", error status was "${status}"`,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
resolve({
|
||||
address: place.formatted_address,
|
||||
origin: placeOrigin(place),
|
||||
bounds: placeBounds(place),
|
||||
});
|
||||
}
|
||||
});
|
||||
service.getDetails({ placeId }, (place, status) => {
|
||||
if (status !== serviceStatus.OK) {
|
||||
reject(
|
||||
new Error(`Could not get details for place id "${placeId}", error status was "${status}"`),
|
||||
);
|
||||
} else {
|
||||
resolve({
|
||||
address: place.formatted_address,
|
||||
origin: placeOrigin(place),
|
||||
bounds: placeBounds(place),
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const predictionSuccessful = status => {
|
||||
const { OK, ZERO_RESULTS } = window.google.maps.places.PlacesServiceStatus;
|
||||
|
|
@ -67,19 +64,18 @@ const predictionSuccessful = status => {
|
|||
* with the original search query and an array of
|
||||
* `google.maps.places.AutocompletePrediction` objects
|
||||
*/
|
||||
export const getPlacePredictions = search =>
|
||||
new Promise((resolve, reject) => {
|
||||
const service = new window.google.maps.places.AutocompleteService();
|
||||
export const getPlacePredictions = search => new Promise((resolve, reject) => {
|
||||
const service = new window.google.maps.places.AutocompleteService();
|
||||
|
||||
service.getPlacePredictions({ input: search }, (predictions, status) => {
|
||||
if (!predictionSuccessful(status)) {
|
||||
reject(new Error(`Prediction service status not OK: ${status}`));
|
||||
} else {
|
||||
const results = {
|
||||
search,
|
||||
predictions: predictions || [],
|
||||
};
|
||||
resolve(results);
|
||||
}
|
||||
});
|
||||
service.getPlacePredictions({ input: search }, (predictions, status) => {
|
||||
if (!predictionSuccessful(status)) {
|
||||
reject(new Error(`Prediction service status not OK: ${status}`));
|
||||
} else {
|
||||
const results = {
|
||||
search,
|
||||
predictions: predictions || [],
|
||||
};
|
||||
resolve(results);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@ const SUCCESS = 'SUCCESS';
|
|||
const FAILURE = 'FAILURE';
|
||||
|
||||
// response format: { REQUEST: 'baseStr.REQUEST', SUCCESS: 'baseStr.SUCCESS', FAILURE: 'baseStr.FAILURE' }
|
||||
export const createRequestTypes = base =>
|
||||
[REQUEST, SUCCESS, FAILURE].reduce(
|
||||
(acc, type) => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
acc[type] = `${base}.${type}`;
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
export const createRequestTypes = base => [REQUEST, SUCCESS, FAILURE].reduce(
|
||||
(acc, type) => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
acc[type] = `${base}.${type}`;
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
/* eslint-enable import/prefer-default-export */
|
||||
|
|
|
|||
|
|
@ -5,15 +5,13 @@
|
|||
// Redux Form expects and undefined value for a successful validation
|
||||
const VALID = undefined;
|
||||
|
||||
export const required = message =>
|
||||
value => {
|
||||
return value ? VALID : message;
|
||||
};
|
||||
export const required = message => value => {
|
||||
return value ? VALID : message;
|
||||
};
|
||||
|
||||
export const maxLength = (message, maximumLength) =>
|
||||
value => {
|
||||
return !value || value.length <= maximumLength ? VALID : message;
|
||||
};
|
||||
export const maxLength = (message, maximumLength) => value => {
|
||||
return !value || value.length <= maximumLength ? VALID : message;
|
||||
};
|
||||
|
||||
export const noEmptyArray = message => value => {
|
||||
return value && Array.isArray(value) && value.length > 0 ? VALID : message;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue