updating api routing

This commit is contained in:
ari committed 2022-05-16 15:38:13 -04:00
1 parent dc726ff184
commit 0be03b1536
7 files changed
+53 -63

No files matched your search

+5 -5
View File
@@ -1,7 +1,7 @@
import { AutomationData } from "types/automations";
import { API } from "./base";
import { ListData, ListParams } from "./types";
import { AUTOMTAION_LIST, AUTOMTAION_ROOT } from './paths';
import { AUTOMTAION_LIST, AUTOMTAION_ITEM } from './paths';
export const makeAutomationAPI = (api: API) => ({
@@ -14,19 +14,19 @@ export const makeAutomationAPI = (api: API) => ({
});
return data;
},
async update({index, auto}: {index: number, auto: AutomationData}) {
async update({ index, auto }: { index: number, auto: AutomationData }) {
return await api.makeCall({
path: AUTOMTAION_ROOT,
path: AUTOMTAION_ITEM,
data: {
index,
data: auto
},
})
},
async remove({index}: {index: number}) {
async remove({ index }: { index: number }) {
return await api.makeCall({
method: "DELETE",
path: AUTOMTAION_ROOT,
path: AUTOMTAION_ITEM,
data: {
index,
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { useRef } from 'react';
import { AutomationData } from 'types/automations';
import { API } from './base';
import { AUTOMTAION_LIST, AUTOMTAION_ROOT } from './paths';
import { AUTOMTAION_LIST, AUTOMTAION_ITEM } from './paths';
export const useMockAPI = (
@@ -26,7 +26,7 @@ export const useMockAPI = (
}))
} as any
}
if (path === AUTOMTAION_ROOT) {
if (path === AUTOMTAION_ITEM) {
if (method === 'POST') {
const { index, data: auto } = data as any;
if (index >= automationsRef.current.length) {
@@ -37,7 +37,7 @@ export const useMockAPI = (
auto,
...automationsRef.current.slice(index + 1)
];
}
}
return {
ok: true,
data: {}
+3 -2
View File
@@ -1,4 +1,5 @@
export const AUTOMTAION_ROOT = '' as const;
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}/list` as const;
export const AUTOMTAION_ROOT = '/' as const;
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}list` as const;
export const AUTOMTAION_ITEM = `${AUTOMTAION_ROOT}item` as const;