import React, { useState, useCallback, useContext } from 'react' import PropTypes from 'prop-types' import { I18nContext } from '../../../contexts/i18n' import Popover from '../../../components/ui/popover' import Button from '../../../components/ui/button' import QuoteDetails from './quote-details' import SortList from './sort-list' import { QUOTE_DATA_ROWS_PROPTYPES_SHAPE } from './select-quote-popover-constants' const SelectQuotePopover = ({ quoteDataRows = [], onClose = null, onSubmit = null, swapToSymbol, initialAggId, onQuoteDetailsIsOpened, }) => { const t = useContext(I18nContext) const [sortDirection, setSortDirection] = useState(1) const [sortColumn, setSortColumn] = useState(null) const [selectedAggId, setSelectedAggId] = useState(initialAggId) const [contentView, setContentView] = useState('sortList') const [viewingAgg, setViewingAgg] = useState(null) const onSubmitClick = useCallback(() => { onSubmit(selectedAggId) onClose() }, [selectedAggId, onClose, onSubmit]) const closeQuoteDetails = useCallback(() => { setViewingAgg(null) setContentView('sortList') }, []) const onRowClick = useCallback((aggId) => setSelectedAggId(aggId), [ setSelectedAggId, ]) const onCaretClick = useCallback( (aggId) => { const agg = quoteDataRows.find((quote) => quote.aggId === aggId) setContentView('quoteDetails') onQuoteDetailsIsOpened() setViewingAgg(agg) }, [quoteDataRows, onQuoteDetailsIsOpened], ) const CustomBackground = useCallback( () => (
), [onClose], ) const footer = ( <> > ) return (