Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add campaign overview statistics #7559

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 241 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@
"react-a11y-dialog": "^6.1.5",
"react-acceptjs": "^0.3.0",
"react-ace": "^10.1.0",
"react-apexcharts": "^1.4.1",
"react-aria-components": "^1.0.0-alpha.6",
"react-beautiful-dnd": "^13.1.1",
"react-circular-progressbar": "^2.1.0",
"react-csv": "^2.0.1",
"react-currency-input-field": "^3.6.10",
"react-datepicker": "^4.16.0",
Expand Down
2 changes: 2 additions & 0 deletions src/Campaigns/Actions/LoadCampaignDetailsAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function __invoke()
[
'adminUrl' => admin_url(),
'currency' => give_get_currency(),
'apiRoot' => esc_url_raw(rest_url('give-api/v2/campaigns')),
'apiNonce' => wp_create_nonce('wp_rest'),
kjohnson marked this conversation as resolved.
Show resolved Hide resolved
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,24 @@
use Give\API\RestRoute;
use Give\Campaigns\CampaignDonationQuery;
use Give\Campaigns\Models\Campaign;
use Give\Campaigns\ValueObjects\CampaignRoute;
use Give\Framework\Support\Facades\DateTime\Temporal;
use WP_REST_Response;
use WP_REST_Server;

/**
* @unreleased
*/
class CampaignOverviewStatistics implements RestRoute
class GetCampaignStatistics implements RestRoute
{
/** @var string */
protected $endpoint = 'campaign-overview-statistics';

/**
* @unreleased
*/
public function registerRoute()
{
register_rest_route(
'give-api/v2',
$this->endpoint,
CampaignRoute::NAMESPACE,
CampaignRoute::CAMPAIGN . '/statistics',
[
[
'methods' => WP_REST_Server::READABLE,
Expand All @@ -38,18 +36,16 @@ public function registerRoute()
},
],
'args' => [
'campaignId' => [
'id' => [
'type' => 'integer',
'required' => true,
'sanitize_callback' => 'absint',
'validate_callback' => 'is_numeric',
],
'rangeInDays' => [
'type' => 'integer',
'required' => false,
'sanitize_callback' => 'absint',
'default' => 0, // Zero to mean "all time".
'validate_callback' => 'is_numeric',
],
],
]
Expand All @@ -63,7 +59,7 @@ public function registerRoute()
*/
public function handleRequest($request): WP_REST_Response
{
$campaign = Campaign::find($request->get_param('campaignId'));
$campaign = Campaign::find($request->get_param('id'));

$query = new CampaignDonationQuery($campaign);

Expand Down
Loading
Loading