mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
fix: document fetch
This commit is contained in:
parent
9b7fc7255f
commit
f9bfcf7fb4
@ -217,13 +217,13 @@ export const BottomBar = () => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
</StyledBottomBarItem>
|
</StyledBottomBarItem>
|
||||||
{(data?.owner_id === user?.id || (!data && user)) && (
|
{(data?.owner_email === user?.email || (!data && user)) && (
|
||||||
<StyledBottomBarItem onClick={handleSaveJson} disabled={isUpdating}>
|
<StyledBottomBarItem onClick={handleSaveJson} disabled={isUpdating}>
|
||||||
{hasChanges ? <AiOutlineCloudUpload /> : <AiOutlineCloudSync />}
|
{hasChanges ? <AiOutlineCloudUpload /> : <AiOutlineCloudSync />}
|
||||||
{hasChanges ? (query?.json ? "Unsaved Changes" : "Create Document") : "Saved"}
|
{hasChanges ? (query?.json ? "Unsaved Changes" : "Create Document") : "Saved"}
|
||||||
</StyledBottomBarItem>
|
</StyledBottomBarItem>
|
||||||
)}
|
)}
|
||||||
{data?.owner_id === user?.id && (
|
{data?.owner_email === user?.email && (
|
||||||
<StyledBottomBarItem onClick={setPrivate} disabled={isUpdating}>
|
<StyledBottomBarItem onClick={setPrivate} disabled={isUpdating}>
|
||||||
{isPrivate ? <AiOutlineLock /> : <AiOutlineUnlock />}
|
{isPrivate ? <AiOutlineLock /> : <AiOutlineUnlock />}
|
||||||
{isPrivate ? "Private" : "Public"}
|
{isPrivate ? "Private" : "Public"}
|
||||||
|
@ -24,13 +24,13 @@ const getFromCloud = async (doc_id: string): Promise<PostgrestSingleResponse<Fil
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getAllJson = async (): Promise<File[]> => {
|
const getAllJson = async (): Promise<File[]> => {
|
||||||
const userId = useUser.getState().user?.id;
|
const userEmail = useUser.getState().user?.email;
|
||||||
if (!userId) return [];
|
if (!userEmail) return [];
|
||||||
|
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("document")
|
.from("document")
|
||||||
.select()
|
.select()
|
||||||
.eq("owner_id", userId)
|
.eq("owner_email", userEmail)
|
||||||
.order("created_at", { ascending: false });
|
.order("created_at", { ascending: false });
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -42,7 +42,7 @@ interface JsonActions {
|
|||||||
export type File = {
|
export type File = {
|
||||||
id: string;
|
id: string;
|
||||||
views: number;
|
views: number;
|
||||||
owner_id: string;
|
owner_email: string;
|
||||||
name: string;
|
name: string;
|
||||||
content: string;
|
content: string;
|
||||||
private: boolean;
|
private: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user