PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.7.1
GiveWP – Donation Plugin and Fundraising Platform v4.7.1
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Campaigns / Blocks / shared / hooks / useCampaigns.ts
useCampaigns.ts
41 lines 922 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {useEntityRecords} from '@wordpress/core-data';
2 import {Campaign} from '@givewp/campaigns/admin/components/types';
3
4 type CampaignStatus = 'active' | 'draft' | 'archived';
5
6 type useCampaignsParams = {
7 ids?: number[],
8 page?: number,
9 per_page?: number;
10 status?: CampaignStatus[]
11 sortBy?: string;
12 orderBy?: string;
13 }
14
15 export default function useCampaigns({
16 ids = [],
17 page = 1,
18 per_page = 30,
19 status = ['active'],
20 sortBy = 'date',
21 orderBy = 'desc',
22 }: useCampaignsParams = {}) {
23 const data = useEntityRecords('givewp', 'campaign', {
24 ids,
25 page,
26 per_page,
27 status,
28 sortBy,
29 orderBy
30 });
31
32 return {
33 campaigns: data?.records as Campaign[],
34 //@ts-ignore
35 totalItems: data.totalItems,
36 //@ts-ignore
37 totalPages: data.totalPages,
38 hasResolved: data?.hasResolved,
39 };
40 }
41