import {
  SettingsFormCard,
  type SettingFieldDef,
} from '@/components/admin/shared/settings-form-card';
import { PageHeader } from '@/components/shared/page-header';

const DEFAULT_FIELDS: SettingFieldDef[] = [
  {
    key: 'reminder_default_enabled',
    label: 'Enable reminders by default on new interests',
    description:
      'When on, newly-created interests inherit reminderEnabled=true. Users can still toggle it on a per-interest basis.',
    type: 'boolean',
    defaultValue: false,
  },
  {
    key: 'reminder_default_days',
    label: 'Default inactivity days',
    description:
      "Default value for an interest's reminderDays field. Reminders fire after this many days of no contact.",
    type: 'number',
    placeholder: '7',
    defaultValue: 7,
  },
];

const DIGEST_FIELDS: SettingFieldDef[] = [
  {
    key: 'reminder_digest_enabled',
    label: 'Batch reminders into a daily digest',
    description:
      'Off (default): reminders fire as soon as the threshold is hit. On: pending reminders are accumulated and delivered once per day at the digest time.',
    type: 'boolean',
    defaultValue: false,
  },
  {
    key: 'reminder_digest_time',
    label: 'Digest delivery time',
    description: '24-hour HH:MM in the digest timezone.',
    type: 'string',
    placeholder: '09:00',
    defaultValue: '09:00',
  },
  {
    key: 'reminder_digest_timezone',
    label: 'Digest timezone',
    description: 'IANA timezone name used to interpret the delivery time (e.g. Europe/Warsaw).',
    type: 'string',
    placeholder: 'Europe/Warsaw',
    defaultValue: 'Europe/Warsaw',
  },
];

export default function ReminderSettingsPage() {
  return (
    <div className="space-y-6">
      <PageHeader
        title="Reminders"
        description="Default reminder behaviour for new interests and the optional daily-digest delivery window. Individual users can still configure their own digest preferences in Notifications → Preferences."
      />

      <SettingsFormCard
        title="Defaults for new interests"
        description="Applied when an interest is created without an explicit reminder configuration."
        fields={DEFAULT_FIELDS}
      />

      <SettingsFormCard
        title="Daily digest"
        description="Optional batching window so reminder notifications go out once per day instead of as they fire."
        fields={DIGEST_FIELDS}
      />
    </div>
  );
}
