PageContentsUtilities.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { useTranslation } from 'next-i18next';
  2. import { useUpdateStateAfterSave } from '~/client/services/page-operation';
  3. import { useDrawioModalLauncherForView } from '~/client/services/side-effects/drawio-modal-launcher-for-view';
  4. import { useHandsontableModalLauncherForView } from '~/client/services/side-effects/handsontable-modal-launcher-for-view';
  5. import { toastSuccess, toastError } from '~/client/util/toastr';
  6. import { useCurrentPageId } from '~/stores/context';
  7. export const PageContentsUtilities = (): null => {
  8. const { t } = useTranslation();
  9. const { data: pageId } = useCurrentPageId();
  10. const updateStateAfterSave = useUpdateStateAfterSave(pageId);
  11. useHandsontableModalLauncherForView({
  12. onSaveSuccess: () => {
  13. toastSuccess(t('toaster.save_succeeded'));
  14. updateStateAfterSave?.();
  15. },
  16. onSaveError: (error) => {
  17. toastError(error);
  18. },
  19. });
  20. useDrawioModalLauncherForView({
  21. onSaveSuccess: () => {
  22. toastSuccess(t('toaster.save_succeeded'));
  23. updateStateAfterSave?.();
  24. },
  25. onSaveError: (error) => {
  26. toastError(error);
  27. },
  28. });
  29. return null;
  30. };