From 2afa78f34330183bc2b33345a1d90437994aeed4 Mon Sep 17 00:00:00 2001 From: Eason Su Date: Thu, 29 Sep 2022 11:39:30 +0800 Subject: [PATCH] Fetch the number of syncable products in the ProductFeedStatusSection component --- .../product-feed-status-section.js | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/js/src/setup-mc/setup-stepper/setup-paid-ads/product-feed-status-section.js b/js/src/setup-mc/setup-stepper/setup-paid-ads/product-feed-status-section.js index bf5cc7b9db..10ccede393 100644 --- a/js/src/setup-mc/setup-stepper/setup-paid-ads/product-feed-status-section.js +++ b/js/src/setup-mc/setup-stepper/setup-paid-ads/product-feed-status-section.js @@ -2,6 +2,7 @@ * External dependencies */ import { sprintf, __, _n } from '@wordpress/i18n'; +import { useEffect } from '@wordpress/element'; import { Flex, FlexItem, FlexBlock } from '@wordpress/components'; /** @@ -11,7 +12,7 @@ import Section from '.~/wcdl/section'; import AppDocumentationLink from '.~/components/app-documentation-link'; import SyncIcon from '.~/components/sync-icon'; import AppTooltip from '.~/components/app-tooltip'; -import getNumberOfSyncProducts from '.~/utils/getNumberOfSyncProducts'; +import useSyncableProductsCalculation from '.~/hooks/useSyncableProductsCalculation'; import './product-feed-status-section.scss'; function ProductQuantity( { quantity } ) { @@ -51,25 +52,12 @@ function ProductQuantity( { quantity } ) { * and show the number of products will be synced to Google Merchant Center. */ export default function ProductFeedStatusSection() { - /* - const { data, hasFinishedResolution } = useAppSelectDispatch( - 'getMCProductStatistics' - ); - */ - // TODO: Replace the dummy data with the above code later to use the adjusted API. - const data = { - statistics: { - active: 1, - expiring: 2, - pending: 3, - disapproved: 4, - not_synced: 5, - }, - }; - const hasFinishedResolution = true; - const productQuantity = hasFinishedResolution - ? getNumberOfSyncProducts( data.statistics ) - : null; + const { retrieve, count } = useSyncableProductsCalculation(); + + // Retrieve the result of calculation that was requested when entering the Get Started page. + useEffect( () => { + retrieve(); + }, [ retrieve ] ); return (
+ { __( 'Google will review your product listings within 3-5 days. Once approved, your products will automatically be live and searchable on Google. You’ll be notified if there are any product feed issues.',