import { useEffect, useState } from "react";
import clsx from "clsx";
import { User } from "@/types/user";
import { formatBytes, fromNowTime, getFileIcon } from "@/utils";
import IconClose from "@/assets/icons/close.circle.svg";
import ExpiredMessage from "./ExpiredMessage";
import Progress from "./Progress";
import DownloadArea from "./DownloadArea";
type Props = {
content: string;
sending: boolean;
content_type: string;
name: string;
progress: number;
size: number;
created_at: number;
from_user: User;
handleCancel: () => void;
};
const OtherFileMessage = ({
content,
sending,
content_type,
name,
progress,
size,
created_at,
from_user,
handleCancel
}: Props) => {
const [error, setError] = useState(false);
const icon = getFileIcon(content_type, name, `w-9 shrink-0 h-auto`);
useEffect(() => {
if (content) {
fetch(content)
.then((resp) => {
console.log("fetch", resp.status);
if (resp.status >= 400) {
setError(true);
}
})
.catch((error) => {
console.log("fetch error", error);
setError(true);
});
}
}, [content]);
if (error) return