use dioxus::prelude::*;

use crate::Route;
use crate::session::SessionIdentity;

/// Honest placeholder for the publish flow. The wizard (PM-43) is not built
/// yet, so this route reserves the surface and prompts anonymous users to sign
/// in with a `return_to` of `/publish` — never a faked upload form.
#[allow(clippy::useless_format)]
#[component]
pub(crate) fn Publish() -> Element {
    let session = use_context::<Signal<SessionIdentity>>();
    let return_to = use_route::<Route>().to_string();
    let is_anonymous = matches!(*session.read(), SessionIdentity::Anonymous);

    rsx! {
        main { class: "publish-page",
            section { class: "publish-intro blueprint-panel", aria_label: "Publish",
                span { class: "status-pill status-muted", "Coming soon" }
                h1 { "Publish a thing" }
                p { class: "product-lede", "The flow for uploading models, parts, and files is not built yet. This route reserves the space so the product shell stays honest about what exists." }
            }

            if is_anonymous {
                section { class: "publish-signed-out blueprint-panel", aria_label: "Sign in to publish",
                    span { class: "status-pill", "Signed out" }
                    h2 { "Sign in to publish" }
                    p { "Publishing needs an ATProto account. Sign in now and you return here, ready for when the flow ships." }
                    form {
                        class: "session-control",
                        action: "/oauth/start",
                        method: "get",
                        input { r#type: "hidden", name: "return_to", value: "{return_to}" },
                        input {
                            r#type: "text",
                            name: "identifier",
                            placeholder: "handle.test",
                            aria_label: "ATProto handle for publishing",
                        }
                        button { class: "button button-primary", r#type: "submit", "Sign in" }
                    }
                }
            } else {
                section { class: "publish-steps blueprint-panel", aria_label: "Publish outline",
                    h2 { "What the flow will cover" }
                    ol { class: "instruction-list",
                        li { "Describe the thing: title, summary, tags, and license." }
                        li { "Add models and upload their ordered parts and files." }
                        li { "Review, then publish to your ATProto repository." }
                    }
                }
            }
        }
    }
}
