fix: document fetch

This commit is contained in:
AykutSarac 2023-08-02 19:30:01 +03:00
parent 9b7fc7255f
commit f9bfcf7fb4
No known key found for this signature in database
3 changed files with 6 additions and 6 deletions

View File

@ -217,13 +217,13 @@ export const BottomBar = () => {
</Flex>
)}
</StyledBottomBarItem>
{(data?.owner_id === user?.id || (!data && user)) && (
{(data?.owner_email === user?.email || (!data && user)) && (
<StyledBottomBarItem onClick={handleSaveJson} disabled={isUpdating}>
{hasChanges ? <AiOutlineCloudUpload /> : <AiOutlineCloudSync />}
{hasChanges ? (query?.json ? "Unsaved Changes" : "Create Document") : "Saved"}
</StyledBottomBarItem>
)}
{data?.owner_id === user?.id && (
{data?.owner_email === user?.email && (
<StyledBottomBarItem onClick={setPrivate} disabled={isUpdating}>
{isPrivate ? <AiOutlineLock /> : <AiOutlineUnlock />}
{isPrivate ? "Private" : "Public"}

View File

@ -24,13 +24,13 @@ const getFromCloud = async (doc_id: string): Promise<PostgrestSingleResponse<Fil
};
const getAllJson = async (): Promise<File[]> => {
const userId = useUser.getState().user?.id;
if (!userId) return [];
const userEmail = useUser.getState().user?.email;
if (!userEmail) return [];
const { data, error } = await supabase
.from("document")
.select()
.eq("owner_id", userId)
.eq("owner_email", userEmail)
.order("created_at", { ascending: false });
if (error) {

View File

@ -42,7 +42,7 @@ interface JsonActions {
export type File = {
id: string;
views: number;
owner_id: string;
owner_email: string;
name: string;
content: string;
private: boolean;