Skip to content

Commit

Permalink
comment disable prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jackie2111 committed Oct 3, 2024
1 parent 857c25f commit 2f55971
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 66 deletions.
57 changes: 7 additions & 50 deletions src/modules/blockchains/Buy/hooks/useHandleDragging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <key>-<value>
// Format ID of parent option = <key>-parent-<suffix>
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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);
Expand All @@ -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 (
Expand Down Expand Up @@ -279,7 +278,6 @@ export default function useHandleDragging() {

return;
}
console.log('runnnnnnnn 6');

// Active is parent and drag to the left side
if (
Expand Down Expand Up @@ -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));
}
Expand All @@ -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];
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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 = {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1242,7 +1200,6 @@ export default function useHandleDragging() {
},
};
});
console.log('JK HEHEHHE newNodes', newNodes);
//Drag remove node
setNodes(newNodes);
needReactFlowRenderSignal.value = true;
Expand Down
31 changes: 15 additions & 16 deletions src/modules/blockchains/Buy/studio/Controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -26,13 +23,15 @@ const ignoreFieldMapper: Record<string, string[]> = {
};

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],
Expand All @@ -59,7 +58,7 @@ export default memo(function StudioControls() {
return (
<BoxOptionV3
key={item.key}
disable={item.disable || (isUpdateChainFlow && !item.updatable)}
disable={item.disable || (isUpdateFlow && !item.updatable)}
label={item.title}
id={item.key}
isRequired={item.required}
Expand Down Expand Up @@ -161,7 +160,7 @@ export default memo(function StudioControls() {
const walletTypeOption = dengenCategory?.options.find(
(opt) => opt.key === 'wallet_type',
);
const degenDapp = isUpdateChainFlow
const degenDapp = isUpdateFlow
? dapps?.find((item) =>
compareString(
item.key,
Expand Down Expand Up @@ -189,10 +188,10 @@ export default memo(function StudioControls() {
<BoxOption
info={{
...item.options[0],
disabled:
item.disable ||
!item.options[0].selectable ||
isChainOptionDisabled(field, item, item.options[0]),
disabled: false,
// item.disable ||
// !item.options[0].selectable ||
// isChainOptionDisabled(field, item, item.options[0]),
title: '',
description: {
title: item.title,
Expand Down Expand Up @@ -243,7 +242,7 @@ export default memo(function StudioControls() {
needCheckIcon={false}
>
{item.options.map((option, index) => {
const dapp = isUpdateChainFlow
const dapp = isUpdateFlow
? dapps?.find((item) =>
compareString(
item.key,
Expand Down

0 comments on commit 2f55971

Please sign in to comment.