import { h } from "./jsx";
import { Sidebar } from "./components/Sidebar";
import { PaliadinWidget } from "./components/PaliadinWidget";
import { BottomNav } from "./components/BottomNav";
import { Footer } from "./components/Footer";
import { PWAHead } from "./components/PWAHead";

export function renderAppointmentsNew(): string {
  return "<!DOCTYPE html>" + (
    <html lang="de">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
        <meta name="theme-color" content="#BFF355" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="default" />
        <PWAHead />
        <title data-i18n="appointments.neu.title">Neuer Termin &mdash; Paliad</title>
        <link rel="stylesheet" href="/assets/global.css" />
      </head>
      <body className="has-sidebar">
        <Sidebar currentPath="/events?type=appointment" />
        <BottomNav currentPath="/events?type=appointment" />

        <main>
          <section className="tool-page">
            <div className="container container-narrow">
              <div className="tool-header">
                <a href="/events?type=appointment" className="back-link" id="appointment-new-back" data-i18n="appointments.neu.back">&larr; Zur&uuml;ck zur &Uuml;bersicht</a>
                <h1 data-i18n="appointments.neu.heading">Neuer Termin</h1>
                <p className="tool-subtitle" data-i18n="appointments.neu.subtitle">
                  Pers&ouml;nlich oder einer Akte zugeordnet. Bei aktiver CalDAV-Synchronisation erscheint der Termin auch im externen Kalender.
                </p>
              </div>

              <form id="appointment-new-form" className="entity-form" autocomplete="off">
                <div className="form-field">
                  <label htmlFor="appointment-title" data-i18n="appointments.field.title">Titel</label>
                  <input
                    type="text"
                    id="appointment-title"
                    required
                    placeholder="z.B. M&uuml;ndliche Verhandlung"
                    data-i18n-placeholder="appointments.field.title.placeholder"
                  />
                </div>

                <div className="form-field-row">
                  <div className="form-field">
                    <label htmlFor="appointment-start" data-i18n="appointments.field.start">Beginn</label>
                    <input type="datetime-local" id="appointment-start" required />
                  </div>
                  <div className="form-field">
                    <label htmlFor="appointment-end" data-i18n="appointments.field.end">Ende (optional)</label>
                    <input type="datetime-local" id="appointment-end" />
                  </div>
                </div>

                <div className="form-field-row">
                  <div className="form-field">
                    <label htmlFor="appointment-type" data-i18n="appointments.field.type">Typ</label>
                    <select id="appointment-type">
                      <option value="" data-i18n="appointments.field.type.none">Kein Typ</option>
                      <option value="hearing" data-i18n="appointments.type.hearing">Verhandlung</option>
                      <option value="meeting" data-i18n="appointments.type.meeting">Besprechung</option>
                      <option value="consultation" data-i18n="appointments.type.consultation">Beratung</option>
                      <option value="deadline_hearing" data-i18n="appointments.type.deadline_hearing">Fristverhandlung</option>
                    </select>
                  </div>
                  <div className="form-field">
                    <label htmlFor="appointment-project" data-i18n="appointments.field.akte">Akte (optional)</label>
                    <select id="appointment-project">
                      <option value="" data-i18n="appointments.field.akte.none">Pers&ouml;nlicher Termin</option>
                    </select>
                  </div>
                </div>

                <div className="form-field">
                  <label htmlFor="appointment-location" data-i18n="appointments.field.location">Ort (optional)</label>
                  <input type="text" id="appointment-location" placeholder="z.B. UPC LD M&uuml;nchen" data-i18n-placeholder="appointments.field.location.placeholder" />
                </div>

                <div className="form-field">
                  <label htmlFor="appointment-description" data-i18n="appointments.field.description">Beschreibung (optional)</label>
                  <textarea id="appointment-description" rows={3} placeholder="Hinweise, Tagesordnung, n&auml;chste Schritte&hellip;" data-i18n-placeholder="appointments.field.description.placeholder" />
                </div>

                <p className="form-msg" id="appointment-new-msg" />

                {/* t-paliad-154 — form-time 4-eye hint. */}
                <div className="approval-hint" id="appointment-approval-hint" style="display:none">
                  <span className="approval-hint-icon" dangerouslySetInnerHTML={{
                    __html: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>'
                  }} />
                  <span id="appointment-approval-hint-text" />
                </div>

                <div className="form-actions">
                  <a href="/events?type=appointment" id="appointment-new-cancel" className="btn-cancel" data-i18n="appointments.neu.cancel">Abbrechen</a>
                  <button type="submit" className="btn-primary btn-cta-lime" data-i18n="appointments.neu.submit">Termin anlegen</button>
                </div>
              </form>
            </div>
          </section>
        </main>

        <Footer />
        <PaliadinWidget />
        <script src="/assets/appointments-new.js"></script>
      </body>
    </html>
  );
}
