import type { Metadata } from 'next';
import { getServerBranding } from '@server/lib/branding';
import RefundPageContent from './RefundPageContent';

export const revalidate = 60;

export async function generateMetadata(): Promise<Metadata> {
  const branding = await getServerBranding();
  const title = `Refund Policy — ${branding.siteTitle}`;
  const description = `${branding.siteTitle}'s 30-day money-back guarantee and refund terms.`;
  return {
    title,
    description,
    alternates: branding.marketingUrl ? { canonical: `${branding.marketingUrl.replace(/\/$/, '')}/refund` } : undefined,
    openGraph: {
      title,
      description,
      siteName: branding.siteTitle,
      ...(branding.marketingUrl ? { url: `${branding.marketingUrl.replace(/\/$/, '')}/refund` } : {}),
      type: 'website',
    },
    twitter: {
      card: 'summary',
      title,
      description,
    },
  };
}

export default async function RefundPage() {
  const branding = await getServerBranding();
  return <RefundPageContent supportEmail={branding.supportEmail} />;
}
