Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"canvas-confetti": "^1.9.2",
"clsx": "^2.0.0",
"dotenv-cli": "^7.3.0",
"export-to-csv": "^1.4.0",
"geist": "^1",
"jose": "^5.2.2",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import { stackAppInternalsSymbol } from "@/app/(main)/integrations/transfer-confirm-page";
import { UserTable } from "@/components/data-table/user-table";
import { ExportUsersDialog } from "@/components/export-users-dialog";
import { StyledLink } from "@/components/link";
import { UserDialog } from "@/components/user-dialog";
import { Alert, Button, Skeleton } from "@stackframe/stack-ui";
import { Suspense } from "react";
import { Download } from "lucide-react";
import { Suspense, useState } from "react";
import { AppEnabledGuard } from "../app-enabled-guard";
import { PageLayout } from "../page-layout";
import { useAdminApp } from "../use-admin-app";
Expand All @@ -31,7 +33,11 @@ function TotalUsersDisplay() {

export default function PageClient() {
const stackAdminApp = useAdminApp();
const firstUser = stackAdminApp.useUsers({ limit: 1 });
const firstUser = (stackAdminApp as any).useUsers({ limit: 1 });
const [exportOptions, setExportOptions] = useState<{
search?: string,
includeAnonymous: boolean,
}>({ includeAnonymous: false });

return (
<AppEnabledGuard appId="authentication">
Expand All @@ -43,18 +49,31 @@ export default function PageClient() {
<TotalUsersDisplay />
</Suspense>
</>}
actions={<UserDialog
type="create"
trigger={<Button>Create User</Button>}
/>}
actions={
<div className="flex gap-2">
<ExportUsersDialog
trigger={
<Button variant="outline">
<Download className="mr-2 h-4 w-4" />
Export
</Button>
}
exportOptions={exportOptions}
/>
<UserDialog
type="create"
trigger={<Button>Create User</Button>}
/>
</div>
}
>
{firstUser.length > 0 ? null : (
<Alert variant='success'>
Congratulations on starting your project! Check the <StyledLink href="https://docs.stack-auth.com">documentation</StyledLink> to add your first users.
</Alert>
)}

<UserTable />
<UserTable onFilterChange={setExportOptions} />
</PageLayout>
</AppEnabledGuard>
);
Expand Down
13 changes: 12 additions & 1 deletion apps/dashboard/src/components/data-table/user-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ const querySchema = yup.object({

const columnHelper = createColumnHelper<ExtendedServerUser>();

export function UserTable() {
export function UserTable(props?: {
onFilterChange?: (filters: { search?: string, includeAnonymous: boolean }) => void,
}) {
const { query, setQuery } = useUserTableQueryState();
const [searchInput, setSearchInput] = useState(query.search ?? "");
const cursorPaginationCache = useCursorPaginationCache();
Expand Down Expand Up @@ -209,6 +211,15 @@ export function UserTable() {
}
}, [query.page, query.cursor, setQuery]);

const onFilterChange = props?.onFilterChange;

useEffect(() => {
onFilterChange?.({
search: query.search,
includeAnonymous: query.includeAnonymous,
});
}, [query.search, query.includeAnonymous, onFilterChange]);

return (
<section className="space-y-2">
<UserTableHeader
Expand Down
Loading
Loading