mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-12 19:02:53 +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 (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);
|
||||
|
@ -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" });
|
||||
|
@ -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[]>> => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user