Skip to content

Commit

Permalink
scandipwa#3780 - Create confirm newsletter subscription page
Browse files Browse the repository at this point in the history
  • Loading branch information
IrinaZhadzinets committed Jul 21, 2022
1 parent 2e50918 commit b403255
Show file tree
Hide file tree
Showing 25 changed files with 386 additions and 17 deletions.
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/da_DK.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/fa_IR.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/fi_FI.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/lv_LV.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/nb_NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/nl_NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/sl_SI.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/sv_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/tr_TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
6 changes: 5 additions & 1 deletion packages/scandipwa/i18n/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,9 @@
"Send Confirmation Action": null,
"This email does not require confirmation.": null,
"Remove file": null,
"Region": null
"Region": null,
"Confirm Newsletter Page": null,
"Confirm subscription": null,
"Unable to confirm subscrabition": null,
"Thank you for subscribing to our newsletter!": null
}
7 changes: 7 additions & 0 deletions packages/scandipwa/src/component/Router/Router.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
CMS_PAGE,
COMPARE,
CONFIRM_ACCOUNT,
CONFIRM_NEWSLETTER,
CONTACT_PAGE,
COOKIE_POPUP,
CREATE_ACCOUNT,
Expand Down Expand Up @@ -93,6 +94,7 @@ export const PasswordChangePage = lazy(() => import(/* webpackMode: "lazy", webp
export const SearchPage = lazy(() => import(/* webpackMode: "lazy", webpackChunkName: "search" */ 'Route/SearchPage'));
export const SendConfirmationPage = lazy(() => import(/* webpackMode: "lazy", webpackChunkName: "cms" */ 'Route/SendConfirmationPage'));
export const ConfirmAccountPage = lazy(() => import(/* webpackMode: "lazy", webpackChunkName: "cms" */ 'Route/ConfirmAccountPage'));
export const ConfirmNewsletterPage = lazy(() => import(/* webpackMode: "lazy", webpackChunkName: "cms" */ 'Route/ConfirmNewsletterPage'));
export const MenuPage = lazy(() => import(/* webpackMode: "lazy", webpackChunkName: "cms" */ 'Route/MenuPage'));
export const Footer = lazy(() => import(/* webpackMode: "lazy", webpackChunkName: "footer" */ 'Component/Footer'));
export const NavigationTabs = lazy(() => import(/* webpackMode: "lazy", webpackChunkName: "header" */ 'Component/NavigationTabs'));
Expand Down Expand Up @@ -309,6 +311,11 @@ export class Router extends PureComponent {
position: 95,
name: PRINT_ORDER
},
{
component: <Route path={ withStoreRegex('/newsletter/subscriber/confirm/:id?/code/:code?') } render={ (props) => <ConfirmNewsletterPage { ...props } /> } />,
position: 100,
name: CONFIRM_NEWSLETTER
},
{
component: <Route render={ (props) => <UrlRewrites { ...props } /> } />,
position: 1000,
Expand Down
1 change: 1 addition & 0 deletions packages/scandipwa/src/component/Router/Router.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const LOGIN = 'LOGIN';
export const ACCOUNT_FORGOT_PASSWORD = 'ACCOUNT_FORGOT_PASSWORD';
export const FORGOT_PASSWORD = 'FORGOT_PASSWORD';
export const CONFIRM_ACCOUNT = 'CONFIRM_ACCOUNT';
export const CONFIRM_NEWSLETTER = 'CONFIRM_NEWSLETTER';
export const MY_ACCOUNT = 'MY_ACCOUNT';
export const MY_ACCOUNT_ORDER = 'MY_ACCOUNT_ORDER';
export const MY_ACCOUNT_ORDERS = 'MY_ACCOUNT_ORDERS';
Expand Down
14 changes: 14 additions & 0 deletions packages/scandipwa/src/query/NewsletterSubscription.query.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ export class NewsletterSubscriptionQuery {
'status'
];
}

confirmSubscribeToNewsletterMutation(id, code) {
return new Field('confirmSubscribingToNewsletter')
.addArgument('id', 'String!', id)
.addArgument('code', 'String!', code)
.addFieldList(this._getConfirmFields());
}

_getConfirmFields() {
return [
'status',
'message'
];
}
}

export default new NewsletterSubscriptionQuery();
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* ScandiPWA - Progressive Web App for Magento
*
* Copyright © Scandiweb, Inc. All rights reserved.
* See LICENSE for license details.
*
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0)
* @package scandipwa/scandipwa
* @link https://github.com/scandipwa/scandipwa
*/

import PropTypes from 'prop-types';
import { PureComponent } from 'react';

import ContentWrapper from 'Component/ContentWrapper';
import Link from 'Component/Link';

import { FAILED_STATUS, SUCCESS_STATUS } from './ConfirmNewsletterPage.config';

import './ConfirmNewsletterPage.style';

/** @namespace Route/ConfirmNewsletterPage/Component */
export class ConfirmNewsletterPage extends PureComponent {
static propTypes = {
status: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
shouldDisplayWarning: PropTypes.bool.isRequired
};

renderWarningMessage() {
const { status, message, shouldDisplayWarning } = this.props;

if (!shouldDisplayWarning && status !== FAILED_STATUS) {
return null;
}

return (
<div block="ConfirmNewsletterPage" elem="WarningMsg">
<h2>
{ __('Unable to confirm subscrabition') }
</h2>
<div>
{ message }
</div>
</div>
);
}

renderButtons() {
return (
<div block="ConfirmNewsletterPage" elem="ButtonWrapper">
<Link
block="Button"
mix={ { block: 'ConfirmNewsletterPage', elem: 'ContinueButton' } }
to="/"
>
{ __('Continue shopping') }
</Link>
</div>
);
}

renderPageContents() {
const { status, message, shouldDisplayWarning } = this.props;

if (shouldDisplayWarning || status !== SUCCESS_STATUS) {
return null;
}

return (
<>
<h1 block="ConfirmNewsletterPage" elem="Heading">
{ message }
</h1>
<h3 block="ConfirmNewsletterPage" elem="Message">
{ __('Thank you for subscribing to our newsletter!') }
</h3>
{ this.renderButtons() }
</>
);
}

render() {
return (
<main block="ConfirmNewsletterPage" aria-label={ __('Confirm Newsletter Page') }>
<ContentWrapper
wrapperMix={ { block: 'ConfirmNewsletterPage', elem: 'Wrapper' } }
>
{ this.renderWarningMessage() }
{ this.renderPageContents() }
</ContentWrapper>
</main>
);
}
}

export default ConfirmNewsletterPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* ScandiPWA - Progressive Web App for Magento
*
* Copyright © Scandiweb, Inc. All rights reserved.
* See LICENSE for license details.
*
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0)
* @package scandipwa/scandipwa
* @link https://github.com/scandipwa/scandipwa
*/

export const SUCCESS_STATUS = 'success';
export const FAILED_STATUS = 'failed';
Loading

0 comments on commit b403255

Please sign in to comment.