summaryrefslogtreecommitdiff
path: root/frontend/src/models/errors.js
diff options
context:
space:
mode:
authorVictor Chabbert <chabbertvi@eisti.eu>2017-05-28 20:42:21 +0200
committerVictor Chabbert <chabbertvi@eisti.eu>2017-05-28 20:42:21 +0200
commit0bf423172ffb2e4030b521b0985d133cb5c61dd9 (patch)
tree0c24821770274a414f80b3092d5be54902c042d9 /frontend/src/models/errors.js
parentFix proxy not working since CRA upgrade (diff)
downloadseven-wonders-0bf423172ffb2e4030b521b0985d133cb5c61dd9.tar.gz
seven-wonders-0bf423172ffb2e4030b521b0985d133cb5c61dd9.tar.bz2
seven-wonders-0bf423172ffb2e4030b521b0985d133cb5c61dd9.zip
Move to immutable with Records
Diffstat (limited to 'frontend/src/models/errors.js')
-rw-r--r--frontend/src/models/errors.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/frontend/src/models/errors.js b/frontend/src/models/errors.js
new file mode 100644
index 00000000..c00954cd
--- /dev/null
+++ b/frontend/src/models/errors.js
@@ -0,0 +1,34 @@
+import { Record, List } from 'immutable';
+
+const ErrorsRecord = Record({
+ nextId: 0,
+ history: new List(),
+});
+
+export default class ErrorsState extends ErrorsRecord {
+ addError(error) {
+ const errorObject = new Error({ id: this.nextId, error: new ErrorBag(error) });
+ return this.set('history', this.history.push(errorObject)).set('nextId', this.nextId + 1);
+ }
+}
+
+const ErrorRecord = Record({
+ id: -1,
+ timestamp: new Date(),
+ error: new ErrorsRecord(),
+});
+
+export class Error extends ErrorRecord {}
+
+const ErrorBagRecord = Record({
+ type: '',
+ position: 'bottom-left',
+ options: {
+ icon: 'error',
+ removeOnHover: true,
+ showCloseButton: true,
+ },
+ title: 'Unknown Error',
+});
+
+export class ErrorBag extends ErrorBagRecord {}
bgstack15