$37 GRAYBYTE WORDPRESS FILE MANAGER $46

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.23
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bravrvjk/itiministry.org/wp-content/plugins/give/src/Campaigns/Blocks/Campaign/

HOME
Current File : /home/bravrvjk/itiministry.org/wp-content/plugins/give/src/Campaigns/Blocks/Campaign//edit.tsx
import {__} from '@wordpress/i18n';
import React, {CSSProperties, useState} from 'react';
import {InspectorControls, useBlockProps} from '@wordpress/block-editor';
import {BlockEditProps} from '@wordpress/blocks';
import {PanelBody, ToggleControl} from '@wordpress/components';
import {CampaignBlockType} from './types';
import CampaignSelector from '../shared/components/CampaignSelector';
import CampaignCard from '../shared/components/CampaignCard';
import {BlockNotice} from '@givewp/form-builder-library';
import {getCampaignOptionsWindowData, updateUserNoticeOptions, useCampaignEntityRecord, createCampaignPage} from '@givewp/campaigns/utils';


const styles = {
    title: {
        fontWeight: 600
    },
    notice: {
        position: 'relative',
        display: 'flex',
        flexDirection: 'column',
        gap: 8,
        padding: 16,
        borderRadius: 2,
        color: '#0e0e0e',
        background: '#f2f2f2',
        fontSize: 12,
        lineHeight: 1.33,
    },
    close: {
        position: 'absolute',
        cursor: 'pointer',
        right: 16,
        top: 16,
    },
    link: {
        color: '#0e0e0e',
    }
} as CSSProperties;

const CloseIcon = () => (
    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path
            d="M11.805 5.138a.667.667 0 1 0-.943-.943L8 7.057 5.138 4.195a.667.667 0 1 0-.943.943L7.057 8l-2.862 2.862a.667.667 0 1 0 .943.943L8 8.943l2.862 2.862a.667.667 0 1 0 .943-.943L8.943 8l2.862-2.862z"
            fill="#0E0E0E" />
    </svg>
)

export default function Edit({attributes, setAttributes}: BlockEditProps<CampaignBlockType>) {
    const blockProps = useBlockProps();
    const campaignWindowData = getCampaignOptionsWindowData();
    const [showNotification, setShowNotification] = useState(campaignWindowData.admin.showCampaignInteractionNotice);
    const {record: campaign, hasResolved, edit, save} = useCampaignEntityRecord(attributes.campaignId);


    const Notices = () => {
        if (!attributes.campaignId) {
            return null;
        }

        if (campaign.pageId) {
            if (!showNotification) {
                return null;
            }

            return (
                <p style={styles['notice']}>
                    <span
                        style={styles['close']}
                        onClick={() => {
                            updateUserNoticeOptions('givewp_campaign_interaction_notice').then(() => setShowNotification(false))
                        }}>
                        <CloseIcon />
                    </span>
                    <span style={styles['title']}>
                        {__('Campaign interaction', 'give ')}
                    </span>
                    <span>
                        {__('Users will be redirected to campaign page.', 'give')}
                    </span>
                </p>
            )
        }

        return (
            <BlockNotice
                title={__('There is no Campaign page for this campaign.', 'give ')}
                description={__('For this campaign block to work properly, create a campaign page.', 'give')}
            >
                <a
                    href="#"
                    onClick={async (e) => {
                        e.preventDefault();
                        const campaignPageResponse = await createCampaignPage(campaign.id)

                        if (campaignPageResponse) {
                            edit({...campaign, pageId: campaignPageResponse?.id});

                            await save();
                        }
                    }}
                    style={styles['link']}
                >
                    {__('Create campaign page.', 'give')}
                </a>
            </BlockNotice>
        )
    };

    return (
        <div {...blockProps}>
            {hasResolved && (
                <>
                    <CampaignSelector
                        campaignId={attributes.campaignId}
                        handleSelect={(campaignId: number) => setAttributes({campaignId})}
                        showInspectorControl={true}
                        inspectorControls={<Notices />}
                    >
                        <CampaignCard
                            campaign={campaign}
                            showImage={attributes.showImage}
                            showDescription={attributes.showDescription}
                            showGoal={attributes.showGoal}
                        />
                    </CampaignSelector>

                    <InspectorControls>
                        <PanelBody title={__('Display Elements', 'give')} initialOpen={true}>
                            <ToggleControl
                                label={__('Show campaign image', 'give')}
                                checked={attributes.showImage}
                                onChange={(showImage) => setAttributes({showImage})}
                            />
                            <ToggleControl
                                label={__('Show description', 'give')}
                                checked={attributes.showDescription}
                                onChange={(showDescription) => setAttributes({showDescription})}
                            />
                            <ToggleControl
                                label={__('Show goal', 'give')}
                                checked={attributes.showGoal}
                                onChange={(showGoal) => setAttributes({showGoal})}
                            />
                        </PanelBody>
                    </InspectorControls>
                </>
            )}
        </div>
    )
}


Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
1 Jan 1970 12.00 AM
root / root
0
app.tsx
1.052 KB
20 Aug 2025 6.13 PM
bravrvjk / bravrvjk
0644
block.json
0.891 KB
9 Dec 2025 1.09 AM
bravrvjk / bravrvjk
0644
edit.tsx
5.6 KB
18 Nov 2025 7.37 PM
bravrvjk / bravrvjk
0644
index.tsx
0.244 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644
render.php
0.306 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644
types.ts
0.134 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF