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

requests

parent ffaba6a9
......@@ -66,5 +66,22 @@ img {
font-family: monospace;
padding: 0 32px 16px;
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', () => {
logo: 'Account',
logout: function() {
store.set('account.token', false);
store.set('account.data', false);
},
profile: 'Profile'
};
......
import './Field.scss';
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 } )}>
<label class="field__label">
<span class="field__label-text">{cfg.label}</span>
......@@ -9,4 +9,7 @@ export default D.declare('view.cmp.field.LabeledField', (cfg, children)=> {
</label>
{children}
</div>
})
});
export default LabeledField;
export {LabeledField};
\ No newline at end of file
......@@ -39,11 +39,16 @@ const Login = D.declare('view.page.Login', () => {
loginStore.set({phone})
}else{
const result = await AsyncAuthAjax.get( API.ENDPOINTS.GET_USER( store.get( 'account.userID' ) ) );
store.set( 'account.data', result );
if( result.lastLoginAt ){
store.set( 'navigation.current', 'Account' );
if(store.get('account.data') &&
store.get('navigation.current') !== 'Login'){
}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";
import { AsyncAuthAjax } from "../../../controller/Ajax";
import {API} from "../../../dict/Consts";
const TestRequests = D.declare('view.page.tmp.TestRequests', () => {
let response;
return <div>
Курвалол
<button onclick={async()=>{
const result = await AsyncAuthAjax.get(API.ENDPOINTS.GET_USER(store.get('account.userID')));
response.innerText = JSON.stringify(result, null, 2);
}}>Get user</button>
<div className='error-block'>{response = <div></div>}</div>
return <div style={{padding: '16px'}}>
<h1>Testing requests</h1>
{((response, s = new Store({id: store.get('account.userID')}))=>
<div class='test-request-block'>
<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>
});
......
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