diff --git a/src/Campaigns/Actions/LoadCampaignDetailsAssets.php b/src/Campaigns/Actions/LoadCampaignDetailsAssets.php
index 56339ae55d..3b1767c6e1 100644
--- a/src/Campaigns/Actions/LoadCampaignDetailsAssets.php
+++ b/src/Campaigns/Actions/LoadCampaignDetailsAssets.php
@@ -3,6 +3,7 @@
namespace Give\Campaigns\Actions;
use Give\Campaigns\Models\Campaign;
+use Give\DonationForms\Models\DonationForm;
use Give\Framework\Support\Facades\Scripts\ScriptAsset;
use Give\Helpers\Form\Utils;
@@ -33,14 +34,17 @@ public function __invoke()
true
);
- $defaultForm = $campaign->defaultForm();
- $defaultFormTitle = Utils::isV3Form($defaultForm->id) ? $defaultForm->settings->formTitle : $defaultForm->title;
wp_localize_script($handleName, 'GiveCampaignDetails',
[
'adminUrl' => admin_url(),
'currency' => give_get_currency(),
'isRecurringEnabled' => defined('GIVE_RECURRING_VERSION') ? GIVE_RECURRING_VERSION : null,
- 'defaultForm' => $defaultFormTitle,
+ 'donationForms' => array_map(function(DonationForm $form) {
+ return [
+ 'id' => $form->id,
+ 'title' => $form->hasProperty('settings') ? $form->settings->formTitle : $form->title,
+ ];
+ }, $campaign->forms()->getAll()),
]
);
diff --git a/src/Campaigns/Controllers/CampaignRequestController.php b/src/Campaigns/Controllers/CampaignRequestController.php
index 787a657f3b..822f5c5191 100644
--- a/src/Campaigns/Controllers/CampaignRequestController.php
+++ b/src/Campaigns/Controllers/CampaignRequestController.php
@@ -2,13 +2,14 @@
namespace Give\Campaigns\Controllers;
-use Exception;
use Give\Campaigns\Models\Campaign;
use Give\Campaigns\Repositories\CampaignRepository;
use Give\Campaigns\ValueObjects\CampaignGoalType;
use Give\Campaigns\ValueObjects\CampaignRoute;
use Give\Campaigns\ValueObjects\CampaignStatus;
use Give\Campaigns\ValueObjects\CampaignType;
+use Give\Campaigns\DataTransferObjects\CampaignDetailsData;
+use Exception;
use WP_Error;
use WP_REST_Request;
use WP_REST_Response;
@@ -31,7 +32,9 @@ public function getCampaign(WP_REST_Request $request)
return new WP_Error('campaign_not_found', __('Campaign not found', 'give'), ['status' => 404]);
}
- return new WP_REST_Response($campaign->toArray());
+ return new WP_REST_Response(
+ (new CampaignDetailsData($campaign))->toArray()
+ );
}
/**
@@ -139,7 +142,9 @@ public function updateCampaign(WP_REST_Request $request)
$campaign->save();
}
- return new WP_REST_Response($campaign->toArray());
+ return new WP_REST_Response(
+ (new CampaignDetailsData($campaign))->toArray()
+ );
}
diff --git a/src/Campaigns/DataTransferObjects/CampaignDetailsData.php b/src/Campaigns/DataTransferObjects/CampaignDetailsData.php
new file mode 100644
index 0000000000..d823cf8afa
--- /dev/null
+++ b/src/Campaigns/DataTransferObjects/CampaignDetailsData.php
@@ -0,0 +1,38 @@
+campaign = $campaign;
+ }
+
+ /**
+ * @unreleased
+ */
+ public function toArray(): array
+ {
+ return array_merge(
+ $this->campaign->toArray(),
+ [
+ 'defaultFormId' => $this->campaign->defaultForm()->id,
+ ]
+ );
+ }
+}
diff --git a/src/Campaigns/Routes/RegisterCampaignRoutes.php b/src/Campaigns/Routes/RegisterCampaignRoutes.php
index 7c56edeaf9..10d11522dc 100644
--- a/src/Campaigns/Routes/RegisterCampaignRoutes.php
+++ b/src/Campaigns/Routes/RegisterCampaignRoutes.php
@@ -231,7 +231,7 @@ public function getSchema(): array
'description' => esc_html__('Campaign goal type', 'give'),
],
'defaultFormId' => [
- 'type' => 'integer',
+ 'type' => 'number',
'description' => esc_html__('Default campaign form ID', 'give'),
],
],
diff --git a/src/Campaigns/resources/admin/components/CampaignDetailsPage/CampaignDetailsPage.module.scss b/src/Campaigns/resources/admin/components/CampaignDetailsPage/CampaignDetailsPage.module.scss
index 7764dff4a6..fc7998a8ec 100644
--- a/src/Campaigns/resources/admin/components/CampaignDetailsPage/CampaignDetailsPage.module.scss
+++ b/src/Campaigns/resources/admin/components/CampaignDetailsPage/CampaignDetailsPage.module.scss
@@ -267,6 +267,7 @@ select[name="campaignId"] {
.sectionDescription {
font-size: 16px;
+ line-height: 24px;
color: #4b5563;
}
diff --git a/src/Campaigns/resources/admin/components/CampaignDetailsPage/Components/CampaignStats.tsx b/src/Campaigns/resources/admin/components/CampaignDetailsPage/Components/CampaignStats.tsx
index 997529e9ba..acdef312dd 100644
--- a/src/Campaigns/resources/admin/components/CampaignDetailsPage/Components/CampaignStats.tsx
+++ b/src/Campaigns/resources/admin/components/CampaignDetailsPage/Components/CampaignStats.tsx
@@ -7,14 +7,9 @@ import { addQueryArgs } from '@wordpress/url';
import HeaderText from './HeaderText';
import HeaderSubText from './HeaderSubText';
import DefaultFormWidget from "./DefaultForm";
-import {GiveCampaignDetails} from "@givewp/campaigns/admin/components/CampaignDetailsPage/types";
const campaignId = new URLSearchParams(window.location.search).get('id');
-declare const window: {
- GiveCampaignDetails: GiveCampaignDetails;
-} & Window;
-
const pluck = (array: any[], property: string) => array.map(element => element[property])
const filterOptions = [
@@ -65,7 +60,7 @@ const CampaignStats = () => {