From 96c6818718a35f07dbee51e8e02c0d987c0bc574 Mon Sep 17 00:00:00 2001 From: Kevin L <40267301+a8ck3n@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:55:59 +0900 Subject: [PATCH] Stats: Wire up feedback review button (#94219) --- client/my-sites/stats/feedback/index.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/client/my-sites/stats/feedback/index.tsx b/client/my-sites/stats/feedback/index.tsx index 04ec5cf9fa2411..82c191dcf751f9 100644 --- a/client/my-sites/stats/feedback/index.tsx +++ b/client/my-sites/stats/feedback/index.tsx @@ -10,6 +10,8 @@ const FEEDBACK_ACTION_LEAVE_REVIEW = 'feedback-action-leave-review'; const FEEDBACK_ACTION_SEND_FEEDBACK = 'feedback-action-send-feedback'; const FEEDBACK_ACTION_DISMISS_FLOATING_PANEL = 'feedback-action-dismiss-floating-panel'; +const FEEDBACK_LEAVE_REVIEW_URL = 'https://wordpress.org/support/plugin/jetpack/reviews/'; + interface FeedbackProps { siteId: number; } @@ -95,11 +97,18 @@ function StatsFeedbackController( { siteId }: FeedbackProps ) { const [ isFloatingPanelOpen, setIsFloatingPanelOpen ] = useState( true ); const handleButtonClick = ( action: string ) => { - if ( action === FEEDBACK_ACTION_SEND_FEEDBACK ) { - setIsOpen( true ); - } - if ( action === FEEDBACK_ACTION_DISMISS_FLOATING_PANEL ) { - setIsFloatingPanelOpen( false ); + switch ( action ) { + case FEEDBACK_ACTION_SEND_FEEDBACK: + setIsOpen( true ); + break; + case FEEDBACK_ACTION_DISMISS_FLOATING_PANEL: + setIsFloatingPanelOpen( false ); + break; + case FEEDBACK_ACTION_LEAVE_REVIEW: + setIsFloatingPanelOpen( false ); + window.open( FEEDBACK_LEAVE_REVIEW_URL ); + break; + // Ignore other cases. } };