Commit 0fd93e90 by Иван Кубота

requests

parent ffaba6a9
...@@ -66,5 +66,22 @@ img { ...@@ -66,5 +66,22 @@ img {
font-family: monospace; font-family: monospace;
padding: 0 32px 16px; padding: 0 32px 16px;
color: #ccdde8; color: #ccdde8;
font-size: 16px;
} }
} }
.log-block {
background: #ccdde8;
div {
white-space: pre;
font-family: monospace;
padding: 0 32px 16px;
color: #194965;
font-size: 14px;
}
}
.test-request-block {
padding: 0 32px 16px;
}
\ No newline at end of file
...@@ -12,6 +12,7 @@ const Header = D.declare('view.block.Header', () => { ...@@ -12,6 +12,7 @@ const Header = D.declare('view.block.Header', () => {
logo: 'Account', logo: 'Account',
logout: function() { logout: function() {
store.set('account.token', false); store.set('account.token', false);
store.set('account.data', false);
}, },
profile: 'Profile' profile: 'Profile'
}; };
......
import './Field.scss'; import './Field.scss';
import Input from './Input.jsx'; import Input from './Input.jsx';
export default D.declare('view.cmp.field.LabeledField', (cfg, children)=> { const LabeledField = D.declare('view.cmp.field.LabeledField', (cfg, children)=> {
return <div class={D.cls( "field", cfg.cls, { "field--invalid": cfg.invalid } )}> return <div class={D.cls( "field", cfg.cls, { "field--invalid": cfg.invalid } )}>
<label class="field__label"> <label class="field__label">
<span class="field__label-text">{cfg.label}</span> <span class="field__label-text">{cfg.label}</span>
...@@ -9,4 +9,7 @@ export default D.declare('view.cmp.field.LabeledField', (cfg, children)=> { ...@@ -9,4 +9,7 @@ export default D.declare('view.cmp.field.LabeledField', (cfg, children)=> {
</label> </label>
{children} {children}
</div> </div>
}) });
export default LabeledField;
export {LabeledField};
\ No newline at end of file
...@@ -39,11 +39,16 @@ const Login = D.declare('view.page.Login', () => { ...@@ -39,11 +39,16 @@ const Login = D.declare('view.page.Login', () => {
loginStore.set({phone}) loginStore.set({phone})
}else{ }else{
const result = await AsyncAuthAjax.get( API.ENDPOINTS.GET_USER( store.get( 'account.userID' ) ) ); const result = await AsyncAuthAjax.get( API.ENDPOINTS.GET_USER( store.get( 'account.userID' ) ) );
store.set( 'account.data', result ); if(store.get('account.data') &&
if( result.lastLoginAt ){ store.get('navigation.current') !== 'Login'){
store.set( 'navigation.current', 'Account' );
}else{ }else{
store.set( 'navigation.current', 'Welcome' ); store.set( 'account.data', result );
if( result.lastLoginAt ){
store.set( 'navigation.current', 'Account' );
}else{
store.set( 'navigation.current', 'Welcome' );
}
} }
} }
}); });
......
...@@ -5,14 +5,38 @@ import Input from "../../cmp/field/Input"; ...@@ -5,14 +5,38 @@ import Input from "../../cmp/field/Input";
import { AsyncAuthAjax } from "../../../controller/Ajax"; import { AsyncAuthAjax } from "../../../controller/Ajax";
import {API} from "../../../dict/Consts"; import {API} from "../../../dict/Consts";
const TestRequests = D.declare('view.page.tmp.TestRequests', () => { const TestRequests = D.declare('view.page.tmp.TestRequests', () => {
let response;
return <div> return <div style={{padding: '16px'}}>
Курвалол <h1>Testing requests</h1>
<button onclick={async()=>{
const result = await AsyncAuthAjax.get(API.ENDPOINTS.GET_USER(store.get('account.userID')));
response.innerText = JSON.stringify(result, null, 2); {((response, s = new Store({id: store.get('account.userID')}))=>
}}>Get user</button> <div class='test-request-block'>
<div className='error-block'>{response = <div></div>}</div> <LabeledField bind={s.bind('id')} label={'User ID'}/>
<button onClick={async() => {
const result = await AsyncAuthAjax.get( API.ENDPOINTS.GET_USER( s.get( 'id' ) ) );
response.innerText = JSON.stringify( result, null, 2 );
}}>
Get user
</button>
<div className='log-block'>{response = <div/>}</div>
</div>)()}
{((response)=>
<div class='test-request-block'>
<button onClick={async() => {
const result = await AsyncAuthAjax.get( API.ENDPOINTS.GET_USER_NEW_CARDS() );
response.innerText = `${result.length} new cards.
`+JSON.stringify( result.slice(0,3), null, 2 )+'\n\n . . . . .\n\n'+
JSON.stringify( result.slice(result.length-3), null, 2 );
}}>
New cards
</button>
<div className='log-block'>{response = <div/>}</div>
</div>)()}
</div> </div>
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment