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";

// t-paliad-240 — global Schriftsätze drafts index. Top-level sidebar
// entry that lists every draft the caller owns across visible projects.
// Per-project editor stays at /projects/{id}/submissions/{code}/draft —
// this page only adds a discovery surface and click-through to it.

export function renderSubmissionsIndex(): 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="submissions.index.title">Schriftsätze &mdash; Paliad</title>
        <link rel="stylesheet" href="/assets/global.css" />
      </head>
      <body className="has-sidebar">
        <Sidebar currentPath="/submissions" />
        <BottomNav currentPath="/submissions" />

        <main>
          <section className="tool-page">
            <div className="container">
              <div className="tool-header">
                <div className="submissions-index-headline">
                  <div>
                    <h1 data-i18n="submissions.index.heading">Schriftsätze</h1>
                    <p className="tool-subtitle" data-i18n="submissions.index.subtitle">
                      Ihre Schriftsatz-Entw&uuml;rfe &uuml;ber alle sichtbaren Projekte.
                    </p>
                  </div>
                  <a href="/submissions/new" className="btn-primary btn-cta-lime"
                     data-i18n="submissions.index.action.new">+ Neuer Entwurf</a>
                </div>
              </div>

              <p className="entity-events-empty" id="submissions-index-loading"
                 data-i18n="submissions.index.loading">L&auml;dt&hellip;</p>

              <div className="entity-empty" id="submissions-index-empty" style="display:none">
                <p data-i18n="submissions.index.empty">
                  Noch keine Entw&uuml;rfe. Beginnen Sie mit einem neuen Entwurf &mdash; mit oder ohne Projekt.
                </p>
                <a href="/submissions/new" className="btn-primary btn-cta-lime"
                   data-i18n="submissions.index.empty.cta">+ Neuer Entwurf</a>
              </div>

              <div className="entity-empty" id="submissions-index-error" style="display:none">
                <p data-i18n="submissions.index.error">Schrifts&auml;tze konnten nicht geladen werden.</p>
              </div>

              <div className="entity-table-wrap" id="submissions-index-tablewrap" style="display:none">
                <table className="entity-table">
                  <thead>
                    <tr>
                      <th data-i18n="submissions.index.col.project">Projekt</th>
                      <th data-i18n="submissions.index.col.submission">Schriftsatz</th>
                      <th data-i18n="submissions.index.col.draft">Entwurf</th>
                      <th data-i18n="submissions.index.col.updated">Zuletzt ge&auml;ndert</th>
                    </tr>
                  </thead>
                  <tbody id="submissions-index-body" />
                </table>
              </div>
            </div>
          </section>
        </main>

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