-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7766961
commit ac21318
Showing
11 changed files
with
109 additions
and
35 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { createMailtoUrl } from './share-link-actions'; | ||
import { ShareType, UrlType } from './constants'; | ||
|
||
const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | ||
|
||
export const showGiftUrlSection = (props) => ({ | ||
shareType: ShareType.gift, | ||
url: props.urls.gift || props.urls.dummy, | ||
urlType: props.urls.gift ? UrlType.gift : UrlType.dummy, | ||
mailtoUrl: props.mailtoUrls.gift, | ||
showCopyConfirmation: false | ||
}); | ||
|
||
export const showNonGiftUrlSection = (props) => ({ | ||
shareType: ShareType.nonGift, | ||
url: props.urls.nonGift, | ||
urlType: UrlType.nonGift, | ||
mailtoUrl: props.mailtoUrls.nonGift, | ||
showCopyConfirmation: false | ||
}); | ||
|
||
export const setGiftUrl = (url, redemptionLimit, isShortened) => { | ||
const mailtoUrl = createMailtoUrl(this.articleTitle, url); | ||
|
||
return props => ({ | ||
url, | ||
mailtoUrl, | ||
redemptionLimit, | ||
isGiftUrlCreated: true, | ||
isGiftUrlShortened: isShortened, | ||
urlType: UrlType.gift, | ||
|
||
urls: Object.assign(props.urls, { | ||
gift: url, | ||
}), | ||
|
||
mailtoUrls: Object.assign(props.mailtoUrls, { | ||
gift: mailtoUrl, | ||
}) | ||
}); | ||
}; | ||
|
||
export const setAllowance = (giftCredits, monthlyAllowance, nextRenewalDate) => { | ||
const date = new Date(nextRenewalDate); | ||
const nextRenewalDateText = `${ monthNames[date.getMonth()] } ${ date.getDate() }`; | ||
|
||
return { | ||
giftCredits, | ||
monthlyAllowance, | ||
nextRenewalDateText | ||
}; | ||
}; | ||
|
||
export const setShortenedNonGiftUrl = (shortenedUrl) => props => { | ||
const mailtoUrl = createMailtoUrl(props.articleTitle, shortenedUrl); | ||
|
||
return { | ||
url: shortenedUrl, | ||
mailtoUrl: mailtoUrl, | ||
isNonGiftUrlShortened: true, | ||
|
||
urls: Object.assign(props.urls, { | ||
gift: shortenedUrl, | ||
}), | ||
|
||
mailtoUrls: Object.assign(props.mailtoUrls, { | ||
gift: mailtoUrl, | ||
}) | ||
}; | ||
}; |
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