forked from midday-ai/midday
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
153 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
apps/dashboard/src/components/charts/transactions-item-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ErrorFallback } from "@/components/error-fallback"; | ||
import { ErrorBoundary } from "next/dist/client/components/error-boundary"; | ||
import { Suspense } from "react"; | ||
import { | ||
VaultWidget, | ||
VaultWidgetHeader, | ||
VaultWidgetSkeleton, | ||
} from "./vault-widget"; | ||
|
||
export function Vault() { | ||
return ( | ||
<div className="border aspect-square overflow-hidden relative p-4 md:p-8"> | ||
<VaultWidgetHeader /> | ||
|
||
<ErrorBoundary errorComponent={ErrorFallback}> | ||
<Suspense fallback={<VaultWidgetSkeleton />}> | ||
<VaultWidget /> | ||
</Suspense> | ||
</ErrorBoundary> | ||
</div> | ||
); | ||
} |
57 changes: 57 additions & 0 deletions
57
apps/dashboard/src/components/widgets/vault/vault-widget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { getUser } from "@midday/supabase/cached-queries"; | ||
import { getVaultActivityQuery } from "@midday/supabase/queries"; | ||
import { createClient } from "@midday/supabase/server"; | ||
import { Vault } from "./vault"; | ||
|
||
export function VaultWidgetSkeleton() { | ||
return null; | ||
} | ||
|
||
export function VaultWidgetHeader() { | ||
return ( | ||
<div> | ||
<h2 className="text-lg">Recent files</h2> | ||
|
||
<div className="flex py-3 border-b-[1px] justify-between mt-4"> | ||
<span className="font-medium text-sm">Name</span> | ||
<span className="font-medium text-sm">Tag</span> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export async function VaultWidget() { | ||
const supabase = createClient(); | ||
const { data: userData } = await getUser(); | ||
|
||
const { data: storageData } = await getVaultActivityQuery( | ||
supabase, | ||
userData?.team_id, | ||
); | ||
|
||
const files = storageData | ||
?.filter((file) => file?.path_tokens.pop() !== ".emptyFolderPlaceholder") | ||
.map((file) => { | ||
const [_, ...pathWithoutTeamId] = file?.path_tokens ?? []; | ||
|
||
return { | ||
id: file.id, | ||
name: file.name?.split("/").at(-1), | ||
path: file.path_tokens, | ||
mimetype: file.metadata?.mimetype, | ||
team_id: file.team_id, | ||
tag: file.tag, | ||
filePath: pathWithoutTeamId?.join("/"), | ||
}; | ||
}); | ||
|
||
if (!files?.length) { | ||
return ( | ||
<div className="flex items-center justify-center aspect-square"> | ||
<p className="text-sm text-[#606060] -mt-12">No files found</p> | ||
</div> | ||
); | ||
} | ||
|
||
return <Vault files={files} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { FilePreview } from "@/components/file-preview"; | ||
import { Tag } from "@/components/tables/vault/tag"; | ||
import { | ||
HoverCard, | ||
HoverCardContent, | ||
HoverCardTrigger, | ||
} from "@midday/ui/hover-card"; | ||
import { isSupportedFilePreview } from "@midday/utils"; | ||
|
||
type Props = { | ||
files: { | ||
id: string; | ||
name: string; | ||
tag?: string; | ||
mimetype: string; | ||
team_id: string; | ||
filePath: string; | ||
}[]; | ||
}; | ||
|
||
export function Vault({ files }: Props) { | ||
return ( | ||
<ul className="bullet-none divide-y cursor-pointer overflow-auto scrollbar-hide aspect-square pb-24"> | ||
{files?.map((file) => { | ||
const filePreviewSupported = isSupportedFilePreview(file.mimetype); | ||
|
||
return ( | ||
<li key={file.id}> | ||
<HoverCard openDelay={200}> | ||
<HoverCardTrigger asChild> | ||
<div className="flex items-center py-3"> | ||
<div className="w-[55%]"> | ||
<span className="text-sm line-clamp-1">{file.name}</span> | ||
</div> | ||
|
||
<div className="ml-auto"> | ||
<Tag name={file.tag} /> | ||
</div> | ||
</div> | ||
</HoverCardTrigger> | ||
{filePreviewSupported && ( | ||
<HoverCardContent className="w-[273px] h-[358px] p-0 overflow-hidden"> | ||
<FilePreview | ||
width={280} | ||
height={365} | ||
src={`/api/proxy?filePath=vault/${file.team_id}/${file.filePath}/${file.name}`} | ||
downloadUrl={`/api/download/file?path=${file.filePath}/${file.name}&filename=${file.name}`} | ||
name={file.name} | ||
type={file?.mimetype} | ||
/> | ||
</HoverCardContent> | ||
)} | ||
</HoverCard> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters