From 68bca8c8a125d2d12dd4081e0378db75191207e0 Mon Sep 17 00:00:00 2001 From: lelemm Date: Tue, 12 Nov 2024 16:51:08 -0300 Subject: [PATCH] Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../src/components/reports/reports/Summary.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/desktop-client/src/components/reports/reports/Summary.tsx b/packages/desktop-client/src/components/reports/reports/Summary.tsx index 161d2a2816b..92afc97a303 100644 --- a/packages/desktop-client/src/components/reports/reports/Summary.tsx +++ b/packages/desktop-client/src/components/reports/reports/Summary.tsx @@ -167,7 +167,13 @@ function SummaryInner({ widget }: SummaryInnerProps) { const onSaveWidgetName = async (newName: string) => { if (!widget) { - throw new Error('No widget that could be saved.'); + dispatch( + addNotification({ + type: 'error', + message: t('Cannot save: No widget available.'), + }), + ); + return; } const name = newName || t('Summary'); @@ -189,7 +195,13 @@ function SummaryInner({ widget }: SummaryInnerProps) { async function onSaveWidget() { if (!widget) { - throw new Error('No widget that could be saved.'); + dispatch( + addNotification({ + type: 'error', + message: t('Cannot save: No widget available.'), + }), + ); + return; } await send('dashboard-update-widget', {