// @flow import * as ICONS from 'constants/icons'; import React, { useState } from 'react'; import Button from 'component/button'; import ClaimList from 'component/claimList'; import Paginate from 'component/common/paginate'; import { PAGE_SIZE } from 'constants/claim'; import { Form } from 'component/common/form-components/form'; import Icon from 'component/common/icon'; import { FormField } from 'component/common/form-components/form-field'; import { withRouter } from 'react-router'; import Card from 'component/common/card'; import classnames from 'classnames'; import Yrbl from 'component/yrbl'; import { PURCHASES_PAGE_SIZE } from 'page/library/view'; import Spinner from 'component/spinner'; type Props = { fetchingFileList: boolean, downloadedUrls: Array, downloadedUrlsCount: ?number, history: { replace: string => void }, query: string, doPurchaseList: () => void, myDownloads: Array, myPurchases: Array, myPurchasesCount: ?number, fetchingMyPurchases: boolean, }; const VIEW_DOWNLOADS = 'view_download'; const VIEW_PURCHASES = 'view_purchases'; function FileListDownloaded(props: Props) { const { history, query, downloadedUrlsCount, myPurchasesCount, myPurchases, myDownloads, fetchingFileList, fetchingMyPurchases, } = props; const loading = fetchingFileList || fetchingMyPurchases; const [viewMode, setViewMode] = React.useState(VIEW_PURCHASES); const [searchQuery, setSearchQuery] = useState(''); function handleInputChange(e) { const { value } = e.target; if (value !== searchQuery) { setSearchQuery(value); history.replace(`?query=${value}&page=1`); } } return (