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

@@ -46,7 +46,12 @@ export default function TemplatesPage() {
if (!importServerId) return;
autoImport.mutate(Number(importServerId), {
onSuccess: (res) => {
toast.success(`${t('templates.imported')}: ${res.count}`);
const count = res.imported_count ?? 0;
toast.success(
count > 0
? t('templates.imported_count', { count })
: t('templates.imported_none'),
);
setImportDialogOpen(false);
},
onError: (err: Error) => toast.error(err.message),