(ns auto-ap.views.pages.login
  (:require
   [auto-ap.views.utils :refer [login-url]]
   [re-frame.core :as re-frame]
   [cemerick.url :as url]))

(re-frame/reg-sub
 ::logout-reason
 (fn [db] (-> db :logout-reason)))

(defn login-page []
  [:div.container
   [:section.is-fullheight.hero
    [:div.hero-body
     [:div.container
      [:div.column.is-4.is-offset-4.has-text-centered
       (when-let [reason @(re-frame/subscribe [::logout-reason])]
         [:div.notification.is-warning reason])
       [:h1.title "Login"]
       [:div.box.slideInFromBelow

        [:img {:src "/img/logo-big.png"}]
        [:div
         [:a.button.is-large.is-primary {:href (login-url (get (:query (url/url (.-location js/window))) "redirect-to"))} "Login with Google"]]]
       [:p.has-text-gray
        "Copyright Integreat 2018"]]]]]])
