Skip to content

Commit f6ff5ee

Browse files
committed
Move CustomerEffortScorePrompt from product-feed/ to components/
And make it more general so it can be a shared component
1 parent 70e8d5a commit f6ff5ee

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

js/src/product-feed/customer-effort-score-prompt/index.js renamed to js/src/components/customer-effort-score-prompt/index.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
import { __ } from '@wordpress/i18n';
55
import CustomerEffortScore from '@woocommerce/customer-effort-score';
66
import { recordEvent } from '@woocommerce/tracks';
7+
import PropTypes from 'prop-types';
78

89
/**
910
* Internal dependencies
1011
*/
1112
import { LOCAL_STORAGE_KEYS } from '.~/constants';
1213
import localStorage from '.~/utils/localStorage';
1314

14-
const EVENT_CONTEXT = 'gla-setup';
15-
16-
export default function CustomerEffortScorePrompt() {
15+
const CustomerEffortScorePrompt = ( { eventContext, label } ) => {
1716
const removeCESPromptFlagFromLocal = () => {
1817
localStorage.remove(
1918
LOCAL_STORAGE_KEYS.CAN_ONBOARDING_SETUP_CES_PROMPT_OPEN
@@ -22,38 +21,35 @@ export default function CustomerEffortScorePrompt() {
2221

2322
const onNoticeShown = () => {
2423
recordEvent( 'gla_ces_snackbar_open', {
25-
context: EVENT_CONTEXT,
24+
context: eventContext,
2625
} );
2726
};
2827

2928
const onNoticeDismissed = () => {
3029
removeCESPromptFlagFromLocal();
3130
recordEvent( 'gla_ces_snackbar_closed', {
32-
context: EVENT_CONTEXT,
31+
context: eventContext,
3332
} );
3433
};
3534

3635
const onModalShown = () => {
3736
removeCESPromptFlagFromLocal();
3837
recordEvent( 'gla_ces_modal_open', {
39-
context: EVENT_CONTEXT,
38+
context: eventContext,
4039
} );
4140
};
4241

4342
const recordScore = ( score, comments ) => {
4443
recordEvent( 'gla_ces_feedback', {
45-
context: EVENT_CONTEXT,
44+
context: eventContext,
4645
score,
4746
comments: comments || '',
4847
} );
4948
};
5049

5150
return (
5251
<CustomerEffortScore
53-
label={ __(
54-
'How easy was it to set up Google Listings & Ads?',
55-
'google-listings-and-ads'
56-
) }
52+
label={ label }
5753
recordScoreCallback={ recordScore }
5854
onNoticeShownCallback={ onNoticeShown }
5955
onNoticeDismissedCallback={ onNoticeDismissed }
@@ -72,4 +68,11 @@ export default function CustomerEffortScorePrompt() {
7268
}
7369
/>
7470
);
75-
}
71+
};
72+
73+
CustomerEffortScorePrompt.propTypes = {
74+
label: PropTypes.string.isRequired,
75+
eventContext: PropTypes.string.isRequired,
76+
};
77+
78+
export default CustomerEffortScorePrompt;

js/src/product-feed/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import NavigationClassic from '.~/components/navigation-classic';
1111
import IssuesTableCard from './issues-table-card';
1212
import ProductFeedTableCard from './product-feed-table-card';
1313
import SubmissionSuccessGuide from './submission-success-guide';
14-
import CustomerEffortScorePrompt from './customer-effort-score-prompt';
14+
import CustomerEffortScorePrompt from '.~/components/customer-effort-score-prompt';
1515
import ProductStatistics from './product-statistics';
1616
import './index.scss';
1717
import useProductFeedPrefetch from './useProductFeedPrefetch';
@@ -41,7 +41,15 @@ const ProductFeed = () => {
4141
<>
4242
<NavigationClassic />
4343
{ isSubmissionSuccessOpen && <SubmissionSuccessGuide /> }
44-
{ shouldOpenCESPrompt && <CustomerEffortScorePrompt /> }
44+
{ shouldOpenCESPrompt && (
45+
<CustomerEffortScorePrompt
46+
label={ __(
47+
'How easy was it to set up Google Listings & Ads?',
48+
'google-listings-and-ads'
49+
) }
50+
eventContext="gla-setup"
51+
/>
52+
) }
4553
<div className="gla-product-feed">
4654
{ ! hasFinishedResolution && <AppSpinner /> }
4755
{ hasFinishedResolution &&

0 commit comments

Comments
 (0)