Skip to content

Commit c7f6a68

Browse files
committed
Add notifications
1 parent 1e4440f commit c7f6a68

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

front/lib/swr/data_source_view_documents.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export function useCreateDataSourceViewDocument(
118118
disabled: true,
119119
});
120120

121+
const sendNotification = useSendNotification();
122+
121123
const doCreate = async (body: PostDataSourceWithNameDocumentRequestBody) => {
122124
const createUrl = `/api/w/${owner.sId}/spaces/${dataSourceView.spaceId}/data_sources/${dataSourceView.dataSource.sId}/documents`;
123125
const res = await fetch(createUrl, {
@@ -129,11 +131,21 @@ export function useCreateDataSourceViewDocument(
129131
});
130132
if (!res.ok) {
131133
const errorData = await getErrorFromResponse(res);
132-
console.error("Error creating document", errorData);
134+
sendNotification({
135+
type: "error",
136+
title: "Failed to create document",
137+
description: `Error: ${errorData.message}`,
138+
});
133139
return null;
134140
} else {
135141
void mutateContentNodes();
136142

143+
sendNotification({
144+
type: "success",
145+
title: "Document created",
146+
description: "Document has been created",
147+
});
148+
137149
const response: PostDocumentResponseBody = await res.json();
138150
return response.document;
139151
}

0 commit comments

Comments
 (0)