|
8 | 8 | Typography, |
9 | 9 | } from '@strapi/design-system'; |
10 | 10 | import { Data } from '@strapi/strapi'; |
11 | | -import { Layouts, Page, useRBAC } from '@strapi/strapi/admin'; |
12 | | -import { QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query'; |
| 11 | +import { Layouts, Page, useNotification, useRBAC } from '@strapi/strapi/admin'; |
| 12 | +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; |
13 | 13 | import { first, isEmpty } from 'lodash'; |
14 | 14 | import { SyntheticEvent, useCallback, useEffect, useMemo, useState } from 'react'; |
15 | 15 | import { useIntl } from 'react-intl'; |
@@ -79,6 +79,8 @@ const makeAction = <T,>({ cancel, perform, trigger }: MakeActionInput<T>) => { |
79 | 79 | const Inner = () => { |
80 | 80 | const { formatMessage } = useIntl(); |
81 | 81 |
|
| 82 | + const { toggleNotification } = useNotification(); |
| 83 | + |
82 | 84 | const localeQuery = useLocale(); |
83 | 85 |
|
84 | 86 | const [recentNavigation, setRecentNavigation] = useState<{ documentId?: string; id?: Data.ID }>(); |
@@ -268,18 +270,31 @@ const Inner = () => { |
268 | 270 | i18nCopySourceLocale && setI18nCopyModalOpened(true); |
269 | 271 | }, [setI18nCopyModalOpened, i18nCopySourceLocale]); |
270 | 272 |
|
271 | | - const updateNavigationMutation = useUpdateNavigation((next) => { |
272 | | - setCurrentNavigation({ |
273 | | - ...next, |
274 | | - items: next.items.map(appendViewId), |
275 | | - }); |
| 273 | + const updateNavigationMutation = useUpdateNavigation({ |
| 274 | + onError: (error: any) => { |
| 275 | + toggleNotification({ |
| 276 | + type: 'danger', |
| 277 | + message: formatMessage(getTrad('notification.navigation.update.error')), |
| 278 | + }); |
276 | 279 |
|
277 | | - setRecentNavigation({ |
278 | | - documentId: next.documentId, |
279 | | - id: next.id, |
280 | | - }); |
| 280 | + try { |
| 281 | + console.error(error); |
| 282 | + console.log(error.response.data.error); |
| 283 | + } catch (e) {} |
| 284 | + }, |
| 285 | + onSuccess: (next) => { |
| 286 | + setCurrentNavigation({ |
| 287 | + ...next, |
| 288 | + items: next.items.map(appendViewId), |
| 289 | + }); |
| 290 | + |
| 291 | + setRecentNavigation({ |
| 292 | + documentId: next.documentId, |
| 293 | + id: next.id, |
| 294 | + }); |
281 | 295 |
|
282 | | - setStructureChanged(false); |
| 296 | + setStructureChanged(false); |
| 297 | + }, |
283 | 298 | }); |
284 | 299 |
|
285 | 300 | const submit = () => { |
|
0 commit comments