diff --git a/src/modules/blockchains/Buy/hooks/useHandleDragging.ts b/src/modules/blockchains/Buy/hooks/useHandleDragging.ts index 1494b9eb4..30f9efe83 100644 --- a/src/modules/blockchains/Buy/hooks/useHandleDragging.ts +++ b/src/modules/blockchains/Buy/hooks/useHandleDragging.ts @@ -113,7 +113,6 @@ export default function useHandleDragging() { setDraggingParent(false); const { over, active } = event; - console.log('over, active', { over, active }); // Format ID of single option = - // Format ID of parent option = -parent- @@ -143,7 +142,7 @@ export default function useHandleDragging() { const category = categoryMapping?.[activeKey]; const totalTemplateDapps = templateDapps.length; const ignoreKeys = ['bridge_apps', 'gaming_apps']; - console.log('runnnnnnnn 1'); + if (!rightDragging && !overIsFinalDroppable && overSuffix1 !== 'right') { if (isMultiChoice) { const currentValues = (field[activeKey].value || []) as string[]; @@ -189,7 +188,7 @@ export default function useHandleDragging() { } return; } - console.log('runnnnnnnn 2'); + if (rightDragging && !overIsFinalDroppable && overSuffix1 === 'right') { // swap activeKey, overKey in draggedFields const _draggedFields = cloneDeep(draggedFields); @@ -206,17 +205,17 @@ export default function useHandleDragging() { return; } - console.log('runnnnnnnn 3'); + if (activeIsNotAChainField && !ignoreKeys.includes(activeKey)) { return; } - console.log('runnnnnnnn 4'); + if (!category?.updatable && isUpdateFlow) { // TODO: Notify if needed return; } - console.log('runnnnnnnn 5'); + if (!isMultiChoice) { // Error case if ( @@ -279,7 +278,6 @@ export default function useHandleDragging() { return; } - console.log('runnnnnnnn 6'); // Active is parent and drag to the left side if ( @@ -314,7 +312,7 @@ export default function useHandleDragging() { index, ); } - console.log('nodessssss', nodes[index + 1 + totalTemplateDapps]); + setRemovedNode(nodes[index + 1 + totalTemplateDapps]); setNodes(removeItemAtIndex(nodes, index + 1 + totalTemplateDapps)); } @@ -332,21 +330,19 @@ export default function useHandleDragging() { index, ); } - console.log('nodessssss1', nodes[index + 1 + totalTemplateDapps]); setRemovedNode(nodes[index + 1 + totalTemplateDapps]); setNodes(removeItemAtIndex(nodes, index + 1 + totalTemplateDapps)); } return; } - console.log('runnnnnnnn 7'); + // Multi choice case if ( (over && (overIsFinalDroppable || overIsParentOfActiveDroppable)) || (!overIsFinalDroppable && overSuffix1 === 'right') || !over ) { - console.log('runnnnnnnn 8'); const currentValues = (field[activeKey].value || []) as string[]; const isCurrentEmpty = currentValues.length === 0; const newValue = [...currentValues, active.data.current.value]; @@ -386,8 +382,6 @@ export default function useHandleDragging() { draggedIds2DSignal.value = [...draggedIds2DSignal.value, []]; } } else { - console.log('runnnnnnnn 9'); - const currentValues = (field[activeKey].value || []) as string[]; const newValue = currentValues.filter( (value) => value !== active.data.current.value, @@ -425,7 +419,6 @@ export default function useHandleDragging() { draggedIds2DSignal.value, index, ); - console.log('nodessssss2', nodes[index + 1 + totalTemplateDapps]); setRemovedNode(nodes[index + 1 + totalTemplateDapps]); setNodes(removeItemAtIndex(nodes, index + 1 + totalTemplateDapps)); } @@ -443,7 +436,6 @@ export default function useHandleDragging() { draggedIds2DSignal.value, index, ); - console.log('nodessssss3', nodes[index + 1 + totalTemplateDapps]); setRemovedNode(nodes[index + 1 + totalTemplateDapps]); setNodes(removeItemAtIndex(nodes, index + 1 + totalTemplateDapps)); } @@ -453,8 +445,6 @@ export default function useHandleDragging() { }; const handleDappDragEnd = (event: any) => { - console.log('[useHandleDragging] handleDappDragEnd', event); - const { over, active } = event; subScribeDropEnd.value += 1; blockDraggingSignal.value = { @@ -509,30 +499,6 @@ export default function useHandleDragging() { const activeIsASingle = DragUtil.idDraggingIsASingle(activeId); const activeIsABaseModule = DragUtil.idDraggingIsABaseModule(activeId); - console.log('[useHandleDragging] handleDappDragEnd', { - active, - over, - overIsInput, - overIsOutput, - overIsABase, - overBaseIndex, - overIsABlock, - overIndex, - overOriginalKey, - activeFromRightSide, - activeFromLeftSide, - activeIsAChildOfABlock, - activeIsRightSide, - activeBaseIndex, - activeIndex, - activeOriginalKey, - activeFieldKey, - activeIsABase, - activeIsAModule, - activeIsABlock, - activeIsASingle, - }); - // Case 0.1: Drag to the block parent if (activeFromLeftSide && activeIsAChildOfABlock && overIsABlock) { if (activeOriginalKey !== overOriginalKey) { @@ -1164,15 +1130,7 @@ export default function useHandleDragging() { if (activeIsABase) { const totalTemplateDapps = (templateDapps || []).length; const removeIndex = activeBaseIndex + 1 + totalTemplateDapps; - console.log('JK HEHEHHE', { - nodes: nodes, - edges: edges.length, - removeIndex, - activeBaseIndex, - totalTemplateDapps, - }); const rootNode = 'blockchain'; - console.log('nodessssss', nodes[removeIndex]); setRemovedNode(nodes[removeIndex]); let newNodes = removeItemAtIndex(nodes, removeIndex); @@ -1242,7 +1200,6 @@ export default function useHandleDragging() { }, }; }); - console.log('JK HEHEHHE newNodes', newNodes); //Drag remove node setNodes(newNodes); needReactFlowRenderSignal.value = true; diff --git a/src/modules/blockchains/Buy/studio/Controls/index.tsx b/src/modules/blockchains/Buy/studio/Controls/index.tsx index b7983d245..b93096afd 100644 --- a/src/modules/blockchains/Buy/studio/Controls/index.tsx +++ b/src/modules/blockchains/Buy/studio/Controls/index.tsx @@ -8,16 +8,13 @@ import useOrderFormStoreV3 from '@/modules/blockchains/Buy/stores/index_v3'; import useModelCategoriesStore from '@/modules/blockchains/Buy/stores/useModelCategoriesStore'; import s from '@/modules/blockchains/Buy/styles_v6.module.scss'; import Droppable from '@/modules/blockchains/dapp/components/Droppable'; -import { useAppSelector } from '@/stores/hooks'; -import { dappSelector } from '@/stores/states/dapp/selector'; import { formatCurrencyV2 } from '@utils/format'; import { compareString } from '@utils/string'; -import { useParams } from 'next/navigation'; import React, { memo } from 'react'; import useDapps from '../../hooks/useDapps'; import { accountAbstractionAsADapp } from '../../mockup_3'; import { chainKeyToDappKey, isChainOptionDisabled } from '../../utils'; -import { DappModel } from '@/types/customize-model'; +import useStudioInfo from '../../hooks/useStudioInfo'; const ignoreFields = ['bridge_apps', 'gaming_apps', 'wallet_type']; const shouldGenFields = ['defi_apps', 'degen_apps']; @@ -26,13 +23,15 @@ const ignoreFieldMapper: Record = { }; export default memo(function StudioControls() { - const { parsedCategories } = useModelCategoriesStore(); - const { field } = useOrderFormStoreV3(); + const parsedCategories = useModelCategoriesStore( + (state) => state.parsedCategories, + ); + const field = useOrderFormStoreV3((state) => state.field); + const { dapps, dappMapping } = useDapps(); - const dappState = useAppSelector(dappSelector); - const params = useParams(); - const isUpdateChainFlow = React.useMemo(() => !!params?.id, [params?.id]); + const { isUpdateFlow } = useStudioInfo(); + const currentNetwork = React.useMemo( () => field['network']?.value as string, [field['network']?.value], @@ -59,7 +58,7 @@ export default memo(function StudioControls() { return ( opt.key === 'wallet_type', ); - const degenDapp = isUpdateChainFlow + const degenDapp = isUpdateFlow ? dapps?.find((item) => compareString( item.key, @@ -189,10 +188,10 @@ export default memo(function StudioControls() { {item.options.map((option, index) => { - const dapp = isUpdateChainFlow + const dapp = isUpdateFlow ? dapps?.find((item) => compareString( item.key,