          (material/raised-button
            #js {:label      "Create"
                 :primary    true
-                :onTouchTap (fn []
-                              (POST "/services"
-                                    {:format :json
-                                     :params (state)
-                                     :handler
-                                             (fn [response]
-                                               (router/dispatch! "/#/services")
-                                               (message/mount!
-                                                 (str "Service " (get "ID" response) " has been created.")))
-                                     :error-handler
-                                             (fn [{:keys [status status-text]}]
-                                               (message/mount!
-                                                 (str "Service creation failed. Reason: " status-text)))}))}))]]]))
+                :onTouchTap (create-service-handler)}))]]]))
 
 (defn- init-settings-state
   []

            [swarmpit.component.service.form-ports :as ports]
            [swarmpit.component.service.form-variables :as variables]
            [swarmpit.component.message :as message]
            [rum.core :as rum]
            [ajax.core :refer [POST]]))


          item)))
    steps))

(defn- create-service-handler
  []
  (POST "/services"
        {:format  :json
         :params  (-> @settings/state
                      (assoc :ports @ports/state)
                      (assoc :variables @variables/state))
         :finally (progress/mount!)
         :handler
                  (fn [response]
                    (let [id (get response "ID")]
                      (progress/unmount!)
                      (router/dispatch! (str "/#/services/" id))
                      (message/mount!
                        (str "Service " id " has been created."))))
         :error-handler
                  (fn [{:keys [status status-text]}]
                    (progress/unmount!)
                    (message/mount!
                      (str "Service creation failed. Status: " status " Reason: " status-text)))}))

(rum/defc form < rum/reactive []
  (let [index (rum/react step-index)]
