Making Fredy an ESM project (#70)

Making Fredy an ESM project
This commit is contained in:
Christian Kellner
2023-03-13 13:42:43 +01:00
committed by GitHub
parent 7d0ec72a0c
commit 2c5eceb0c1
69 changed files with 862 additions and 1567 deletions

View File

@@ -1,5 +1,4 @@
import { xhrGet } from '../../xhr';
export const generalSettings = {
state: {
settings: {},

View File

@@ -1,5 +1,4 @@
import { xhrGet } from '../../xhr';
export const jobs = {
state: {
jobs: [],

View File

@@ -1,5 +1,4 @@
import { xhrGet } from '../../xhr';
export const user = {
state: {
users: [],

View File

@@ -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;

View File

@@ -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);

View File

@@ -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,

View File

@@ -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,