Files
kmtnflower/retire-donation-page.md
T

76 lines
4.3 KiB
Markdown

# Retire Donation Page, Add Configurable External Donation URL
## Context
The donation page (`/donate`) is being retired — it was a tier-based landing page with calls to action. All donation links will instead point to an external URL (e.g., a nonprofit payment processor). Admins configure this URL in the existing Station Config screen.
## Approach
1. Add `donation_url` field to the existing `StationConfig` singleton (backend model + schema, frontend interface + admin form)
2. Replace all donation links across the site with external `<a href>` links driven by `config().donation_url`, hidden when empty
3. Delete the donation page, tier service, tier admin UI, and all backend tier infrastructure
## Step-by-Step
### Phase 1 — Add `donation_url` to StationConfig (backend)
- **`backend/app/models.py`** — Add `donation_url = Column(String(500), nullable=False, default="")` to `StationConfig` class
- **`backend/app/schemas.py`** — Add `donation_url: str` to `StationConfigResponse`; add `donation_url: Optional[str] = None` to `StationConfigUpdate`
- **`backend/seed.py`** — Add `"donation_url": ""` to `STATION_CONFIG` dict
### Phase 2 — Add `donation_url` to StationConfig (frontend)
- **`src/app/interfaces/station-config.ts`** — Add `donation_url: string`
- **`src/app/services/station-config.service.ts`** — Add `donation_url: ''` to `DEFAULT_CONFIG`
- **`src/app/admin/admin-station-form.component.ts`** — Add `donation_url` property, wire it in `populate()` and `onSubmit()` payload
- **`src/app/admin/admin-station-form.component.html`** — Add a "Donation" form section with a URL input field
- **`src/app/admin/admin.component.html`** — Show `donation_url` in the station config summary view
### Phase 3 — Replace donation links with external links
All links switch from `routerLink="/donate"` to `[href]="config().donation_url"` with `target="_blank" rel="noopener noreferrer"`, wrapped in `@if (config().donation_url)` so they hide when empty.
- **`src/app/navbar/navbar.component.html`** — "Donate Now" button (line 37)
- **`src/app/hero/hero.component.html`** — "Support the Station" button (line 28)
- **`src/app/about/about.component.html`** — "Become a Member" CTA section (lines 76-88), wrap entire block in `@if`
- **`src/app/footer/footer.component.html`** — "Donate" and "Become a Member" links (lines 26, 33)
### Phase 4 — Delete donation page
- Remove `/donate` route from **`src/app/app.routes.ts`** (lines 22-25)
- Delete **`src/app/donate/`** directory (3 files: `.ts`, `.html`, `.scss`)
### Phase 5 — Remove tier infrastructure (frontend)
- Delete **`src/app/interfaces/tier.ts`**
- Delete **`src/app/services/tier.service.ts`**
- Delete **`src/app/admin/admin-tier-form.component.*`** (3 files)
- **`src/app/admin/admin.component.ts`** — Remove `Tier`/`TierService`/`AdminTierFormComponent` imports, `TabKey` entry, injected service, `tiers$` BehaviorSubject, `editingTier`, `showTierForm`, `reloadTiers()`, and all tier CRUD methods
- **`src/app/admin/admin.component.html`** — Remove Tiers tab button, Tiers tab content panel, tier form modal
### Phase 6 — Remove tier infrastructure (backend)
- Delete **`backend/app/api/tiers.py`**
- **`backend/app/models.py`** — Delete `DonationTier` class
- **`backend/app/schemas.py`** — Delete `TierCreate`, `TierUpdate`, `TierResponse`
- **`backend/app/main.py`** — Remove `tiers` import and router registration
- **`backend/app/api/admin.py`** — Remove `DonationTier` from reset truncation
- **`backend/seed.py`** — Remove `DonationTier` import, `TIERS` list, `_upsert_tier()` helper, tier seeding, tier truncation
### Phase 7 — Contact form cleanup
- **`src/app/contact/contact.component.html`** — Remove `<option value="donation">Donation Question</option>`
## Execution Order
1 → 2 → 3 → 4 → 5 → 6 → 7
## Verification
1. Grep for remaining references to `Tier`, `tier`, `DonationTier`, `donate`, `/donate` — none should remain in live code
2. `ng build` — no import errors, no unresolved references
3. Backend starts without import errors
4. Admin station form shows the new "External Donation URL" field
5. Setting a URL → all 4 link locations render external links with `target="_blank"`
6. Clearing the URL → all 4 link locations hide
7. Navigate to `/donate` → 404 or wildcard redirect to home