Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/components/activity/TenantActivityLogToolbar.tsx
T

38 lines
1.3 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[];
// Path of the CSV export resource route; active filters are carried over.
exportTo: string;
};
export default function TenantActivityLogToolbar({ filters, exportTo }: Props) {
const { t } = useTranslation();
const location = useLocation();
const exportLabel = getFallbackTranslation(t("shared.export"), "Export");
const exportSearchParams = new URLSearchParams(location.search);
exportSearchParams.delete("page");
exportSearchParams.delete("export");
const exportQuery = exportSearchParams.toString();
const exportHref = exportQuery ? `${exportTo}?${exportQuery}` : exportTo;
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;
}