fix(StorePage/index.tsx): add is_component parameter to handleFork function to properly clone flow with parent
fix(StorePage/index.tsx): pass is_component parameter to cloneFLowWithParent function when cloning flow fix(StorePage/index.tsx): log newFlow after cloning with parent fix(StorePage/index.tsx): log parsed response after saving cloned flow to flow store fix(StorePage/index.tsx): pass item.is_component parameter to handleFork function when adding MarketCardComponent fix(StorePage/index.tsx): pass item.id and item.is_component parameters to handleFork function when adding MarketCardComponent fix(StorePage/index.tsx): pass data[0].id and data[0].is_component parameters to handleFork function when clicking test button fix(storeUtils.ts): add is_component parameter to cloneFLowWithParent function to properly set is_component property of cloned flow
This commit is contained in:
parent
8b9267b2e8
commit
55e28bdeba
2 changed files with 14 additions and 7 deletions
|
|
@ -83,14 +83,15 @@ export default function StorePage(): JSX.Element {
|
||||||
const loadingWithApiKey = loading;
|
const loadingWithApiKey = loading;
|
||||||
const renderComponents = !loading;
|
const renderComponents = !loading;
|
||||||
|
|
||||||
function handleFork(flowId: string) {
|
function handleFork(flowId: string, is_component: boolean) {
|
||||||
getComponent(flowId).then(
|
getComponent(flowId).then(
|
||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
const newFLow = cloneFLowWithParent(res);
|
const newFLow = cloneFLowWithParent(res.data, is_component);
|
||||||
|
console.log(newFLow);
|
||||||
saveFlowStore(newFLow).then(
|
saveFlowStore(newFLow).then(
|
||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(JSON.parse(JSON.stringify(res)));
|
||||||
addFlow(true, newFLow);
|
addFlow(true, newFLow);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|
@ -222,12 +223,17 @@ export default function StorePage(): JSX.Element {
|
||||||
filteredCategories.has(f.is_component)
|
filteredCategories.has(f.is_component)
|
||||||
)
|
)
|
||||||
.map((item, idx) => (
|
.map((item, idx) => (
|
||||||
<MarketCardComponent key={idx} data={item} onAdd={() => {}} />
|
<MarketCardComponent
|
||||||
|
key={idx}
|
||||||
|
data={item}
|
||||||
|
onAdd={() => {
|
||||||
|
handleFork(item.id, item.is_component);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log(data);
|
handleFork(data[0].id, data[0].is_component);
|
||||||
handleFork(data[0].id);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
test
|
test
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { FlowType } from "../types/flow";
|
import { FlowType } from "../types/flow";
|
||||||
|
|
||||||
export default function cloneFLowWithParent(flow: FlowType) {
|
export default function cloneFLowWithParent(flow: FlowType, is_component) {
|
||||||
const parent = flow.id;
|
const parent = flow.id;
|
||||||
let childFLow = cloneDeep(flow);
|
let childFLow = cloneDeep(flow);
|
||||||
childFLow.parent = parent;
|
childFLow.parent = parent;
|
||||||
childFLow.id = "";
|
childFLow.id = "";
|
||||||
|
childFLow.is_component = is_component;
|
||||||
return childFLow;
|
return childFLow;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue