index.ts
9 months ago
useDonationsBySubscription.ts
9 months ago
useSubscriptionAmounts.ts
9 months ago
useSubscriptionCancel.ts
9 months ago
useSubscriptionSync.tsx
9 months ago
useDonationsBySubscription.ts
36 lines
| 1 | import { useEntityRecords } from '@wordpress/core-data'; |
| 2 | import { Donation } from '@givewp/donations/admin/components/types'; |
| 3 | |
| 4 | /** |
| 5 | * @since 4.8.0 |
| 6 | */ |
| 7 | export function useDonationsBySubscription( |
| 8 | subscriptionId: number, |
| 9 | mode: 'test' | 'live', |
| 10 | ) { |
| 11 | const queryArgs = { |
| 12 | subscriptionId, |
| 13 | mode, |
| 14 | status: 'any', |
| 15 | sort: 'createdAt', |
| 16 | direction: 'DESC' |
| 17 | }; |
| 18 | |
| 19 | const { |
| 20 | records, |
| 21 | hasResolved, |
| 22 | isResolving, |
| 23 | }: { |
| 24 | records: Donation[] | null; |
| 25 | hasResolved: boolean; |
| 26 | isResolving: boolean; |
| 27 | |
| 28 | } = useEntityRecords('givewp', 'donation', queryArgs); |
| 29 | |
| 30 | return { |
| 31 | records, |
| 32 | hasResolved, |
| 33 | isResolving, |
| 34 | }; |
| 35 | } |
| 36 |