mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Rename transition/review/message attribute at to createdAt
This commit is contained in:
parent
7239a66eb6
commit
565a32f3c9
8 changed files with 47 additions and 43 deletions
|
|
@ -81,18 +81,18 @@ export const WithTransitions = {
|
|||
listing: createListing('Listing'),
|
||||
transitions: [
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 8, 10)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 8, 10)),
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 8, 12)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 8, 12)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_ACCEPT,
|
||||
}),
|
||||
// this should not be visible in the feed
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 16, 8, 12)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 16, 8, 12)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_EXPIRE_REVIEW_PERIOD,
|
||||
}),
|
||||
|
|
@ -118,32 +118,32 @@ export const WithMessagesTransitionsAndReviews = {
|
|||
lastTransition: TRANSITION_REVIEW_2_BY_CUSTOMER,
|
||||
transitions: [
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 8, 10)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 8, 10)),
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 8, 12)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 8, 12)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_ACCEPT,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 10, 33)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 10, 33)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_DECLINE,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 10, 34)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 10, 34)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_COMPLETE,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 11, 34)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 11, 34)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_REVIEW_1_BY_PROVIDER,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 12, 34)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 12, 34)),
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REVIEW_2_BY_CUSTOMER,
|
||||
}),
|
||||
|
|
@ -151,12 +151,12 @@ export const WithMessagesTransitionsAndReviews = {
|
|||
reviews: [
|
||||
createReview(
|
||||
'review1',
|
||||
{ at: new Date(Date.UTC(2017, 10, 9, 11, 34)), rating: 3, type: 'ofCustomer' },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 9, 11, 34)), rating: 3, type: 'ofCustomer' },
|
||||
{ author: createUser('user2'), subject: createUser('user1') }
|
||||
),
|
||||
createReview(
|
||||
'review2',
|
||||
{ at: new Date(Date.UTC(2017, 10, 9, 12, 34)), rating: 5, type: 'ofProvider' },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 9, 12, 34)), rating: 5, type: 'ofProvider' },
|
||||
{ author: createUser('user1'), subject: createUser('user2') }
|
||||
),
|
||||
],
|
||||
|
|
@ -164,22 +164,22 @@ export const WithMessagesTransitionsAndReviews = {
|
|||
messages: [
|
||||
createMessage(
|
||||
'msg1',
|
||||
{ at: new Date(Date.UTC(2017, 10, 9, 8, 11)) },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 9, 8, 11)) },
|
||||
{ sender: createUser('user1') }
|
||||
),
|
||||
createMessage(
|
||||
'msg2',
|
||||
{ at: new Date(Date.UTC(2017, 10, 9, 8, 14)) },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 9, 8, 14)) },
|
||||
{ sender: createUser('user1') }
|
||||
),
|
||||
createMessage(
|
||||
'msg3',
|
||||
{ at: new Date(Date.UTC(2017, 10, 9, 8, 17)) },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 9, 8, 17)) },
|
||||
{ sender: createUser('user2') }
|
||||
),
|
||||
createMessage(
|
||||
'msg4',
|
||||
{ at: new Date(Date.UTC(2017, 10, 12, 13, 20)) },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 12, 13, 20)) },
|
||||
{ sender: createUser('user2') }
|
||||
),
|
||||
],
|
||||
|
|
@ -202,24 +202,24 @@ export const WithAReviewFromBothUsers = {
|
|||
reviews: [
|
||||
createReview(
|
||||
'review1',
|
||||
{ at: new Date(Date.UTC(2017, 10, 9, 8, 10)), rating: 3, type: 'ofProvider' },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 9, 8, 10)), rating: 3, type: 'ofProvider' },
|
||||
{ author: createUser('user1'), subject: createUser('user2') }
|
||||
),
|
||||
createReview(
|
||||
'review2',
|
||||
{ at: new Date(Date.UTC(2017, 10, 10, 8, 10)), rating: 5, type: 'ofCustomer' },
|
||||
{ createdAt: new Date(Date.UTC(2017, 10, 10, 8, 10)), rating: 5, type: 'ofCustomer' },
|
||||
{ author: createUser('user2'), subject: createUser('user1') }
|
||||
),
|
||||
],
|
||||
lastTransition: TRANSITION_REVIEW_2_BY_PROVIDER,
|
||||
transitions: [
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 9, 8, 10)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 8, 10)),
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REVIEW_1_BY_CUSTOMER,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 10, 10, 8, 10)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 10, 8, 10)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_REVIEW_2_BY_PROVIDER,
|
||||
}),
|
||||
|
|
@ -255,12 +255,12 @@ class PagedFeed extends Component {
|
|||
const provider = createUser('provider');
|
||||
|
||||
const trans1 = createTxTransition({
|
||||
at: dates[0],
|
||||
createdAt: dates[0],
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
});
|
||||
const trans2 = createTxTransition({
|
||||
at: dates[2],
|
||||
createdAt: dates[2],
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_ACCEPT,
|
||||
});
|
||||
|
|
@ -268,18 +268,18 @@ class PagedFeed extends Component {
|
|||
// Last transition timestamp is interleaved between the last two
|
||||
// messages.
|
||||
const trans3 = createTxTransition({
|
||||
at: dates[5],
|
||||
createdAt: dates[5],
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_COMPLETE,
|
||||
});
|
||||
|
||||
// First message timestamp is interleaved between the first two
|
||||
// transitions.
|
||||
const msg1 = createMessage('msg1', { at: dates[1] }, { sender: customer });
|
||||
const msg1 = createMessage('msg1', { createdAt: dates[1] }, { sender: customer });
|
||||
|
||||
const msg2 = createMessage('msg2', { at: dates[3] }, { sender: provider });
|
||||
const msg3 = createMessage('msg3', { at: dates[4] }, { sender: customer });
|
||||
const msg4 = createMessage('msg4', { at: dates[6] }, { sender: customer });
|
||||
const msg2 = createMessage('msg2', { createdAt: dates[3] }, { sender: provider });
|
||||
const msg3 = createMessage('msg3', { createdAt: dates[4] }, { sender: customer });
|
||||
const msg4 = createMessage('msg4', { createdAt: dates[6] }, { sender: customer });
|
||||
|
||||
const transaction = createTransaction({
|
||||
id: 'tx1',
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ const Message = props => {
|
|||
<Avatar className={css.avatar} user={message.sender} />
|
||||
<div>
|
||||
<p className={css.messageContent}>{message.attributes.content}</p>
|
||||
<p className={css.messageDate}>{formatDate(intl, todayString, message.attributes.at)}</p>
|
||||
<p className={css.messageDate}>
|
||||
{formatDate(intl, todayString, message.attributes.createdAt)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
@ -54,7 +56,9 @@ const OwnMessage = props => {
|
|||
<div className={css.ownMessageContentWrapper}>
|
||||
<p className={css.ownMessageContent}>{message.attributes.content}</p>
|
||||
</div>
|
||||
<p className={css.ownMessageDate}>{formatDate(intl, todayString, message.attributes.at)}</p>
|
||||
<p className={css.ownMessageDate}>
|
||||
{formatDate(intl, todayString, message.attributes.createdAt)}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -292,7 +296,7 @@ const Transition = props => {
|
|||
</div>
|
||||
<div>
|
||||
<p className={css.transitionContent}>{transitionMessage}</p>
|
||||
<p className={css.transitionDate}>{formatDate(intl, todayString, transition.at)}</p>
|
||||
<p className={css.transitionDate}>{formatDate(intl, todayString, transition.createdAt)}</p>
|
||||
{reviewComponent}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -323,9 +327,9 @@ const EmptyTransition = () => {
|
|||
|
||||
const isMessage = item => item && item.type === 'message';
|
||||
|
||||
// Compare function for sorting an array containint messages and transitions
|
||||
// Compare function for sorting an array containing messages and transitions
|
||||
const compareItems = (a, b) => {
|
||||
const itemDate = item => (isMessage(item) ? item.attributes.at : item.at);
|
||||
const itemDate = item => (isMessage(item) ? item.attributes.createdAt : item.createdAt);
|
||||
return itemDate(a) - itemDate(b);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const exampleTransaction = params => {
|
|||
lastTransition: TRANSITION_REQUEST,
|
||||
transitions: [
|
||||
{
|
||||
at: created,
|
||||
createdAt: created,
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ const exampleTransaction = params => {
|
|||
lastTransition: TRANSITION_REQUEST,
|
||||
transitions: [
|
||||
{
|
||||
at: created,
|
||||
createdAt: created,
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import css from './Reviews.css';
|
|||
const Review = props => {
|
||||
const { review, intl } = props;
|
||||
|
||||
const date = review.attributes.at;
|
||||
const date = review.attributes.createdAt;
|
||||
const dateString = intl.formatDate(date, { month: 'long', year: 'numeric' });
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ const estimatedTransaction = (unitType, bookingStart, bookingEnd, unitPrice, qua
|
|||
],
|
||||
transitions: [
|
||||
{
|
||||
at: now,
|
||||
createdAt: now,
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ export const createOwnListing = (id, attributes = {}, includes = {}) => ({
|
|||
|
||||
export const createTxTransition = options => {
|
||||
return {
|
||||
at: new Date(Date.UTC(2017, 4, 1)),
|
||||
createdAt: new Date(Date.UTC(2017, 4, 1)),
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
...options,
|
||||
|
|
@ -135,12 +135,12 @@ export const createTransaction = options => {
|
|||
lastTransitionedAt = new Date(Date.UTC(2017, 5, 1)),
|
||||
transitions = [
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 4, 1)),
|
||||
createdAt: new Date(Date.UTC(2017, 4, 1)),
|
||||
by: TX_TRANSITION_ACTOR_CUSTOMER,
|
||||
transition: TRANSITION_REQUEST,
|
||||
}),
|
||||
createTxTransition({
|
||||
at: new Date(Date.UTC(2017, 5, 1)),
|
||||
createdAt: new Date(Date.UTC(2017, 5, 1)),
|
||||
by: TX_TRANSITION_ACTOR_PROVIDER,
|
||||
transition: TRANSITION_ACCEPT,
|
||||
}),
|
||||
|
|
@ -188,7 +188,7 @@ export const createMessage = (id, attributes = {}, includes = {}) => {
|
|||
id: new UUID(id),
|
||||
type: 'message',
|
||||
attributes: {
|
||||
at: new Date(Date.UTC(2017, 10, 9, 8, 12)),
|
||||
createdAt: new Date(Date.UTC(2017, 10, 9, 8, 12)),
|
||||
content: `Message ${id}\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.`,
|
||||
...attributes,
|
||||
},
|
||||
|
|
@ -200,7 +200,7 @@ export const createReview = (id, attributes = {}, includes = {}) => {
|
|||
return {
|
||||
id: new UUID(id),
|
||||
attributes: {
|
||||
at: new Date(),
|
||||
createdAt: new Date(),
|
||||
content:
|
||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
||||
rating: 3,
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ export const txHasFirstReview = tx => firstReviewTransitions.includes(txLastTran
|
|||
export const txIsReviewed = tx => areReviewsCompleted(txLastTransition(tx));
|
||||
|
||||
propTypes.transition = shape({
|
||||
at: instanceOf(Date).isRequired,
|
||||
createdAt: instanceOf(Date).isRequired,
|
||||
by: oneOf(TX_TRANSITION_ACTORS).isRequired,
|
||||
transition: oneOf(TRANSITIONS).isRequired,
|
||||
});
|
||||
|
|
@ -323,7 +323,7 @@ export const REVIEW_TYPE_OF_CUSTOMER = 'ofCustomer';
|
|||
propTypes.review = shape({
|
||||
id: propTypes.uuid.isRequired,
|
||||
attributes: shape({
|
||||
at: instanceOf(Date).isRequired,
|
||||
createdAt: instanceOf(Date).isRequired,
|
||||
content: string,
|
||||
rating: oneOf(REVIEW_RATINGS),
|
||||
state: string.isRequired,
|
||||
|
|
@ -387,7 +387,7 @@ propTypes.message = shape({
|
|||
id: propTypes.uuid.isRequired,
|
||||
type: propTypes.value('message').isRequired,
|
||||
attributes: shape({
|
||||
at: instanceOf(Date).isRequired,
|
||||
createdAt: instanceOf(Date).isRequired,
|
||||
content: string.isRequired,
|
||||
}).isRequired,
|
||||
sender: propTypes.user,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue