From 565a32f3c947d05d7ab727152c570af6cdc8dbc6 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Wed, 18 Apr 2018 15:38:00 +0300 Subject: [PATCH] Rename transition/review/message attribute `at` to `createdAt` --- .../ActivityFeed/ActivityFeed.example.js | 52 +++++++++---------- src/components/ActivityFeed/ActivityFeed.js | 14 +++-- .../BookingBreakdown.example.js | 2 +- .../BookingBreakdown/BookingBreakdown.test.js | 2 +- src/components/Reviews/Reviews.js | 2 +- .../EstimatedBreakdownMaybe.js | 2 +- src/util/test-data.js | 10 ++-- src/util/types.js | 6 +-- 8 files changed, 47 insertions(+), 43 deletions(-) diff --git a/src/components/ActivityFeed/ActivityFeed.example.js b/src/components/ActivityFeed/ActivityFeed.example.js index 81679255..8d94c2e2 100644 --- a/src/components/ActivityFeed/ActivityFeed.example.js +++ b/src/components/ActivityFeed/ActivityFeed.example.js @@ -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', diff --git a/src/components/ActivityFeed/ActivityFeed.js b/src/components/ActivityFeed/ActivityFeed.js index ef77ac58..9a88c64e 100644 --- a/src/components/ActivityFeed/ActivityFeed.js +++ b/src/components/ActivityFeed/ActivityFeed.js @@ -35,7 +35,9 @@ const Message = props => {

{message.attributes.content}

-

{formatDate(intl, todayString, message.attributes.at)}

+

+ {formatDate(intl, todayString, message.attributes.createdAt)} +

); @@ -54,7 +56,9 @@ const OwnMessage = props => {

{message.attributes.content}

-

{formatDate(intl, todayString, message.attributes.at)}

+

+ {formatDate(intl, todayString, message.attributes.createdAt)} +

); }; @@ -292,7 +296,7 @@ const Transition = props => {

{transitionMessage}

-

{formatDate(intl, todayString, transition.at)}

+

{formatDate(intl, todayString, transition.createdAt)}

{reviewComponent}
@@ -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); }; diff --git a/src/components/BookingBreakdown/BookingBreakdown.example.js b/src/components/BookingBreakdown/BookingBreakdown.example.js index 774f412b..ef262952 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.example.js +++ b/src/components/BookingBreakdown/BookingBreakdown.example.js @@ -38,7 +38,7 @@ const exampleTransaction = params => { lastTransition: TRANSITION_REQUEST, transitions: [ { - at: created, + createdAt: created, by: TX_TRANSITION_ACTOR_CUSTOMER, transition: TRANSITION_REQUEST, }, diff --git a/src/components/BookingBreakdown/BookingBreakdown.test.js b/src/components/BookingBreakdown/BookingBreakdown.test.js index bcef62dd..b4263d54 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.test.js +++ b/src/components/BookingBreakdown/BookingBreakdown.test.js @@ -24,7 +24,7 @@ const exampleTransaction = params => { lastTransition: TRANSITION_REQUEST, transitions: [ { - at: created, + createdAt: created, by: TX_TRANSITION_ACTOR_CUSTOMER, transition: TRANSITION_REQUEST, }, diff --git a/src/components/Reviews/Reviews.js b/src/components/Reviews/Reviews.js index 0757d752..79572233 100644 --- a/src/components/Reviews/Reviews.js +++ b/src/components/Reviews/Reviews.js @@ -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 ( diff --git a/src/containers/BookingDatesForm/EstimatedBreakdownMaybe.js b/src/containers/BookingDatesForm/EstimatedBreakdownMaybe.js index 5c480102..006e3a9a 100644 --- a/src/containers/BookingDatesForm/EstimatedBreakdownMaybe.js +++ b/src/containers/BookingDatesForm/EstimatedBreakdownMaybe.js @@ -104,7 +104,7 @@ const estimatedTransaction = (unitType, bookingStart, bookingEnd, unitPrice, qua ], transitions: [ { - at: now, + createdAt: now, by: TX_TRANSITION_ACTOR_CUSTOMER, transition: TRANSITION_REQUEST, }, diff --git a/src/util/test-data.js b/src/util/test-data.js index 8d9607f2..fe40776c 100644 --- a/src/util/test-data.js +++ b/src/util/test-data.js @@ -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, diff --git a/src/util/types.js b/src/util/types.js index 5250541f..2bf4c433 100644 --- a/src/util/types.js +++ b/src/util/types.js @@ -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,