woocommerce/plugins/woocommerce-admin/client/marketing/data-multichannel
Eason d57b9e1d05
Make the `useCampaigns` hook support being used with multiple instances (#41211)
* Add tests for the `useCampaigns` hook in the woocommerce-admin marketing.

* Add `channels` to the deps of `useSelect` in the `useCampaigns` hook to avoid outdated hook states.

* Make the `useCampaigns` hook support being used with multiple instances.

- Include the `perPage` in the page key of campaigns in the multichannel's data store.
- Move the processing of querying the campaigns paging to the selector of the multichannel's data store.
- Move `total` in each campaign's paging of the multichannel's data store.
- Remove unused properties and their types: `state.campaigns.perPage` and `state.campaigns.total`

* Add changelog

* Multichannel data store - Move the `total` from `campaigns.pages[*]` to `campaigns.meta` to have only one total value.

Related to:
- https://github.com/woocommerce/woocommerce/pull/41211#discussion_r1409634640
- https://github.com/woocommerce/woocommerce/pull/41211#discussion_r1409590559

* Multichannel data store - Return the pagination meta of campaigns along with the `getCampaigns` selector.

Address: https://github.com/woocommerce/woocommerce/pull/41211#discussion_r1412266127
2023-12-05 11:20:05 +08:00
..
action-types.ts Simplify wp.data for receiveCampaignTypes. 2023-03-03 00:24:51 +08:00
actions.ts Simplify receiveCampaignTypes. 2023-03-03 00:54:21 +08:00
constants.ts Call marketing channels API with wp.data. 2023-01-18 02:04:42 +08:00
controls.ts Remove unused fetchWithHeaders control. 2023-02-24 23:35:40 +08:00
guards.ts Call marketing channels API with wp.data. 2023-01-18 02:04:42 +08:00
index.ts Add controls with fetchWithHeaders. 2023-02-24 02:08:59 +08:00
reducer.ts Make the `useCampaigns` hook support being used with multiple instances (#41211) 2023-12-05 11:20:05 +08:00
resolvers.ts fix: applied lint autofixes (#39942) 2023-08-30 06:40:45 +08:00
selectors.ts Make the `useCampaigns` hook support being used with multiple instances (#41211) 2023-12-05 11:20:05 +08:00
types.ts Make the `useCampaigns` hook support being used with multiple instances (#41211) 2023-12-05 11:20:05 +08:00