Update execute action list for whitelist merkle tree
This commit is contained in:
parent
41e8a3961a
commit
9654ec845e
@ -1,8 +1,11 @@
|
||||
/* eslint-disable eslint-comments/disable-enable-pair */
|
||||
/* eslint-disable no-nested-ternary */
|
||||
import { Combobox, Transition } from '@headlessui/react'
|
||||
import clsx from 'clsx'
|
||||
import { FormControl } from 'components/FormControl'
|
||||
import type { ExecuteListItem } from 'contracts/whitelist/messages/execute'
|
||||
import { EXECUTE_LIST } from 'contracts/whitelist/messages/execute'
|
||||
import { EXECUTE_LIST as WL_MERKLE_TREE_EXECUTE_LIST } from 'contracts/whitelistMerkleTree/messages/execute'
|
||||
import { matchSorter } from 'match-sorter'
|
||||
import { Fragment, useState } from 'react'
|
||||
import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
||||
@ -10,13 +13,20 @@ import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
||||
export interface ExecuteComboboxProps {
|
||||
value: ExecuteListItem | null
|
||||
onChange: (item: ExecuteListItem) => void
|
||||
whitelistType?: 'standard' | 'flex' | 'merkletree'
|
||||
}
|
||||
|
||||
export const ExecuteCombobox = ({ value, onChange }: ExecuteComboboxProps) => {
|
||||
export const ExecuteCombobox = ({ value, onChange, whitelistType }: ExecuteComboboxProps) => {
|
||||
const [search, setSearch] = useState('')
|
||||
|
||||
const filtered =
|
||||
search === '' ? EXECUTE_LIST : matchSorter(EXECUTE_LIST, search, { keys: ['id', 'name', 'description'] })
|
||||
whitelistType !== 'merkletree'
|
||||
? search === ''
|
||||
? EXECUTE_LIST
|
||||
: matchSorter(EXECUTE_LIST, search, { keys: ['id', 'name', 'description'] })
|
||||
: search === ''
|
||||
? WL_MERKLE_TREE_EXECUTE_LIST
|
||||
: matchSorter(WL_MERKLE_TREE_EXECUTE_LIST, search, { keys: ['id', 'name', 'description'] })
|
||||
|
||||
return (
|
||||
<Combobox
|
||||
|
@ -36,16 +36,16 @@ export const EXECUTE_LIST: ExecuteListItem[] = [
|
||||
name: 'Update Admins',
|
||||
description: `Update the list of administrators for the whitelist`,
|
||||
},
|
||||
{
|
||||
id: 'add_members',
|
||||
name: 'Add Members',
|
||||
description: `Add members to the whitelist`,
|
||||
},
|
||||
{
|
||||
id: 'remove_members',
|
||||
name: 'Remove Members',
|
||||
description: `Remove members from the whitelist`,
|
||||
},
|
||||
// {
|
||||
// id: 'add_members',
|
||||
// name: 'Add Members',
|
||||
// description: `Add members to the whitelist`,
|
||||
// },
|
||||
// {
|
||||
// id: 'remove_members',
|
||||
// name: 'Remove Members',
|
||||
// description: `Remove members from the whitelist`,
|
||||
// },
|
||||
// {
|
||||
// id: 'update_per_address_limit',
|
||||
// name: 'Update Per Address Limit',
|
||||
|
@ -48,7 +48,7 @@ const WhitelistExecutePage: NextPage = () => {
|
||||
const [lastTx, setLastTx] = useState('')
|
||||
const [memberList, setMemberList] = useState<string[]>([])
|
||||
const [flexMemberList, setFlexMemberList] = useState<WhitelistFlexMember[]>([])
|
||||
const [whitelistType, setWhitelistType] = useState<'standard' | 'flex'>('standard')
|
||||
const [whitelistType, setWhitelistType] = useState<'standard' | 'flex' | 'merkletree'>('standard')
|
||||
|
||||
const comboboxState = useExecuteComboboxState()
|
||||
const type = comboboxState.value?.id
|
||||
@ -211,6 +211,8 @@ const WhitelistExecutePage: NextPage = () => {
|
||||
.then((contractType) => {
|
||||
if (contractType?.includes('flex')) {
|
||||
setWhitelistType('flex')
|
||||
} else if (contractType?.includes('merkle')) {
|
||||
setWhitelistType('merkletree')
|
||||
} else {
|
||||
setWhitelistType('standard')
|
||||
}
|
||||
@ -236,7 +238,7 @@ const WhitelistExecutePage: NextPage = () => {
|
||||
<form className="grid grid-cols-2 p-4 space-x-8" onSubmit={mutate}>
|
||||
<div className="space-y-8">
|
||||
<AddressInput {...contractState} />
|
||||
<ExecuteCombobox {...comboboxState} />
|
||||
<ExecuteCombobox whitelistType={whitelistType} {...comboboxState} />
|
||||
<Conditional test={showLimitState}>
|
||||
<NumberInput {...limitState} />
|
||||
</Conditional>
|
||||
|
Loading…
Reference in New Issue
Block a user