diff --git a/rsconcept/frontend/src/components/DataTable/index.tsx b/rsconcept/frontend/src/components/DataTable/index.tsx index 0c323b02..2daad356 100644 --- a/rsconcept/frontend/src/components/DataTable/index.tsx +++ b/rsconcept/frontend/src/components/DataTable/index.tsx @@ -190,7 +190,7 @@ export default function DataTable({ } - {enablePagination && + {!isEmpty && enablePagination && > + query: string + setQuery: React.Dispatch> + strategy: LibraryFilterStrategy + setStrategy: React.Dispatch> } -function SearchPanel({ total, filtered, setFilter }: SearchPanelProps) { +function SearchPanel({ total, filtered, query, setQuery, strategy, setStrategy, setFilter }: SearchPanelProps) { const { navigateTo } = useConceptNavigation(); const search = useLocation().search; const { user } = useAuth(); - const [query, setQuery] = useState(''); - const [strategy, setStrategy] = useLocalStorage('search_strategy', LibraryFilterStrategy.MANUAL); - function handleChangeQuery(event: React.ChangeEvent) { const newQuery = event.target.value; setQuery(newQuery); @@ -76,7 +76,7 @@ function SearchPanel({ total, filtered, setFilter }: SearchPanelProps) { {filtered} из {total} -
+
void + resetQuery: () => void } const columnHelper = createColumnHelper(); -function ViewLibrary({ items, cleanQuery }: ViewLibraryProps) { +function ViewLibrary({ items, resetQuery: cleanQuery }: ViewLibraryProps) { const { navigateTo } = useConceptNavigation(); const intl = useIntl(); const { user } = useAuth(); @@ -42,7 +42,7 @@ function ViewLibrary({ items, cleanQuery }: ViewLibraryProps) { const item = props.row.original; return (<>
{user && user.subscriptions.includes(item.id) &&

} @@ -83,10 +83,10 @@ function ViewLibrary({ items, cleanQuery }: ViewLibraryProps) { columnHelper.accessor('time_update', { id: 'time_update', header: 'Обновлена', - size: 220, - minSize: 220, - maxSize: 220, - cell: props => new Date(props.cell.getValue()).toLocaleString(intl.locale), + size: 150, + minSize: 150, + maxSize: 150, + cell: props =>
{new Date(props.cell.getValue()).toLocaleString(intl.locale)}
, enableSorting: true, sortingFn: 'datetime', sortDescFirst: true @@ -95,6 +95,7 @@ function ViewLibrary({ items, cleanQuery }: ViewLibraryProps) { return (
+ {items.length > 0 &&
@@ -106,38 +107,35 @@ function ViewLibrary({ items, cleanQuery }: ViewLibraryProps) {
-
- -

Список схем пуст

-

- - | - - | - - Очистить фильтр - -

} - - onRowClicked={openRSForm} + +

Список схем пуст

+

+ + + Очистить фильтр + +

+
} + + onRowClicked={openRSForm} - enablePagination - paginationPerPage={itemsPerPage} - onChangePaginationOption={setItemsPerPage} - paginationOptions={[10, 20, 30, 50, 100]} - /> + enableSorting + initialSorting={{ + id: 'time_update', + desc: true + }} + + enablePagination + paginationPerPage={itemsPerPage} + onChangePaginationOption={setItemsPerPage} + paginationOptions={[10, 20, 30, 50, 100]} + />
); } diff --git a/rsconcept/frontend/src/pages/LibraryPage/index.tsx b/rsconcept/frontend/src/pages/LibraryPage/index.tsx index 83ea9eb1..2c4a2633 100644 --- a/rsconcept/frontend/src/pages/LibraryPage/index.tsx +++ b/rsconcept/frontend/src/pages/LibraryPage/index.tsx @@ -1,11 +1,12 @@ -import { useLayoutEffect, useState } from 'react'; +import { useCallback, useLayoutEffect, useState } from 'react'; import BackendError from '../../components/BackendError' import { ConceptLoader } from '../../components/Common/ConceptLoader' import { useLibrary } from '../../context/LibraryContext'; import { useConceptTheme } from '../../context/ThemeContext'; +import useLocalStorage from '../../hooks/useLocalStorage'; import { ILibraryItem } from '../../models/library'; -import { ILibraryFilter } from '../../models/miscelanious'; +import { ILibraryFilter, LibraryFilterStrategy } from '../../models/miscelanious'; import SearchPanel from './SearchPanel'; import ViewLibrary from './ViewLibrary'; @@ -16,6 +17,9 @@ function LibraryPage() { const [ filter, setFilter ] = useState({}); const [ items, setItems ] = useState([]); + const [query, setQuery] = useState(''); + const [strategy, setStrategy] = useLocalStorage('search_strategy', LibraryFilterStrategy.MANUAL); + useLayoutEffect( () => { setShowScroll(true); @@ -27,6 +31,13 @@ function LibraryPage() { setItems(library.filter(filter)); }, [library, filter, filter.query]); + const resetQuery = useCallback( + () => { + setQuery(''); + setStrategy(LibraryFilterStrategy.MANUAL); + setFilter({}); + }, [setStrategy]) + return (
{ library.loading && } @@ -34,12 +45,16 @@ function LibraryPage() { { !library.loading && library.items &&
setFilter({})} + resetQuery={resetQuery} items={items} />
diff --git a/rsconcept/frontend/src/pages/UserProfilePage/UserTabs.tsx b/rsconcept/frontend/src/pages/UserProfilePage/UserTabs.tsx index b6859c12..fa7272dd 100644 --- a/rsconcept/frontend/src/pages/UserProfilePage/UserTabs.tsx +++ b/rsconcept/frontend/src/pages/UserProfilePage/UserTabs.tsx @@ -49,7 +49,7 @@ function UserTabs() {
{subscriptions.length > 0 && showSubs && -
+

Отслеживаемые схемы

} diff --git a/rsconcept/frontend/src/pages/UserProfilePage/ViewSubscriptions.tsx b/rsconcept/frontend/src/pages/UserProfilePage/ViewSubscriptions.tsx index d58f5df4..a346b7d3 100644 --- a/rsconcept/frontend/src/pages/UserProfilePage/ViewSubscriptions.tsx +++ b/rsconcept/frontend/src/pages/UserProfilePage/ViewSubscriptions.tsx @@ -38,10 +38,10 @@ function ViewSubscriptions({items}: ViewSubscriptionsProps) { columnHelper.accessor('time_update', { id: 'time_update', header: 'Обновлена', - minSize: 200, - size: 200, - maxSize: 200, - cell: props => new Date(props.cell.getValue()).toLocaleString(intl.locale), + minSize: 150, + size: 150, + maxSize: 150, + cell: props =>
{new Date(props.cell.getValue()).toLocaleString(intl.locale)}
, enableSorting: true }) ], [intl]);