* Setup, and security settings * Settings -> Details * Settings -> Notifications * Profile * lint * fix: Flash of loading on members screen * align language input * feat: Move share links management to sortable table * Add account menu to sidebar on settings page * Aesthetic tweaks, light borders between settings and slight column offset
76 lines
1.6 KiB
TypeScript
76 lines
1.6 KiB
TypeScript
import * as React from "react";
|
|
import { useHistory, useLocation } from "react-router-dom";
|
|
import scrollIntoView from "smooth-scroll-into-view-if-needed";
|
|
import useQuery from "~/hooks/useQuery";
|
|
import type { Props } from "./Table";
|
|
|
|
const Table = React.lazy(
|
|
() =>
|
|
import(
|
|
/* webpackChunkName: "table" */
|
|
"~/components/Table"
|
|
)
|
|
);
|
|
|
|
const TableFromParams = (
|
|
props: Omit<Props, "onChangeSort" | "onChangePage" | "topRef">
|
|
) => {
|
|
const topRef = React.useRef();
|
|
const location = useLocation();
|
|
const history = useHistory();
|
|
const params = useQuery();
|
|
|
|
const handleChangeSort = React.useCallback(
|
|
(sort, direction) => {
|
|
if (sort) {
|
|
params.set("sort", sort);
|
|
} else {
|
|
params.delete("sort");
|
|
}
|
|
|
|
params.set("direction", direction.toLowerCase());
|
|
|
|
history.replace({
|
|
pathname: location.pathname,
|
|
search: params.toString(),
|
|
});
|
|
},
|
|
[params, history, location.pathname]
|
|
);
|
|
|
|
const handleChangePage = React.useCallback(
|
|
(page) => {
|
|
if (page) {
|
|
params.set("page", page.toString());
|
|
} else {
|
|
params.delete("page");
|
|
}
|
|
|
|
history.replace({
|
|
pathname: location.pathname,
|
|
search: params.toString(),
|
|
});
|
|
|
|
if (topRef.current) {
|
|
scrollIntoView(topRef.current, {
|
|
scrollMode: "if-needed",
|
|
behavior: "auto",
|
|
block: "start",
|
|
});
|
|
}
|
|
},
|
|
[params, history, location.pathname]
|
|
);
|
|
|
|
return (
|
|
<Table
|
|
topRef={topRef}
|
|
onChangeSort={handleChangeSort}
|
|
onChangePage={handleChangePage}
|
|
{...props}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default TableFromParams;
|