mirror of
https://github.com/zoriya/Aeris.git
synced 2026-06-07 20:32:41 +00:00
adding update ids on state
This commit is contained in:
@@ -71,9 +71,13 @@ export default function HomePage() {
|
||||
const [pipelinesData, setPipelinesData] = useState<Array<AppPipelineType>>([]);
|
||||
|
||||
const homePagePipeLineSave = async (pD: AppPipelineType, creation: boolean) => {
|
||||
if (await requestCreatePipeline(pD, creation)) {
|
||||
if (creation) setPipelinesData([...pipelinesData, pD]);
|
||||
else setPipelinesData(pipelinesData.map((iPd) => (iPd.id !== pD.id ? iPd : pD)));
|
||||
let pDId = await requestCreatePipeline(pD, creation);
|
||||
console.log(pDId);
|
||||
if (pDId > 0) {
|
||||
if (creation) {
|
||||
pD.id = pDId;
|
||||
setPipelinesData([...pipelinesData, pD]);
|
||||
} else setPipelinesData(pipelinesData.map((iPd) => (iPd.id !== pD.id ? iPd : pD)));
|
||||
return setModalMode(ModalSelection.None);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { AppPipelineType } from "./types";
|
||||
import { getCookie, PipeLineHostToApi } from "./utils";
|
||||
import { API_ROUTE } from "./globals";
|
||||
|
||||
export const requestCreatePipeline = async (pipelineData: AppPipelineType, creation: boolean): Promise<boolean> => {
|
||||
export const requestCreatePipeline = async (pipelineData: AppPipelineType, creation: boolean): Promise<number> => {
|
||||
const jwt = getCookie("aeris_jwt");
|
||||
|
||||
const request = API_ROUTE + "/workflow/" + (!creation ? pipelineData.id : "");
|
||||
@@ -16,7 +16,9 @@ export const requestCreatePipeline = async (pipelineData: AppPipelineType, creat
|
||||
},
|
||||
body: JSON.stringify(PipeLineHostToApi(pipelineData)),
|
||||
});
|
||||
return rawResponse.ok;
|
||||
|
||||
let data = await rawResponse.json();
|
||||
return rawResponse.ok ? data.action?.id ?? -2 : -1;
|
||||
};
|
||||
|
||||
export const deletePipeline = async (pipelineData: AppPipelineType): Promise<boolean> => {
|
||||
@@ -37,8 +39,7 @@ export const deletePipeline = async (pipelineData: AppPipelineType): Promise<boo
|
||||
|
||||
export const getAboutJson = async (): Promise<any> => {
|
||||
const rawResponse = await fetch(API_ROUTE + "/about.json");
|
||||
if (!rawResponse.ok)
|
||||
return {};
|
||||
if (!rawResponse.ok) return {};
|
||||
let json = await rawResponse.json();
|
||||
return json ?? {};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user