35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { Link, useLocation } from "react-router";
|
|
import { useTranslation } from "react-i18next";
|
|
import { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
|
|
import InputFilters from "~/components/ui/input/InputFilters";
|
|
import { Button } from "~/components/ui/button";
|
|
|
|
type Props = {
|
|
filters: FilterablePropertyDto[];
|
|
};
|
|
|
|
export default function TenantActivityLogToolbar({ filters }: Props) {
|
|
const { t } = useTranslation();
|
|
const location = useLocation();
|
|
const exportLabel = getFallbackTranslation(t("shared.export"), "Export");
|
|
const exportSearchParams = new URLSearchParams(location.search);
|
|
exportSearchParams.delete("page");
|
|
exportSearchParams.set("export", "csv");
|
|
const exportHref = `${location.pathname}?${exportSearchParams.toString()}`;
|
|
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<Button asChild variant="outline">
|
|
<Link to={exportHref} reloadDocument>
|
|
{exportLabel}
|
|
</Link>
|
|
</Button>
|
|
<InputFilters filters={filters} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function getFallbackTranslation(value: string, fallback: string) {
|
|
return value === "shared.export" ? fallback : value;
|
|
}
|