mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-12 19:02:53 +08:00
fix: document fetch
This commit is contained in:
parent
9b7fc7255f
commit
f9bfcf7fb4
@ -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"}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user