-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2430 from jcamposmk/DAT-1633-plan-selection-screen
Dat 1633 plan selection screen
- Loading branch information
Showing
52 changed files
with
2,784 additions
and
294 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"arrowParens": "always" | ||
} | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"arrowParens": "always" | ||
} |
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
96 changes: 96 additions & 0 deletions
96
src/components/BuyProcess/PlanSelection/BannerUpgrade/index.js
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,96 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
import { Link } from 'react-router-dom'; | ||
import { PLAN_TYPE, URL_PLAN_TYPE } from '../../../../doppler-types'; | ||
|
||
export const BannerUpgrade = ({ currentPlan, currentPlanList, planTypes, hightestPlan }) => { | ||
const currentPlanSelected = currentPlan?.id === currentPlanList[currentPlanList.length - 1]?.id; | ||
|
||
if (currentPlanSelected && currentPlan) { | ||
const upgradeInfo = getUpgradeInfo(currentPlan?.type, planTypes); | ||
|
||
if (hightestPlan) { | ||
return ( | ||
<div | ||
className="dp-message-upgrade-plan m-t-24 m-b-24" | ||
data-testid="dp-message-upgrade-plan" | ||
> | ||
<p> | ||
<FormattedMessage | ||
id={upgradeInfo.suggestion.messageId} | ||
values={{ | ||
Link: (chunk) => <Link to={upgradeInfo.suggestion.link}>{chunk}</Link>, | ||
Bold: (chunk) => <strong>{chunk}</strong>, | ||
}} | ||
/> | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="dp-calc-message" data-testid="dp-calc-message"> | ||
<p> | ||
<FormattedMessage | ||
id={upgradeInfo.banner.messageId} | ||
values={{ | ||
Link: (chunk) => <Link to={upgradeInfo.banner.link}>{chunk}</Link>, | ||
}} | ||
/> | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export const getUpgradeInfo = (type, planTypes) => { | ||
const bannerInfo = { | ||
messageId: `plan_calculator.banner_for_${type.replace('-', '_')}`, | ||
link: `/plan-selection/premium/${URL_PLAN_TYPE[PLAN_TYPE.byEmail]}${window.location.search}`, | ||
}; | ||
const suggestionInfo = { | ||
messageId: `plan_calculator.suggestion_for_${type.replace('-', '_')}`, | ||
link: `/upgrade-suggestion-form`, | ||
}; | ||
|
||
switch (type) { | ||
case PLAN_TYPE.byCredit: | ||
case PLAN_TYPE.byContact: | ||
if (planTypes?.includes(PLAN_TYPE.byEmail)) { | ||
return { banner: bannerInfo, suggestion: suggestionInfo }; | ||
} else { | ||
const subscriberMonthlyPlan = { | ||
...suggestionInfo, | ||
messageId: 'plan_calculator.advice_for_subscribers_large_plan', | ||
}; | ||
return { | ||
banner: subscriberMonthlyPlan, | ||
suggestion: subscriberMonthlyPlan, | ||
}; | ||
} | ||
|
||
case PLAN_TYPE.byEmail: | ||
return { | ||
banner: { | ||
...bannerInfo, | ||
link: `/upgrade-suggestion-form`, | ||
}, | ||
suggestion: { | ||
...suggestionInfo, | ||
link: `/plan-selection/premium/${URL_PLAN_TYPE[PLAN_TYPE.byEmail]}`, | ||
}, | ||
}; | ||
default: | ||
return { | ||
banner: { | ||
...bannerInfo, | ||
messageId: `plan_calculator.banner_for_unknown`, | ||
}, | ||
suggestion: { | ||
...suggestionInfo, | ||
messageId: `plan_calculator.suggestion_for_unknown`, | ||
}, | ||
}; | ||
} | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/components/BuyProcess/PlanSelection/GoBackButton/index.js
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,16 @@ | ||
import { useIntl } from 'react-intl'; | ||
|
||
export const GoBackButton = () => { | ||
const intl = useIntl(); | ||
const _ = (id, values) => intl.formatMessage({ id: id }, values); | ||
|
||
return ( | ||
<button | ||
type="button" | ||
className="dp-button button-medium ctaTertiary" | ||
onClick={() => window.history.back()} | ||
> | ||
{_('plan_calculator.button_back')} | ||
</button> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
src/components/BuyProcess/PlanSelection/SubscriptionType/index.js
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,21 @@ | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessageMarkdown } from '../../../../i18n/FormattedMessageMarkdown'; | ||
|
||
export const SubscriptionType = ({ period, discountPercentage }) => { | ||
return ( | ||
<div className="dp-align--center p-t-30"> | ||
<div className="p-b-6"> | ||
<FormattedMessageMarkdown id="plan_calculator.current_subscription" values={{ period }} /> | ||
</div> | ||
<FormattedMessageMarkdown | ||
id="plan_calculator.subscription_discount" | ||
values={{ discountPercentage }} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
SubscriptionType.propTypes = { | ||
period: PropTypes.oneOf([1, 3, 6, 12]), | ||
discountPercentage: PropTypes.number, | ||
}; |
19 changes: 19 additions & 0 deletions
19
src/components/BuyProcess/PlanSelection/SubscriptionType/index.test.js
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,19 @@ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { SubscriptionType } from '.'; | ||
import IntlProvider from '../../../../i18n/DopplerIntlProvider.double-with-ids-as-values'; | ||
|
||
describe('SuscriptionType', () => { | ||
it(`should render SuscriptionType`, async () => { | ||
// Act | ||
render( | ||
<IntlProvider> | ||
<SubscriptionType period={3} discountPercentage={5} /> | ||
</IntlProvider>, | ||
); | ||
|
||
// Assert | ||
screen.getByText('plan_calculator.current_subscription'); | ||
screen.getByText('plan_calculator.subscription_discount'); | ||
}); | ||
}); |
Oops, something went wrong.