Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add survey when disabling new experience (#36544)
* Add customer-score-tracks data * Add callback after disabling new exp * Add TransientNotice after filling out the survey # Conflicts: # plugins/woocommerce/src/Admin/Features/NewProductManagementExperience.php * Remove comments * Remove NEW_PRODUCT_MANAGEMENT_FEEDBACK * Add changelog * Rename const * Remove queryParam after showing notice * Fix lint * Fix lint 2.0 * Remove empty line * Refactor `maybe_show_disabled_notice` * Fix lint 3.0 Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
- Loading branch information
1 parent
1d8ba9f
commit 8dde8f3
Showing
10 changed files
with
179 additions
and
9 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
61 changes: 61 additions & 0 deletions
61
...mmerce-admin/client/customer-effort-score-tracks/product-mvp-feedback-modal-container.tsx
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,61 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { ProductMVPFeedbackModal } from '@woocommerce/customer-effort-score'; | ||
import { recordEvent } from '@woocommerce/tracks'; | ||
import { getAdminLink } from '@woocommerce/settings'; | ||
import { useFormContext } from '@woocommerce/components'; | ||
import { Product } from '@woocommerce/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { STORE_KEY } from './data/constants'; | ||
|
||
export const ProductMVPFeedbackModalContainer: React.FC = () => { | ||
const { values } = useFormContext< Product >(); | ||
const { hideProductMVPFeedbackModal } = useDispatch( STORE_KEY ); | ||
const { isProductMVPModalVisible } = useSelect( ( select ) => { | ||
const { isProductMVPFeedbackModalVisible } = select( STORE_KEY ); | ||
return { | ||
isProductMVPModalVisible: isProductMVPFeedbackModalVisible(), | ||
}; | ||
} ); | ||
|
||
const classicEditorUrl = values.id | ||
? getAdminLink( `post.php?post=${ values.id }&action=edit` ) | ||
: getAdminLink( 'post-new.php?post_type=product' ); | ||
|
||
const recordScore = ( checked: string[], comments: string ) => { | ||
recordEvent( 'product_mvp_feedback', { | ||
action: 'disable', | ||
checked, | ||
comments: comments || '', | ||
} ); | ||
hideProductMVPFeedbackModal(); | ||
window.location.href = `${ classicEditorUrl }&new-product-experience-disabled=true`; | ||
}; | ||
|
||
const onCloseModal = () => { | ||
recordEvent( 'product_mvp_feedback', { | ||
action: 'disable', | ||
checked: '', | ||
comments: '', | ||
} ); | ||
hideProductMVPFeedbackModal(); | ||
window.location.href = classicEditorUrl; | ||
}; | ||
|
||
if ( ! isProductMVPModalVisible ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<ProductMVPFeedbackModal | ||
recordScoreCallback={ recordScore } | ||
onCloseModal={ onCloseModal } | ||
/> | ||
); | ||
}; |
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
4 changes: 4 additions & 0 deletions
4
plugins/woocommerce/changelog/add-survey_after_disabling_new_exp
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,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Add survey after disabling new experience |
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