Bladeren bron

listeners for input fields added.

miskson 3 jaren geleden
bovenliggende
commit
e3e4fff70a
2 gewijzigde bestanden met toevoegingen van 30 en 12 verwijderingen
  1. 2 2
      hw15-gql-cathegory-pg/GQL.html
  2. 28 10
      hw15-gql-cathegory-pg/GQL_files/index.js

+ 2 - 2
hw15-gql-cathegory-pg/GQL.html

@@ -51,8 +51,8 @@
     <h1>ГДЕ Я ОКАЗАЛСЯ?</h1>
     <div>
       <span>Name</span>
-      <button id="logBtn">log-in/out</button>
-      <button>order</button>
+      <a id="logBtn" href="#/login" style="color: hotpink;">log-in</a>
+      <!-- <button>order</button> -->
     </div>
   </header>
 

+ 28 - 10
hw15-gql-cathegory-pg/GQL_files/index.js

@@ -171,10 +171,6 @@ const actionFullLogin = (login, password) =>
     //
 
 let logBtn = document.getElementById('logBtn')
-logBtn.onclick = () => {
-    location.href = "#/login"
-    store.dispatch(actionLogin())
-}
 /********************************MY STUFFF END****************************************************** */
 const actionRootCats = () =>
     actionPromise('rootCats', gql(`query {
@@ -243,7 +239,7 @@ window.onhashchange = () => {
             store.dispatch(actionGoodById(_id))
         },
         login() {
-
+            store.dispatch(actionLogin())
         }
     }
     if (route in routes)
@@ -325,28 +321,50 @@ store.subscribe(()=> {
     const { login } = store.getState().promise
     const [, route, _id] = location.hash.split('/')
     
-    let passInp, logInp
+    let pass, log
     if(!login?.payload && route === 'login') {
         console.log('hire');
         aside.innerHTML = ''
         main.innerHTML = `
-            <div style="border: 1px solid black; padding: 10px">
+            <div style="border: 5px solid purple; padding: 10px; background-color: black;">
                 <button id="returnBtnLogin">&#8656 назад</button>
                 <input  id="logInp" style="display:block; margin:10px" type="text" placeholder="login"/>
                 <input  id="passInp" style="display:block; margin:10px" type="text" placeholder="password"/>
-                <button style="display:block; margin:0 auto">LOGIN</button>
+                <button id="submitBtn" style="display:block; margin:0 auto">LOGIN</button>
             </div>
         `
         let returnBtn = document.getElementById('returnBtnLogin')
-        logInp = document.getElementById('logInp')
-        passInp = document.getElementById('passInp')
+        let logInp = document.getElementById('logInp')
+        let passInp = document.getElementById('passInp')
+        let submitBtn = document.getElementById('submitBtn')
+
+        passInp.oninput = (e) => {
+            console.log(e.target.value)
+            pass = e.target.value
+        }
+
+        logInp.oninput = (e) => {
+            console.log(e.target.value)
+            log = e.target.value
+        }
 
         returnBtn.onclick = () => {
             logBtn.disabled = false
             history.back()
         }
+
+        submitBtn.onclick = () => {
+            //store.dispatch(actionLogin(log, pass))
+            console.log('BABAX')
+        }
+
         logBtn.disabled = true
     }
+
+    if(login?.payload && route === 'login') {
+        history.back()
+
+    }
 })
 
 window.onload = () => {