/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see .
*/
/** @jsxRuntime automatic */
/** @jsxImportSource hono/jsx */
import {SwishIcon} from '@fluxer/marketing/src/components/icons/SwishIcon';
import type {MarketingContext} from '@fluxer/marketing/src/MarketingContext';
import {escapeInlineScriptValue} from '@fluxer/marketing/src/pages/InlineScriptEscaping';
export interface DonationI18n {
email: string;
emailPlaceholder: string;
amount: string;
amountOther: string;
amountPlaceholder: string;
donationType: string;
oneTime: string;
monthly: string;
yearly: string;
orLabel: string;
currency: string;
donate: string;
processing: string;
errorInvalidEmail: string;
errorInvalidAmount: string;
errorGeneric: string;
errorNetwork: string;
}
export function getDonationI18n(ctx: MarketingContext): DonationI18n {
return {
email: ctx.i18n.getMessage('donations.form.email', ctx.locale),
emailPlaceholder: ctx.i18n.getMessage('donations.form.email_placeholder', ctx.locale),
amount: ctx.i18n.getMessage('donations.form.amount', ctx.locale),
amountOther: ctx.i18n.getMessage('donations.form.amount_other', ctx.locale),
amountPlaceholder: ctx.i18n.getMessage('donations.form.amount_placeholder', ctx.locale),
donationType: ctx.i18n.getMessage('donations.form.donation_type', ctx.locale),
oneTime: ctx.i18n.getMessage('donations.form.one_time', ctx.locale),
monthly: ctx.i18n.getMessage('donations.form.monthly', ctx.locale),
yearly: ctx.i18n.getMessage('donations.form.yearly', ctx.locale),
orLabel: ctx.i18n.getMessage('donations.form.or_label', ctx.locale),
currency: ctx.i18n.getMessage('donations.form.currency', ctx.locale),
donate: ctx.i18n.getMessage('donations.donate.action', ctx.locale),
processing: ctx.i18n.getMessage('donations.form.processing', ctx.locale),
errorInvalidEmail: ctx.i18n.getMessage('donations.errors.invalid_email', ctx.locale),
errorInvalidAmount: ctx.i18n.getMessage('donations.errors.invalid_amount', ctx.locale),
errorGeneric: ctx.i18n.getMessage('donations.errors.generic', ctx.locale),
errorNetwork: ctx.i18n.getMessage('donations.errors.network', ctx.locale),
};
}
export function renderDonationForm(
ctx: MarketingContext,
type: 'individual' | 'business',
isHidden: boolean,
): JSX.Element {
const i18n = getDonationI18n(ctx);
return (