mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Make listing and user proptypes to work with sparse fields
This commit is contained in:
parent
9eaff734d8
commit
fafefea5ee
1 changed files with 21 additions and 5 deletions
|
|
@ -118,6 +118,17 @@ const userAttributes = shape({
|
|||
}),
|
||||
});
|
||||
|
||||
// Listing queries can include author.
|
||||
// Banned and deleted are not relevant then
|
||||
// since banned and deleted users can't have listings.
|
||||
const authorAttributes = shape({
|
||||
profile: shape({
|
||||
displayName: string.isRequired,
|
||||
abbreviatedName: string.isRequired,
|
||||
bio: string,
|
||||
}),
|
||||
});
|
||||
|
||||
const deletedUserAttributes = shape({
|
||||
deleted: propTypes.value(true).isRequired,
|
||||
});
|
||||
|
|
@ -130,7 +141,12 @@ const bannedUserAttributes = shape({
|
|||
propTypes.user = shape({
|
||||
id: propTypes.uuid.isRequired,
|
||||
type: propTypes.value('user').isRequired,
|
||||
attributes: oneOfType([userAttributes, deletedUserAttributes, bannedUserAttributes]).isRequired,
|
||||
attributes: oneOfType([
|
||||
userAttributes,
|
||||
authorAttributes,
|
||||
deletedUserAttributes,
|
||||
bannedUserAttributes,
|
||||
]).isRequired,
|
||||
profileImage: propTypes.image,
|
||||
});
|
||||
|
||||
|
|
@ -148,12 +164,12 @@ const LISTING_STATES = [
|
|||
|
||||
const listingAttributes = shape({
|
||||
title: string.isRequired,
|
||||
description: string.isRequired,
|
||||
description: string,
|
||||
geolocation: propTypes.latlng,
|
||||
deleted: propTypes.value(false).isRequired,
|
||||
state: oneOf(LISTING_STATES).isRequired,
|
||||
deleted: propTypes.value(false),
|
||||
state: oneOf(LISTING_STATES),
|
||||
price: propTypes.money,
|
||||
publicData: object.isRequired,
|
||||
publicData: object,
|
||||
});
|
||||
|
||||
const AVAILABILITY_PLAN_DAY = 'availability-plan/day';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue