Add admin UI: setup wizard, goals, rules editor, donations, moderation, overlays, settings
Test and Release / test (push) Successful in 2m34s
Test and Release / release (push) Successful in 9s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 10:26:03 -08:00
1 parent 0b9e6e7cbb
commit 4efdef72f6
18 files changed
+2169

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
<?php
declare( strict_types=1 );
namespace StreamGoals\Admin;
use StreamGoals\Core\Money;
/** Pure goal templates used by the setup wizard. */
final class Templates {
public const LABELS = array(
'simple' => array( 'Simple goal', 'A progress bar towards a fundraising target. Nothing else.' ),
'subathon' => array( 'Subathon timer: +1 min per $1', 'A countdown that gets longer with every donation (1 minute added for every $1).' ),
'counter' => array( 'Counter: +1 per $10', 'A counter that goes up by 1 for every $10 donated (for example "pies thrown").' ),
);
public static function exists( string $key ): bool {
return isset( self::LABELS[ $key ] );
}
/**
* @return array{goal:array,rules:array<int,array{type:string,config:array}>}
*/
public static function build( string $key, string $currency, int $targetMinor, string $title = '' ): array {
$one = 10 ** Money::exponent( $currency ); // one whole currency unit, in minor units
$name = '' !== trim( $title ) ? trim( $title ) : ( 'subathon' === $key ? 'Subathon' : ( 'counter' === $key ? 'Donation counter' : 'My first goal' ) );
$goal = array( 'title' => $name, 'target_minor' => $targetMinor, 'currency' => $currency, 'status' => 'active', 'counts_fees' => 0 );
$rules = array();
if ( 'subathon' === $key ) {
$rules[] = array( 'type' => 'add_time', 'config' => array(
'seconds_per_unit' => 60, 'unit_minor' => $one, 'cap_seconds_per_donation' => null, 'max_total_seconds' => null, 'basis' => 'base',
) );
} elseif ( 'counter' === $key ) {
$rules[] = array( 'type' => 'counter', 'config' => array(
'step' => 1, 'per_minor' => 10 * $one, 'carry_over' => true, 'basis' => 'base', 'label' => 'Count',
) );
}
return array( 'goal' => $goal, 'rules' => $rules );
}
}