✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
fix: create document
AykutSarac028824cb3ea6
diff --git a/src/containers/Editor/BottomBar.tsx b/src/containers/Editor/BottomBar.tsxindex 1666a02c..ac3cb7d9 100644--- a/src/containers/Editor/BottomBar.tsx+++ b/src/containers/Editor/BottomBar.tsx@@ -125,7 +125,7 @@ export const BottomBar = () => {});if (error) throw error;- if (data[0].id) replace({ query: { json: data[0].id } });+ if (data) replace({ query: { json: data } });toast.success("Document saved to cloud", { id: "fileSave" });setHasChanges(false);diff --git a/src/containers/Modals/CloudModal/index.tsx b/src/containers/Modals/CloudModal/index.tsxindex e00eb0ac..953cbabc 100644--- a/src/containers/Modals/CloudModal/index.tsx+++ b/src/containers/Modals/CloudModal/index.tsx@@ -101,7 +101,7 @@ export const CloudModal: React.FC<ModalProps> = ({ opened, onClose }) => {toast.success("Document saved to cloud", { id: "fileSave" });setHasChanges(false);- replace({ query: { json: data[0].id } });+ replace({ query: { json: data } });onClose();} catch (error: any) {toast.error("Failed to save document!", { id: "fileSave" });diff --git a/src/services/json.ts b/src/services/json.tsindex 4970189c..f8c9a4ab 100644--- a/src/services/json.ts+++ b/src/services/json.ts@@ -12,11 +12,15 @@ type CloudSave = {};const saveToCloud = async ({- id,- contents,- format = FileFormat.JSON,-}: CloudSave): Promise<PostgrestSingleResponse<{ id: string }[]>> => {- return await supabase.from("document").upsert({ id, content: contents, format }).select("id");+ id: p_id = "",+ contents: p_content,+ format: p_format = FileFormat.JSON,+}: CloudSave): Promise<PostgrestSingleResponse<string>> => {+ return await supabase.rpc("upsert_document", {+ p_content,+ p_format,+ p_id,+ });};const getFromCloud = async (doc_id: string): Promise<PostgrestSingleResponse<File[]>> => {