refactor(market-card.tsx): remove unused handleFork function to improve code readability and maintainability
feat(market-card.tsx): add setErrorData function to alertContext to handle error messages when adding a component feat(market-card.tsx): add setSuccessData function to alertContext to display success message when adding a component
This commit is contained in:
parent
4775cd1d95
commit
95af78ef08
1 changed files with 6 additions and 23 deletions
|
|
@ -23,7 +23,7 @@ export const MarketCardComponent = ({ data }: { data: storeComponent }) => {
|
|||
const [added, setAdded] = useState(savedFlows.has(data.id) ? true : false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { addFlow } = useContext(TabsContext);
|
||||
const { setSuccessData } = useContext(alertContext);
|
||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||
const flowData = useRef<FlowType>();
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -42,9 +42,14 @@ export const MarketCardComponent = ({ data }: { data: storeComponent }) => {
|
|||
.then(() => {
|
||||
setAdded(true);
|
||||
setLoading(false);
|
||||
setSuccessData({ title: "Component Added to account" });
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
setErrorData({
|
||||
title: "Error on adding Component",
|
||||
list: [error["response"]["data"]["detail"]],
|
||||
});
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
|
|
@ -69,28 +74,6 @@ export const MarketCardComponent = ({ data }: { data: storeComponent }) => {
|
|||
}
|
||||
}
|
||||
|
||||
function handleFork(flowId: string, is_component: boolean) {
|
||||
getComponent(flowId).then(
|
||||
(res) => {
|
||||
console.log(res);
|
||||
const newFLow = cloneFLowWithParent(res.data, res.id, is_component);
|
||||
console.log(newFLow);
|
||||
saveFlowStore(newFLow).then(
|
||||
(res) => {
|
||||
console.log(JSON.parse(JSON.stringify(res)));
|
||||
addFlow(true, newFLow);
|
||||
},
|
||||
(error) => {
|
||||
console.error(error);
|
||||
}
|
||||
);
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="group relative flex cursor-pointer flex-col justify-between overflow-hidden transition-all hover:shadow-md">
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue