From f3b2ea153659fe105ec336ade78e02da662be5d4 Mon Sep 17 00:00:00 2001 From: Jackie <1121@generative.xyz> Date: Fri, 6 Sep 2024 10:51:22 +0700 Subject: [PATCH] update logic create a token --- .../Buy/component4/Dropdown/index.tsx | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/modules/blockchains/Buy/component4/Dropdown/index.tsx b/src/modules/blockchains/Buy/component4/Dropdown/index.tsx index 07f84fbd2..3cd7cab07 100644 --- a/src/modules/blockchains/Buy/component4/Dropdown/index.tsx +++ b/src/modules/blockchains/Buy/component4/Dropdown/index.tsx @@ -16,11 +16,13 @@ import { adjustBrightness, FormDappUtil } from '../../utils'; import { FieldModel } from '@/types/customize-model'; import { compareString } from '@/utils/string'; import { + draggedDappIndexesSignal, draggedIds2DSignal, templateIds2DSignal, } from '../../signals/useDragSignal'; import styles from './styles.module.scss'; import { iconToolNames } from '@/modules/blockchains/Buy/Buy.data'; +import useDraggingStore from '../../stores/useDraggingStore'; type Props = { onlyLabel?: boolean; @@ -40,12 +42,13 @@ const Dropdown = ({ onlyLabel = false, ...props }: Props) => { - const { setCurrentIndexDapp } = useDappsStore(); + const { dapps } = useDappsStore(); const ref = React.useRef(null); const [isOpenDropdown, setIsOpenDropdown] = React.useState(false); const [currentValue, setCurrentValue] = React.useState( props.options[0], ); + const { setIsDragging } = useDraggingStore(); useOnClickOutside(ref, () => setIsOpenDropdown(false)); @@ -68,13 +71,19 @@ const Dropdown = ({ }; const handleOnClickCreateToken = () => { - formDappSignal.value = {}; - draggedIds2DSignal.value = []; - - formTemplateDappSignal.value = {}; - templateIds2DSignal.value = []; - - setCurrentIndexDapp(0); + const tokenDappIndex = dapps.findIndex( + (item) => item.key === 'token_generation', + ); + + setIsDragging(true); + + setTimeout(() => { + draggedDappIndexesSignal.value = [ + ...draggedDappIndexesSignal.value, + tokenDappIndex, + ]; + draggedIds2DSignal.value = [...draggedIds2DSignal.value, []]; + }, 300); }; useSignalEffect(() => { @@ -160,8 +169,10 @@ const Dropdown = ({ const _icon = iconToolNames.find( (item) => - currentValue.icon?.replace('https://storage.googleapis.com/bvm-network', '') === - item, + currentValue.icon?.replace( + 'https://storage.googleapis.com/bvm-network', + '', + ) === item, ) || currentValue.icon || null; @@ -184,9 +195,7 @@ const Dropdown = ({ className={styles.dropdown__inner__content} onClick={() => setIsOpenDropdown(!isOpenDropdown)} > - {_icon && ( - icon - )} + {_icon && icon}

{currentValue.title} @@ -212,8 +221,10 @@ const Dropdown = ({ const _icon2 = iconToolNames.find( (iconName) => - item.icon?.replace('https://storage.googleapis.com/bvm-network', '') === - iconName, + item.icon?.replace( + 'https://storage.googleapis.com/bvm-network', + '', + ) === iconName, ) || item.icon || null; @@ -222,7 +233,7 @@ const Dropdown = ({ key={item.key} className={cn(styles.dropdown__list__item, { [styles.dropdown__list__item__active]: - currentValue.key === item.key, + currentValue.key === item.key, })} onClick={() => handleOnClickOption(item)} > @@ -232,7 +243,7 @@ const Dropdown = ({

{item.title}

- ) + ); })}