diff --git a/src/components/File.tsx b/src/components/File.tsx
index bb79940..c68f603 100644
--- a/src/components/File.tsx
+++ b/src/components/File.tsx
@@ -1,4 +1,4 @@
-import { $, component$ } from "@builder.io/qwik";
+import { $, component$, Signal, useSignal, useTask$ } from "@builder.io/qwik";
import { useNanostore$ } from "~/hooks/nanostores";
import { api } from "~/lib/api";
import { dashboardFiles } from "~/lib/stores";
@@ -68,17 +68,11 @@ export default component$(({ file }: FileProps) => {
- { (file.Name.endsWith(".png") || file.Name.endsWith(".jpg") || file.Name.endsWith(".jpeg")) && (
-
- )}
+
+
+
@@ -120,4 +114,86 @@ export default component$(({ file }: FileProps) => {
)
-})
\ No newline at end of file
+})
+
+const FilePreview = component$(({ file }: FileProps) => {
+ type FileType =
+ | "image"
+ | "video"
+ | "audio"
+ | "other";
+
+ const type: Signal = useSignal("other");
+ const extension = file.Name.split('.').pop()?.toLowerCase() || "";
+
+ useTask$(async () => {
+ if (
+ ["png", "jpg", "jpeg", "gif"]
+ .includes(extension)) type.value = "image";
+
+ else if (
+ ["mp4", "webm", "ogg", "avi", "mov", "mkv"]
+ .includes(extension)) type.value = "video";
+ else if (
+ ["mp3", "wav", "ogg", "flac", "aac"]
+ .includes(extension)) type.value = "audio";
+
+ else type.value = "other";
+ });
+
+ switch (type.value) {
+ case "image":
+ return (
+
+

+
+ );
+ case "video":
+ return (
+
+
+
+ );
+ case "audio":
+ return (
+
+
+
+ );
+ case "other":
+ default:
+ return (
+
+
+ Preview not available
+
+
+ );
+ }
+});
\ No newline at end of file