(ns wanijo.instance.view.link-selection
  (:require [hiccup.form :as hform]
            [hiccup.core :refer [h]]
            [wanijo.infrastructure.view :as view]
            [wanijo.infrastructure.routing :refer [path]]
            [formulare.core :as form]))

(defn link-selection [instance schema form req]
  (view/layout
    :request req
    :content
    [[:h1
      [:small "Link " (-> instance :schema :name h) " "]
      (h (:name instance))
      [:small " with "]
      (h (:name schema))]
     (hform/form-to [:post (path :instance-link-create
                                 {:uuid (:uuid instance)
                                  :schema-uuid (:uuid schema)})]
                    (form/render-widgets form nil req)
                    (hform/submit-button "Link!"))]))
