mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
committed by
GitHub
parent
7d0ec72a0c
commit
2c5eceb0c1
@@ -1,5 +1,4 @@
|
||||
import { xhrGet } from '../../xhr';
|
||||
|
||||
export const generalSettings = {
|
||||
state: {
|
||||
settings: {},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { xhrGet } from '../../xhr';
|
||||
|
||||
export const jobs = {
|
||||
state: {
|
||||
jobs: [],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { xhrGet } from '../../xhr';
|
||||
|
||||
export const user = {
|
||||
state: {
|
||||
users: [],
|
||||
|
||||
@@ -6,14 +6,11 @@ import { createLogger } from 'redux-logger';
|
||||
import { jobs } from './models/jobs';
|
||||
import { user } from './models/user';
|
||||
import { init } from '@rematch/core';
|
||||
|
||||
const middleware = [];
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// eslint-disable-line no-redeclare
|
||||
middleware.push(createLogger({ duration: false, collapsed: (getState, action, logEntry) => !logEntry.error }));
|
||||
}
|
||||
|
||||
const store = init({
|
||||
name: 'fredy',
|
||||
models: {
|
||||
@@ -28,5 +25,4 @@ const store = init({
|
||||
middlewares: middleware,
|
||||
},
|
||||
});
|
||||
|
||||
export const reduxStore = store;
|
||||
|
||||
@@ -8,5 +8,4 @@ export function format(ts) {
|
||||
second: 'numeric',
|
||||
}).format(ts);
|
||||
}
|
||||
|
||||
export const roundToNext5Minute = (ts) => Math.ceil(ts / (1000 * 60 * 5)) * (1000 * 60 * 5);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
export function transform({ id, name, fields }) {
|
||||
const fieldValues = {};
|
||||
|
||||
Object.keys(fields).map((key) => {
|
||||
fieldValues[key] = fields[key].value;
|
||||
});
|
||||
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
export function xhrPost(url, data, contentType = 'application/json; charset=utf-8', isJson = true) {
|
||||
return executePostOrPutCall(url, contentType, data, isJson, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* put request to backend.
|
||||
*
|
||||
@@ -21,7 +20,6 @@ export function xhrPost(url, data, contentType = 'application/json; charset=utf-
|
||||
export function xhrPut(url, data, contentType = 'application/json; charset=utf-8', isJson = true) {
|
||||
return executePostOrPutCall(url, contentType, data, isJson, false);
|
||||
}
|
||||
|
||||
function executePostOrPutCall(url, contentType, data, isJson, isPost) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(url, {
|
||||
@@ -41,7 +39,6 @@ function executePostOrPutCall(url, contentType, data, isJson, isPost) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* get request to backend
|
||||
* returns a Promise with
|
||||
@@ -75,7 +72,6 @@ export function xhrGet(url, contentType = 'application/json; charset=utf-8', isJ
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* delete request to backend
|
||||
* returns a Promise with
|
||||
@@ -114,7 +110,6 @@ export function xhrDelete(url, data, contentType = 'application/json; charset=ut
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function parseJSON(response) {
|
||||
return new Promise((resolve, reject) =>
|
||||
response
|
||||
@@ -122,7 +117,6 @@ function parseJSON(response) {
|
||||
.then((text) => {
|
||||
//some responses doesn't contain a body. .json() would throw errors here...
|
||||
const json = text != null && text.length > 0 ? JSON.parse(text) : {};
|
||||
|
||||
if (response.ok) {
|
||||
resolve({
|
||||
status: response.status,
|
||||
|
||||
Reference in New Issue
Block a user