fix(groups): page client dialogs and submit server-resolved scopes

Keep group client tables and bulk requests bounded with paged queries, frozen selections, and a streamed subscription export. Reuse existing bulk mutations and preserve the explicit-email contracts.
This commit is contained in:
Hamed Sanaei
2026-12-01 11:36:45 +03:30
parent 267379456a
commit 1ac11c7783
46 changed files with 3204 additions and 791 deletions
+48
View File
@@ -0,0 +1,48 @@
import { useQuery } from '@tanstack/react-query';
import { withBasePath } from '@/api/http-init';
import { keys } from '@/api/queryKeys';
import { GroupClientPageSchema, type GroupClientSelection } from '@/generated/zod';
import { HttpUtil } from '@/utils';
import { parseMsg } from '@/utils/zodValidate';
const PAGE_ENDPOINT = '/panel/api/clients/groups/clientPage';
export const GROUP_CLIENT_PAGE_SIZE = 100;
export const MAX_GROUP_EXCLUSIONS = 1000;
export type { GroupClientSelection };
export type GroupClientMode = 'add' | 'remove' | 'links';
export type GroupBulkScope = { group: string; scopeToken?: string };
type PageParams = {
group: string;
mode: GroupClientMode;
page?: number;
search?: string;
freeze?: boolean;
scopeSearch?: string;
maxId?: number;
};
export async function fetchGroupClients(params: PageParams, signal?: AbortSignal) {
const response = await HttpUtil.get(PAGE_ENDPOINT, params, { signal, silent: true });
const result = parseMsg(response, GroupClientPageSchema, 'clients/groups/clientPage');
if (!result.success || !result.obj) throw new Error(result.msg);
return result.obj;
}
export function useGroupClientPage(params: PageParams, enabled: boolean) {
return useQuery({
queryKey: [...keys.clients.root(), 'groupClientPage', params],
queryFn: ({ signal }) => fetchGroupClients(params, signal),
enabled,
gcTime: 0,
retry: false,
});
}
export function groupSubscriptionExportPath(group: string) {
return withBasePath(
'/panel/api/clients/groups/subLinks/export?' + new URLSearchParams({ group }).toString(),
);
}