fix(templates): show clear message after auto-import instead of "undefined"
Some checks failed
Deploy to Production / Trigger production update (push) Has been cancelled

Frontend read res.count but the auto-import endpoint returns imported_count,
so the toast showed "Импортировано: undefined". Read imported_count and show
a distinct message when no new templates were imported.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
markmorado
2026-07-23 22:15:02 +05:00
parent 3502a72a13
commit 06b61dae65
4 changed files with 11 additions and 2 deletions

View File

@@ -60,7 +60,7 @@ export function useDiscoverTemplates(serverId: number) {
export function useAutoImportTemplates() {
const qc = useQueryClient();
return useMutation({
mutationFn: (serverId: number) => apiClient.post<{ success: boolean; count: number }>(`/templates/api/auto-import/${serverId}`),
mutationFn: (serverId: number) => apiClient.post<{ success: boolean; imported_count: number }>(`/templates/api/auto-import/${serverId}`),
onSuccess: () => {
qc.invalidateQueries({ queryKey: templateKeys.groups });
qc.invalidateQueries({ queryKey: ['templates'] });