imgs folder

This commit is contained in:
ntr
2019-07-09 16:54:47 +10:00
parent fac62329e8
commit b33ca86a58
11 changed files with 91 additions and 20 deletions
+17 -5
View File
@@ -3,7 +3,7 @@ const preact = require('preact');
const { Component } = require('preact')
const { connect } = require('preact-redux');
const { postData } = require('../utils');
const { postData, errorToast } = require('../utils');
const addState = connect(
(state) => {
@@ -12,14 +12,26 @@ const addState = connect(
} = state;
function submitLogin(name, password) {
postData('/login', { name, password })
.then(data => ws.connect())
.catch(error => console.error(error));
.then(res => {
if (!res.ok) return errorToast(res);
res.text()
})
.then(res => {
ws.connect();
})
.catch(error => errorToast(error));
}
function submitRegister(name, password, code) {
postData('/register', { name, password, code })
.then(data => ws.connect())
.catch(error => console.error(error));
.then(res => {
if (!res.ok) return errorToast(res);
res.text()
})
.then(res => {
ws.connect();
})
.catch(error => errorToast(error));
}
return {
+1 -1
View File
@@ -194,7 +194,7 @@ function registerEvents(store) {
function errorPrompt(type) {
const message = errMessages[type];
const OK_BUTTON = '<button type="submit">OK</button>';
toast.info({
toast.error({
theme: 'dark',
color: 'black',
timeout: false,
+12
View File
@@ -1,5 +1,6 @@
const preact = require('preact');
const get = require('lodash/get');
const toast = require('izitoast');
const shapes = require('./components/shapes');
@@ -369,6 +370,16 @@ function postData(url = '/', data = {}) {
});
}
function errorToast(message) {
toast.error({
position: 'topRight',
drag: false,
close: false,
message,
});
}
module.exports = {
stringSort,
convertItem,
@@ -377,6 +388,7 @@ module.exports = {
getCombatSequence,
getCombatText,
postData,
errorToast,
NULL_UUID,
STATS,
COLOURS,