-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement(Receipt): fine-tune for event tickets (#920)
- Loading branch information
Showing
10 changed files
with
162 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { TimeRange } from './TimeRange'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
export const EventDescription = ({ event }) => { | ||
return ( | ||
<React.Fragment> | ||
<FormattedMessage defaultMessage='Registration for "{eventName}"' values={{ eventName: event.name }} /> | ||
{'. '} | ||
|
||
{event.startsAt && ( | ||
<React.Fragment> | ||
<FormattedMessage defaultMessage="Date:" /> | ||
| ||
<TimeRange startsAt={event.startsAt} endsAt={event.endsAt} timezone={event.timezone} /> | ||
</React.Fragment> | ||
)} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
EventDescription.propTypes = { | ||
event: PropTypes.shape({ | ||
startsAt: PropTypes.string, | ||
endsAt: PropTypes.string, | ||
timezone: PropTypes.string, | ||
name: PropTypes.string, | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FormattedDate, FormattedTime } from 'react-intl'; | ||
import dayjs from '../lib/dayjs'; | ||
|
||
const FormattedDateProps = (value, timeZone) => ({ | ||
value, | ||
weekday: 'long', | ||
day: 'numeric', | ||
month: 'long', | ||
year: 'numeric', | ||
timeZone, | ||
}); | ||
|
||
const FormattedTimeProps = (value, timeZone) => ({ | ||
value, | ||
timeZone, | ||
}); | ||
|
||
const getIsSameDay = (startsAt, endsAt, timezone) => { | ||
if (!endsAt) { | ||
return true; | ||
} | ||
const tzStartsAt = dayjs.tz(new Date(startsAt), timezone); | ||
const tzEndsAt = dayjs.tz(new Date(endsAt), timezone); | ||
return tzStartsAt.isSame(tzEndsAt, 'day'); | ||
}; | ||
|
||
export const TimeRange = ({ startsAt, endsAt, timezone }) => { | ||
const isSameDay = getIsSameDay(startsAt, endsAt, timezone); | ||
return ( | ||
<Fragment> | ||
<FormattedDate {...FormattedDateProps(startsAt, timezone)} /> | ||
, <FormattedTime {...FormattedTimeProps(startsAt, timezone)} />{' '} | ||
{endsAt && ( | ||
<Fragment> | ||
-{' '} | ||
{!isSameDay && ( | ||
<Fragment> | ||
<FormattedDate {...FormattedDateProps(endsAt, timezone)} />,{' '} | ||
</Fragment> | ||
)} | ||
<FormattedTime {...FormattedTimeProps(endsAt, timezone)} />{' '} | ||
</Fragment> | ||
)} | ||
(UTC{dayjs().tz(timezone).format('Z')}) | ||
</Fragment> | ||
); | ||
}; | ||
|
||
TimeRange.propTypes = { | ||
startsAt: PropTypes.string, | ||
endsAt: PropTypes.string, | ||
timezone: PropTypes.string.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import dayjs from 'dayjs'; | ||
import utc from 'dayjs/plugin/utc'; | ||
import timezone from 'dayjs/plugin/timezone'; | ||
|
||
dayjs.extend(utc); | ||
dayjs.extend(timezone); | ||
|
||
export default dayjs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
834baa2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
opencollective-pdf – ./
opencollective-pdf-opencollective.vercel.app
opencollective-pdf-git-main-opencollective.vercel.app
opencollective-pdf.vercel.app