import { useState } from 'react' import { CHAINS } from '@synapsecns/synapse-constants' import TextField from '@mui/material/TextField' import { inputStyle, dateInputStyle, comboSelectStyle, comboSelectStyleSmall, inputStyleRounded, } from '@utils/styles/muiStyles' import { validateAndParseAddress } from '@utils/validateAndParseAddress' import { validateAndParseHash } from '@utils/validateAndParseHash' import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider' import { DatePicker } from '@mui/x-date-pickers/DatePicker' import MenuItem from '@mui/material/MenuItem' import { TRANSACTIONS_PATH } from '@urls' const ChainId = CHAINS.ChainId const CHAIN_ENUM_BY_ID = CHAINS.CHAIN_ENUM_BY_ID export const UniversalSearch = ({ setPending, pending, loading, setWallet, wallet, setMinSize, minSize, setMaxSize, maxSize, setStartDate, startDate, setEndDate, endDate, setToTx, setFromTx, setKappa, kappa, executeSearch, chains, setChains, chainsLocale, setChainsLocale, walletLocale, setWalletLocale, }) => { const [searchField] = useState('') const [showText, setShowText] = useState(false) // const [startDate, setStartDate] = useState("s"); const handleChains = (event) => { const { target: { value }, } = event setChains( // On autofill we get a stringified value. typeof value === 'string' ? value.split(',') : value ) } const unSelectStyle = 'transition ease-out border-l-0 border-gray-700 border-opacity-30 text-gray-500 bg-gray-700 bg-opacity-30 hover:bg-opacity-20 hover:text-white' const selectStyle = 'text-white border-[#BE78FF] bg-synapse-radial' const resetFields = () => { setWallet('') setMinSize({ type: 'USD', value: '' }) setMaxSize({ type: 'USD', value: '' }) setStartDate(null) setEndDate(null) setToTx(true) setFromTx(true) setChains([]) setKappa('') } // let isValid // let error // let inputType // let searchLink if (!searchField || searchField === '') { // error = 'Field cannot be empty.' } else if (validateAndParseAddress(searchField)) { // isValid = true // inputType = 'ADDRESS' // searchLink = '/txs?account=' + searchField } else if (validateAndParseHash(searchField)) { // isValid = true // inputType = 'TRANSACTION' // searchLink = '/tx/' + searchField // @ts-ignore } else if (Object.values(ChainId).includes(searchField as ChainId)) { // isValid = true // inputType = 'CHAIN' // searchLink = '/txs?chainId=' + searchField } else { // error = 'Not a valid address or transaction hash' } return ( <>

setShowText(!showText)} > {!showText ? ( ) : ( )} Filters

{ setKappa(e.target.value) }} onKeyDown={(e) => { if (e.key === 'Enter') { window.location.href = TRANSACTIONS_PATH + (kappa ? '?hash=' + kappa : '') } }} id="outlined-basic" label="Search by TXID / TXHash" variant="outlined" sx={inputStyle} className="grow sm:flex-1" />
{/* */}
{/* {!isValid && error ? (
{error}
) : ( "" )} */}
{showText ? (
{/* THIS IS WALLET ADDRESS */}

setShowText(!showText)} > Wallet

{ setWallet(e.target.value) }} id="outlined-basic" label="Wallet Address" variant="outlined" sx={inputStyle} />
setWalletLocale(!walletLocale)} >
setWalletLocale(!walletLocale)} >
{/* { setToTx(!toTx) }} />

To

{ setFromTx(!fromTx) }} />

From

*/}
{/* THIS IS MIN/MAX SIZE */}

setShowText(!showText)} > Chain

handleChains(e), }} > {Object.values(CHAIN_ENUM_BY_ID).map((chain: string) => ( {chain.charAt(0).toUpperCase() + chain.slice(1)} ))}
setChainsLocale(!chainsLocale)} >
setChainsLocale(!chainsLocale)} >
{/* THIS IS MIN/MAX SIZE */}

setShowText(!showText)} > Volume

{ setMinSize({ ...minSize, value: e.target.value }) }} id="outlined-basic" label="Min Size" variant="outlined" sx={inputStyleRounded} />
setMinSize({ ...minSize, type: e.target.value }), }} > USD {/* Amount */}
{ setMaxSize({ ...maxSize, value: e.target.value }) }} value={maxSize.value} id="outlined-basic" label="Max Size" variant="outlined" sx={inputStyleRounded} />
setMaxSize({ ...maxSize, type: e.target.value }), }} > USD {/* Amount */}
{/* THIS IS START/DATE */}

setShowText(!showText)} > Time

{ setStartDate(newValue) }} renderInput={(params) => ( )} />
{ setEndDate(newValue) }} renderInput={(params) => ( )} />
{' '}
{/* THIS IS BUTTONS */}
) : null}
) }