0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Integrate the login page ui with the backend.

This commit is contained in:
Andrey Antukh 2016-03-15 20:58:44 +02:00
parent 6a3e0b7743
commit 7494d4936d

View file

@ -1,11 +1,13 @@
(ns uxbox.ui.auth
(:require [sablono.core :as html :refer-macros [html]]
[lentes.core :as l]
[cuerdas.core :as str]
[rum.core :as rum]
[uxbox.router :as r]
[uxbox.state :as s]
[uxbox.rstore :as rs]
[uxbox.data.auth :as da]
[uxbox.util.dom :as dom]
[uxbox.ui.icons :as i]
[uxbox.ui.messages :as uum]
[uxbox.ui.navigation :as nav]
@ -15,11 +17,30 @@
;; Login
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- login-submit
[local]
(let [form (:form @local)]
(rs/emit! (da/login {:username (:email form)
:password (:password form)}))))
(defn- login-submit-enabled?
[local]
(let [form (:form @local)]
(and (not (str/empty? (:email form "")))
(not (str/empty? (:password form ""))))))
(defn- login-field-change
[local field event]
(let [value (str/trim (dom/event->value event))]
(println @local value)
(swap! local assoc-in [:form field] value)))
(defn- login-render
[own local]
(letfn [(on-submit []
(rs/emit! (da/login {:username "cirilla"
:password "secret"})))]
(let [on-submit #(login-submit local)
submit-enabled? (login-submit-enabled? local)
form (:form @local)]
(println "submit-enabled?" submit-enabled?)
(html
[:div.login
[:div.login-body
@ -28,10 +49,16 @@
[:div.login-content
[:input.input-text
{:name "email"
:ref "email"
:value (:email form "")
:on-change #(login-field-change local :email %)
:placeholder "Email or Username"
:type "text"}]
[:input.input-text
{:name "password"
:ref "password"
:value (:password form "")
:on-change #(login-field-change local :password %)
:placeholder "Password"
:type "password"}]
#_[:div.input-checkbox.check-primary
@ -40,6 +67,8 @@
[:label {:for "checkbox1"} "Keep Me Signed in"]]
[:input.btn-primary
{:name "login"
:class (when-not submit-enabled? "btn-disabled")
:disabled (not submit-enabled?)
:value "Continue"
:type "submit"
:on-click on-submit}]