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
Add Campaigns card in Multichannel Marketing page #36735
Conversation
This makes the column right-aligned.
…nnels-card' into feature/34903-multichannel-marketing-frontend/34905-campaigns-card Conflicts: plugins/woocommerce-admin/client/marketing/overview-multichannel/MarketingOverviewMultichannel.tsx
…05-marketing-campaigns-card Conflicts: plugins/woocommerce-admin/client/marketing/overview-multichannel/MarketingOverviewMultichannel.tsx
…05-marketing-campaigns-card
This is to eliminate the unneeded flex gap when there is no description.
This allows fast client-side navigation.
This means when total is more than perPage.
100 is the maximum limit allowed by the API. We do this because the API does not return total number of rows, so we use 100 to get "all" rows, to support pagination in the UI.
plugins/woocommerce-admin/client/marketing/data-multichannel/actions.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/data-multichannel/actions.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/data-multichannel/resolvers.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/data-multichannel/reducer.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/data-multichannel/actions.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/data-multichannel/resolvers.ts
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/data-multichannel/resolvers.ts
Show resolved
Hide resolved
@@ -10,3 +10,7 @@ export const getRegisteredChannels = ( state: State ) => { | |||
export const getRecommendedChannels = ( state: State ) => { | |||
return state.recommendedChannels; | |||
}; | |||
|
|||
export const getCampaigns = ( state: State ) => { |
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.
💅 Missed JSDOCS
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.
Done in 4b87f0a
(#36735).
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.
Missed @param state
declaration
plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/useCampaigns.ts
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.tsx
Show resolved
Hide resolved
}; | ||
|
||
export type CampaignsState = { | ||
error?: ApiFetchError; |
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.
❓ Whats the difference between the error in CampaignsState
vs an error in CampaignsPage
??
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.
That is actually unused now, I have removed it in c0364ad
(#36735).
plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.tsx
Show resolved
Hide resolved
plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.test.tsx
Outdated
Show resolved
Hide resolved
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.
Howdy @ecgan
Behaviour testing good. Left some comments over code.
If total is 0, then the function should return 0, not undefined.
@puntope , thanks for the review comments, I have made changes and addressed them, this is ready for another round of review. 🙂 🙏 PS: ❤️ Extra special thanks for #36735 (review), I got what I wanted to do based on your code example! |
/** | ||
* Create a "RECEIVE_CAMPAIGNS" action object. | ||
*/ | ||
export const receiveCampaigns = ( response: CampaignsResponse ) => { |
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.
💅 Missed @param response
docs
* Get total number of records from the HTTP response header "x-wp-total". | ||
* | ||
* If the header is not present, then the function will return `undefined`. | ||
*/ |
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.
Missed param response docs
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.
Looking good for me @ecgan
Thanks for further changes
All Submissions:
Changes proposed in this Pull Request:
Closes #34905.
In this PR, we add a new Campaigns card into the Multichannel Marketing page. This builds on top of PR #36541, and uses the campaigns API introduced in PR #36222.
Campaigns card in loading state:
Campaigns card in error state:
Campaigns card in empty data state (no campaigns):
Campaigns card with campaign data and pagination:
Demo video showing pagination transition:
demo-pr-campaigns-card-pagination.mp4
Demo video showing the page transition when we click on the campaign link:
demo-pr-campaigns-card.mp4
How to test the changes in this Pull Request:
Pre-condition:
/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=features
).Test instructions:
/wp-admin/admin.php?page=wc-admin&path=%2Fmarketing
.useCampaigns
hook to return the desired states for testing, e.g.loading: true
,data: undefined
,data: []
etc.Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: