Skip to content

Commit

Permalink
#477 csv export file name
Browse files Browse the repository at this point in the history
  • Loading branch information
dendidibe committed Jul 27, 2023
1 parent c70fdc9 commit 0bd273b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client-web/src/components/UsersTable/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { EditAcl } from "../EditAcl";
import NoDataImage from "../NoDataImage";
import { UsersTableRow } from "./UsersTableRow";
import { useSnackbar } from "../../context/SnackbarContext";
import { format } from "date-fns";

type Order = "asc" | "desc";

Expand All @@ -40,7 +41,7 @@ export type ModalType =

interface Props {
currentApp: string;
onAppChange: (app:string) => void
onAppChange: (app: string) => void;
}

export type TSelectedIds = {
Expand All @@ -49,7 +50,7 @@ export type TSelectedIds = {
appId: string;
tags: string[];
};
export default function UsersTable({currentApp, onAppChange}: Props) {
export default function UsersTable({ currentApp, onAppChange }: Props) {
const [order, setOrder] = useState<Order>("desc");
const [orderBy, setOrderBy] = useState<keyof IUser>("createdAt");
const [selectedIds, setSelectedIds] = useState<TSelectedIds[]>([]);
Expand All @@ -60,8 +61,6 @@ export default function UsersTable({currentApp, onAppChange}: Props) {
}>({ open: false, type: "manageTags" });
const apps = useStoreState((state) => state.apps);



const [showNewUser, setShowNewUser] = useState(false);
const [rowsPerPage, setRowsPerPage] = useState(10);
const [users, setUsers] = useState<IUser[]>([]);
Expand Down Expand Up @@ -254,8 +253,9 @@ export default function UsersTable({currentApp, onAppChange}: Props) {
const res = await exportUsersCsv(currentApp);
const url = `data:text/csv;charset=UTF-8,${encodeURIComponent(res.data)}`;
const a = document.createElement("a");
const fileName = 'users-' + format(new Date(), "yyyy-MM-dd") + ".csv";
a.href = url;
a.download = currentApp + ".csv";
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Expand Down

0 comments on commit 0bd273b

Please sign in to comment.