perf: Server Fetching for platform members and org members pages (#21342)
* remove members page * refactor to server fetch * same for /members * use server fetches for all queires * fix * add skeletons * refactor * fix loading page * fix * fix type checks * fix details * refactor platform members page
This commit is contained in:
1 parent
6258ca14d0
commit
bb98143e2e
14 files changed
+231
-130
No files matched your search
@@ -31,6 +31,7 @@ import {
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Avatar } from "@calcom/ui/components/avatar";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
@@ -105,15 +106,22 @@ function reducer(state: UserTableState, action: UserTableAction): UserTableState
|
||||
}
|
||||
}
|
||||
|
||||
export function UserListTable() {
|
||||
export type UserListTableProps = {
|
||||
org: RouterOutputs["viewer"]["organizations"]["listCurrent"];
|
||||
teams: RouterOutputs["viewer"]["organizations"]["getTeams"];
|
||||
facetedTeamValues: RouterOutputs["viewer"]["organizations"]["getFacetedValues"];
|
||||
attributes: RouterOutputs["viewer"]["attributes"]["list"];
|
||||
};
|
||||
|
||||
export function UserListTable(props: UserListTableProps) {
|
||||
return (
|
||||
<DataTableProvider useSegments={useSegments} defaultPageSize={25}>
|
||||
<UserListTableContent />
|
||||
<UserListTableContent {...props} />
|
||||
</DataTableProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function UserListTableContent() {
|
||||
function UserListTableContent({ org, attributes, teams, facetedTeamValues }: UserListTableProps) {
|
||||
const [dynamicLinkVisible, setDynamicLinkVisible] = useQueryState("dynamicLink", parseAsBoolean);
|
||||
const orgBranding = useOrgBranding();
|
||||
const domain = orgBranding?.fullDomain ?? WEBAPP_URL;
|
||||
@@ -121,22 +129,6 @@ function UserListTableContent() {
|
||||
|
||||
const { data: session } = useSession();
|
||||
const { isPlatformUser } = useGetUserAttributes();
|
||||
const { data: org } = trpc.viewer.organizations.listCurrent.useQuery(undefined, {
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
const { data: attributes, isSuccess: isSuccessAttributes } = trpc.viewer.attributes.list.useQuery(
|
||||
undefined,
|
||||
{
|
||||
refetchOnWindowFocus: false,
|
||||
}
|
||||
);
|
||||
const { data: teams } = trpc.viewer.organizations.getTeams.useQuery(undefined, {
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
const { data: facetedTeamValues } = trpc.viewer.organizations.getFacetedValues.useQuery(undefined, {
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
const [rowSelection, setRowSelection] = useState({});
|
||||
@@ -561,11 +553,6 @@ function UserListTableContent() {
|
||||
}
|
||||
};
|
||||
|
||||
if (!isPlatformUser && !isSuccessAttributes) {
|
||||
// do not render the table until the attributes are fetched
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<DataTableWrapper<UserTableUser>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"use client";
|
||||
|
||||
import { DataTableSkeleton } from "@calcom/features/data-table";
|
||||
import { CTA_CONTAINER_CLASS_NAME } from "@calcom/features/data-table/lib/utils";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
export function UserListTableSkeleton() {
|
||||
return (
|
||||
<SkeletonContainer>
|
||||
{/* Toolbar with search, filters, etc. */}
|
||||
<div className="grid w-full items-center gap-2 pb-4">
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
<div className="flex w-full flex-wrap justify-between gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{/* Search bar */}
|
||||
<div className="border-default bg-default flex h-9 w-52 items-center gap-1 rounded-md border px-3 py-2">
|
||||
<div className="flex items-center justify-center">
|
||||
<SkeletonText className="h-4 w-4" />
|
||||
</div>
|
||||
<SkeletonText className="h-4 w-40" />
|
||||
</div>
|
||||
|
||||
{/* Filters */}
|
||||
<SkeletonButton className="h-9 w-28" />
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<SkeletonButton className="h-9 w-20" />
|
||||
<SkeletonButton className="h-9 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<SkeletonButton className="h-9 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* DataTable */}
|
||||
<DataTableSkeleton columns={7} rows={10} columnWidths={[30, 200, 100, 140, 120, 120, 80]} />
|
||||
|
||||
{/* CTA actions at the bottom */}
|
||||
<div className={`mt-4 flex items-center gap-2 ${CTA_CONTAINER_CLASS_NAME}`}>
|
||||
<SkeletonButton className="h-9 w-32" />
|
||||
<SkeletonButton className="h-9 w-24" />
|
||||
</div>
|
||||
</SkeletonContainer>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user