# give/4.18.0/src/Donations/resources/utils.ts

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 38 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/Donations/resources/utils.ts
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/Donations/resources/utils.ts
- Modified: 2025-09-10T13:42:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/Donations/resources/utils.ts#L10-L20`.

```typescript
import {useEntityRecord} from '@wordpress/core-data';
import {Donation} from '@givewp/donations/admin/components/types';
import type {GiveDonationOptions} from '@givewp/donations/types';

declare const window: {
    GiveDonationOptions: GiveDonationOptions;
} & Window;

/**
 * @since 4.6.0
 */
export function useDonationEntityRecord(donationId?: number) {
    const urlParams = new URLSearchParams(window.location.search);

    const {
        record: donation,
        hasResolved,
        isResolving,
        save,
        edit,
    }: {
        record: Donation;
        hasResolved: boolean;
        isResolving: boolean;
        save: () => any;
        edit: (data: Donation | Partial<Donation>) => void;
    } = useEntityRecord('givewp', 'donation', donationId ?? urlParams.get('id'));

    return {record: donation, hasResolved, isResolving, save, edit};
}

/**
 * @since 4.6.0
 */
export function getDonationOptionsWindowData(): GiveDonationOptions {
    return window.GiveDonationOptions;
}

```
