mirror of
https://github.com/docmost/docmost.git
synced 2026-07-25 16:54:43 +10:00
- default status
- type fix - error helper
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { queryClient } from "@/main";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getApiErrorMessage } from "@/lib/api-error";
|
||||
import { IPagination } from "@/lib/types";
|
||||
|
||||
export function useCreatePropertyMutation() {
|
||||
@@ -36,9 +37,9 @@ export function useCreatePropertyMutation() {
|
||||
},
|
||||
);
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to create property"),
|
||||
message: getApiErrorMessage(error, t("Failed to create property")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -69,9 +70,9 @@ export function useUpdatePropertyMutation() {
|
||||
});
|
||||
}
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to update property"),
|
||||
message: getApiErrorMessage(error, t("Failed to update property")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -114,9 +115,9 @@ export function useDeletePropertyMutation() {
|
||||
},
|
||||
);
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to delete property"),
|
||||
message: getApiErrorMessage(error, t("Failed to delete property")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -154,7 +155,7 @@ export function useReorderPropertyMutation() {
|
||||
|
||||
return { previous };
|
||||
},
|
||||
onError: (_, variables, context) => {
|
||||
onError: (error, variables, context) => {
|
||||
if (context?.previous) {
|
||||
queryClient.setQueryData(
|
||||
["bases", variables.pageId],
|
||||
@@ -162,7 +163,7 @@ export function useReorderPropertyMutation() {
|
||||
);
|
||||
}
|
||||
notifications.show({
|
||||
message: t("Failed to reorder property"),
|
||||
message: getApiErrorMessage(error, t("Failed to reorder property")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { queryClient } from "@/main";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getApiErrorMessage } from "@/lib/api-error";
|
||||
import { useAtom } from "jotai";
|
||||
import { treeDataAtom } from "@/features/page/tree/atoms/tree-data-atom";
|
||||
import { treeModel } from "@/features/page/tree/model/tree-model";
|
||||
@@ -44,9 +45,9 @@ export function useCreateBaseMutation() {
|
||||
queryKey: ["bases", "list", data.spaceId],
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to create base"),
|
||||
message: getApiErrorMessage(error, t("Failed to create base")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -77,9 +78,9 @@ export function useConvertPageToBaseMutation() {
|
||||
payload: { isBase: true },
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to create base"),
|
||||
message: getApiErrorMessage(error, t("Failed to create base")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -96,9 +97,9 @@ export function useUpdateBaseMutation() {
|
||||
return { ...old, ...data };
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to update base"),
|
||||
message: getApiErrorMessage(error, t("Failed to update base")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -116,9 +117,9 @@ export function useDeleteBaseMutation() {
|
||||
});
|
||||
notifications.show({ message: t("Base deleted") });
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to delete base"),
|
||||
message: getApiErrorMessage(error, t("Failed to delete base")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { queryClient } from "@/main";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getApiErrorMessage } from "@/lib/api-error";
|
||||
import { useHydrateReferences } from "@/ee/base/reference/reference-store";
|
||||
import { markRequestIdOutbound } from "@/ee/base/hooks/use-base-socket";
|
||||
import { v7 as uuid7 } from "uuid";
|
||||
@@ -149,9 +150,9 @@ export function useCreateRowMutation() {
|
||||
invalidateBaseRows(newRow.pageId);
|
||||
}
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to create row"),
|
||||
message: getApiErrorMessage(error, t("Failed to create row")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -221,7 +222,7 @@ export function useUpdateRowMutation() {
|
||||
|
||||
return { snapshots };
|
||||
},
|
||||
onError: (_, variables, context) => {
|
||||
onError: (error, variables, context) => {
|
||||
if (context?.snapshots) {
|
||||
for (const [key, data] of context.snapshots) {
|
||||
queryClient.setQueryData(key, data);
|
||||
@@ -231,7 +232,7 @@ export function useUpdateRowMutation() {
|
||||
queryKey: ["base-row", variables.pageId, variables.rowId],
|
||||
});
|
||||
notifications.show({
|
||||
message: t("Failed to update row"),
|
||||
message: getApiErrorMessage(error, t("Failed to update row")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -305,14 +306,14 @@ export function useDeleteRowMutation() {
|
||||
|
||||
return { snapshots };
|
||||
},
|
||||
onError: (_, variables, context) => {
|
||||
onError: (error, variables, context) => {
|
||||
if (context?.snapshots) {
|
||||
for (const [key, data] of context.snapshots) {
|
||||
queryClient.setQueryData(key, data);
|
||||
}
|
||||
}
|
||||
notifications.show({
|
||||
message: t("Failed to delete row"),
|
||||
message: getApiErrorMessage(error, t("Failed to delete row")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -349,14 +350,14 @@ export function useDeleteRowsMutation() {
|
||||
|
||||
return { snapshots };
|
||||
},
|
||||
onError: (_, __, context) => {
|
||||
onError: (error, __, context) => {
|
||||
if (context?.snapshots) {
|
||||
for (const [key, data] of context.snapshots) {
|
||||
queryClient.setQueryData(key, data);
|
||||
}
|
||||
}
|
||||
notifications.show({
|
||||
message: t("Failed to delete rows"),
|
||||
message: getApiErrorMessage(error, t("Failed to delete rows")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -399,14 +400,14 @@ export function useReorderRowMutation() {
|
||||
|
||||
return { snapshots };
|
||||
},
|
||||
onError: (_, variables, context) => {
|
||||
onError: (error, variables, context) => {
|
||||
if (context?.snapshots) {
|
||||
for (const [key, data] of context.snapshots) {
|
||||
queryClient.setQueryData(key, data);
|
||||
}
|
||||
}
|
||||
notifications.show({
|
||||
message: t("Failed to reorder row"),
|
||||
message: getApiErrorMessage(error, t("Failed to reorder row")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -504,14 +505,14 @@ export function useKanbanMoveCardMutation() {
|
||||
|
||||
return { snapshots };
|
||||
},
|
||||
onError: (_, __, context) => {
|
||||
onError: (error, __, context) => {
|
||||
if (context?.snapshots) {
|
||||
for (const [key, data] of context.snapshots) {
|
||||
queryClient.setQueryData(key, data);
|
||||
}
|
||||
}
|
||||
notifications.show({
|
||||
message: t("Failed to move card"),
|
||||
message: getApiErrorMessage(error, t("Failed to move card")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -552,9 +553,9 @@ export function useKanbanCreateCardMutation() {
|
||||
};
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to add card"),
|
||||
message: getApiErrorMessage(error, t("Failed to add card")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
|
||||
@@ -28,6 +28,7 @@ function applyConfigPatch(
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { queryClient } from "@/main";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getApiErrorMessage } from "@/lib/api-error";
|
||||
|
||||
export function useCreateViewMutation() {
|
||||
const { t } = useTranslation();
|
||||
@@ -45,9 +46,9 @@ export function useCreateViewMutation() {
|
||||
},
|
||||
);
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to create view"),
|
||||
message: getApiErrorMessage(error, t("Failed to create view")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -99,7 +100,7 @@ export function useUpdateViewMutation() {
|
||||
|
||||
return { previous };
|
||||
},
|
||||
onError: (_, variables, context) => {
|
||||
onError: (error, variables, context) => {
|
||||
if (context?.previous) {
|
||||
queryClient.setQueryData(
|
||||
["bases", variables.pageId],
|
||||
@@ -107,7 +108,7 @@ export function useUpdateViewMutation() {
|
||||
);
|
||||
}
|
||||
notifications.show({
|
||||
message: t("Failed to update view"),
|
||||
message: getApiErrorMessage(error, t("Failed to update view")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -144,9 +145,9 @@ export function useDeleteViewMutation() {
|
||||
},
|
||||
);
|
||||
},
|
||||
onError: () => {
|
||||
onError: (error) => {
|
||||
notifications.show({
|
||||
message: t("Failed to delete view"),
|
||||
message: getApiErrorMessage(error, t("Failed to delete view")),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user