Skip to content

Commit

Permalink
update logic create a token
Browse files Browse the repository at this point in the history
  • Loading branch information
jackie2111 committed Sep 6, 2024
1 parent ca7f0cd commit f3b2ea1
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions src/modules/blockchains/Buy/component4/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,12 +42,13 @@ const Dropdown = ({
onlyLabel = false,
...props
}: Props) => {
const { setCurrentIndexDapp } = useDappsStore();
const { dapps } = useDappsStore();
const ref = React.useRef<HTMLDivElement | null>(null);
const [isOpenDropdown, setIsOpenDropdown] = React.useState<boolean>(false);
const [currentValue, setCurrentValue] = React.useState<FieldModel | null>(
props.options[0],
);
const { setIsDragging } = useDraggingStore();

useOnClickOutside(ref, () => setIsOpenDropdown(false));

Expand All @@ -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(() => {
Expand Down Expand Up @@ -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;
Expand All @@ -184,9 +195,7 @@ const Dropdown = ({
className={styles.dropdown__inner__content}
onClick={() => setIsOpenDropdown(!isOpenDropdown)}
>
{_icon && (
<Image src={_icon} width={16} height={16} alt="icon" />
)}
{_icon && <Image src={_icon} width={16} height={16} alt="icon" />}

<p className={styles.dropdown__inner__content__text}>
{currentValue.title}
Expand All @@ -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;
Expand All @@ -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)}
>
Expand All @@ -232,7 +243,7 @@ const Dropdown = ({

<p className={styles.dropdown__list__item__text}>{item.title}</p>
</li>
)
);
})}
</ul>
</div>
Expand Down

0 comments on commit f3b2ea1

Please sign in to comment.