mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-27 15:22:56 +08:00
fix: create document
This commit is contained in:
parent
1c153e5249
commit
028824cb3e
@ -125,7 +125,7 @@ export const BottomBar = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (error) throw error;
|
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" });
|
toast.success("Document saved to cloud", { id: "fileSave" });
|
||||||
setHasChanges(false);
|
setHasChanges(false);
|
||||||
|
@ -101,7 +101,7 @@ export const CloudModal: React.FC<ModalProps> = ({ opened, onClose }) => {
|
|||||||
|
|
||||||
toast.success("Document saved to cloud", { id: "fileSave" });
|
toast.success("Document saved to cloud", { id: "fileSave" });
|
||||||
setHasChanges(false);
|
setHasChanges(false);
|
||||||
replace({ query: { json: data[0].id } });
|
replace({ query: { json: data } });
|
||||||
onClose();
|
onClose();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast.error("Failed to save document!", { id: "fileSave" });
|
toast.error("Failed to save document!", { id: "fileSave" });
|
||||||
|
@ -12,11 +12,15 @@ type CloudSave = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveToCloud = async ({
|
const saveToCloud = async ({
|
||||||
id,
|
id: p_id = "",
|
||||||
contents,
|
contents: p_content,
|
||||||
format = FileFormat.JSON,
|
format: p_format = FileFormat.JSON,
|
||||||
}: CloudSave): Promise<PostgrestSingleResponse<{ id: string }[]>> => {
|
}: CloudSave): Promise<PostgrestSingleResponse<string>> => {
|
||||||
return await supabase.from("document").upsert({ id, content: contents, format }).select("id");
|
return await supabase.rpc("upsert_document", {
|
||||||
|
p_content,
|
||||||
|
p_format,
|
||||||
|
p_id,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFromCloud = async (doc_id: string): Promise<PostgrestSingleResponse<File[]>> => {
|
const getFromCloud = async (doc_id: string): Promise<PostgrestSingleResponse<File[]>> => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user