diff --git a/src/Campaigns/Actions/LoadCampaignDetailsAssets.php b/src/Campaigns/Actions/LoadCampaignDetailsAssets.php new file mode 100644 index 0000000000..e806639faa --- /dev/null +++ b/src/Campaigns/Actions/LoadCampaignDetailsAssets.php @@ -0,0 +1,41 @@ + esc_url_raw(rest_url('give-api/v2/campaigns')), + 'apiNonce' => wp_create_nonce('wp_rest'), + 'adminUrl' => admin_url(), + 'pluginUrl' => GIVE_PLUGIN_URL, + 'campaignDetailsPage' => (new CampaignDetailsPage($campaign))->exports(), + ] + ); + + wp_enqueue_script($handleName); + wp_enqueue_style('givewp-design-system-foundation'); + } +} diff --git a/src/Campaigns/CampaignsAdminPage.php b/src/Campaigns/CampaignsAdminPage.php index 3b7c954189..17c3910128 100644 --- a/src/Campaigns/CampaignsAdminPage.php +++ b/src/Campaigns/CampaignsAdminPage.php @@ -2,7 +2,9 @@ namespace Give\Campaigns; +use Give\Campaigns\Actions\LoadCampaignDetailsAssets; use Give\Campaigns\Actions\LoadCampaignsListTableAssets; +use Give\Campaigns\Models\Campaign; /** * @unreleased @@ -30,7 +32,17 @@ public function addCampaignsSubmenuPage() */ public function renderCampaignsPage() { - give(LoadCampaignsListTableAssets::class)(); + if (isset($_GET['id'])) { + $campaign = Campaign::find(absint($_GET['id'])); + + if ( ! $campaign) { + wp_die(__('Campaign not found', 'give'), 404); + } + + give(LoadCampaignDetailsAssets::class)($campaign); + } else { + give(LoadCampaignsListTableAssets::class)(); + } echo '
'; } diff --git a/src/Campaigns/Routes/CreateCampaign.php b/src/Campaigns/Routes/CreateCampaign.php index 6ea2f1c9d9..420e6e9cae 100644 --- a/src/Campaigns/Routes/CreateCampaign.php +++ b/src/Campaigns/Routes/CreateCampaign.php @@ -77,7 +77,6 @@ public function registerRoute() public function handleRequest(WP_REST_Request $request): WP_REST_Response { $campaign = Campaign::create([ - 'pageId' => 0, 'type' => CampaignType::CORE(), 'title' => $request->get_param('title'), 'shortDescription' => $request->get_param('shortDescription'), diff --git a/src/Campaigns/ViewModels/CampaignDetailsPage.php b/src/Campaigns/ViewModels/CampaignDetailsPage.php new file mode 100644 index 0000000000..e61b5a7aca --- /dev/null +++ b/src/Campaigns/ViewModels/CampaignDetailsPage.php @@ -0,0 +1,41 @@ +campaign = $campaign; + } + + /** + * @unreleased + */ + public function exports(): array + { + return [ + 'overviewTab' => $this->campaign->toArray(), + 'settingsTab' => [ + 'landingPageUrl' => admin_url('?action=edit_campaign_page&campaign_id=' . $this->campaign->id), + ], + 'reportTab' => [], + 'updatesTab' => [], + ]; + } +} diff --git a/src/Campaigns/resources/admin/campaign-details.tsx b/src/Campaigns/resources/admin/campaign-details.tsx new file mode 100644 index 0000000000..730821cb88 --- /dev/null +++ b/src/Campaigns/resources/admin/campaign-details.tsx @@ -0,0 +1,6 @@ +import {createRoot} from 'react-dom/client'; +import CampaignsDetailsPage from './components/CampaignDetailsPage'; + +const container = document.getElementById('give-admin-campaigns-root'); +const root = createRoot(container!); +root.render(Just below you can see a few data from the details page separated by tabs.
+