-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Free Listings + Paid Ads: Add the product feed status section UI #1638
Changes from 2 commits
9333fa5
603438a
4566683
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { sprintf, __, _n } from '@wordpress/i18n'; | ||
import { Flex, FlexItem, FlexBlock } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
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 './product-feed-status-section.scss'; | ||
|
||
function ProductQuantity( { quantity } ) { | ||
if ( ! Number.isInteger( quantity ) ) { | ||
return null; | ||
} | ||
|
||
const text = sprintf( | ||
// translators: %d: number of products will be synced to Google Merchant Center. | ||
_n( '%d product', '%d products', quantity, 'google-listings-and-ads' ), | ||
quantity | ||
); | ||
|
||
return ( | ||
<> | ||
<span className="gla-product-feed-status-section__product-quantity-separator" /> | ||
<AppTooltip | ||
className | ||
position="top center" | ||
text={ __( | ||
'You can manage and edit your product feed after this setup', | ||
'google-listings-and-ads' | ||
) } | ||
> | ||
{ text } | ||
</AppTooltip> | ||
</> | ||
); | ||
} | ||
|
||
// TODO: `href`` is not yet ready. Will be added later. | ||
/** | ||
* @fires gla_documentation_link_click with `{ context: 'setup-paid-ads', link_id: 'product-feed-status-learn-more', href: 'https://example.com' }` | ||
*/ | ||
|
||
/** | ||
* Renders a section layout to elaborate on how the product listings will be processed | ||
* 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. | ||
Comment on lines
+55
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ Just wanted to make sure my understanding is right. The API There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, as per my test from the frontend side, it has to call |
||
const data = { | ||
statistics: { | ||
active: 1, | ||
expiring: 2, | ||
pending: 3, | ||
disapproved: 4, | ||
not_synced: 5, | ||
}, | ||
}; | ||
const hasFinishedResolution = true; | ||
const productQuantity = hasFinishedResolution | ||
? getNumberOfSyncProducts( data.statistics ) | ||
: null; | ||
|
||
return ( | ||
<Section | ||
className="gla-product-feed-status-section" | ||
title={ __( 'Product feed status', 'google-listings-and-ads' ) } | ||
description={ | ||
<AppDocumentationLink | ||
context="setup-paid-ads" | ||
linkId="product-feed-status-learn-more" | ||
href="https://example.com" // TODO: Not yet ready. Will be added later. | ||
> | ||
{ __( 'Learn more', 'google-listings-and-ads' ) } | ||
</AppDocumentationLink> | ||
} | ||
> | ||
<Section.Card> | ||
<Section.Card.Body> | ||
<Flex align="flex-start" gap={ 3 }> | ||
<FlexItem> | ||
<SyncIcon /> | ||
</FlexItem> | ||
<FlexBlock> | ||
<Section.Card.Title> | ||
{ __( | ||
'Your product listings are being uploaded', | ||
'google-listings-and-ads' | ||
) } | ||
<ProductQuantity quantity={ productQuantity } /> | ||
</Section.Card.Title> | ||
{ __( | ||
'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.', | ||
'google-listings-and-ads' | ||
) } | ||
</FlexBlock> | ||
</Flex> | ||
</Section.Card.Body> | ||
</Section.Card> | ||
</Section> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.gla-product-feed-status-section { | ||
.gla-sync-icon { | ||
fill: $gla-color-green; | ||
transform: rotateZ(90deg); | ||
} | ||
|
||
.wcdl-subsection-title { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
&__product-quantity-separator, | ||
.app-tooltip__children-container { | ||
font-size: $gla-font-smallest; | ||
font-weight: normal; | ||
color: $gray-700; | ||
} | ||
|
||
&__product-quantity-separator::before { | ||
content: "•"; | ||
display: inline-block; | ||
margin: 0 $grid-unit-10; | ||
} | ||
|
||
.app-tooltip__children-container { | ||
padding-bottom: calc($grid-unit-05 / 2); | ||
line-height: 1; | ||
border-bottom: $border-width dashed $gray-600; | ||
} | ||
|
||
.components-popover__content { | ||
width: 200px; | ||
white-space: normal; | ||
font-weight: normal; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @typedef {import('.~/data/actions').ProductStatisticsDetails } ProductStatisticsDetails | ||
*/ | ||
|
||
/** | ||
* Return the total number of syncing/synced products except for the `not_synced` category. | ||
* | ||
* @param {ProductStatisticsDetails} statistics The statistics data of scheduled synchronized products. | ||
* @return {number} Number of syncing/synced products. | ||
*/ | ||
export default function getNumberOfSyncProducts( statistics ) { | ||
return Object.entries( statistics ).reduce( ( sum, [ key, num ] ) => { | ||
if ( key === 'not_synced' ) { | ||
return sum; | ||
} | ||
return sum + num; | ||
}, 0 ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅 Since the type of
ProductStatistics
is defined, it would be nice to add some doc comments in the below function that is using this type.google-listings-and-ads/js/src/data/actions.js
Line 892 in 9333fa5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 4566683.