imgs folder
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user