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