2025-10-24 16:10:59 +02:00
|
|
|
import Link from "next/link";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { AllegatoIframe } from "~/components/allegato-iframe";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { LoadingPage } from "~/components/loading";
|
2025-08-13 17:29:26 +02:00
|
|
|
import { useTranslation } from "~/providers/I18nProvider";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { api } from "~/utils/api";
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-10-24 16:10:59 +02:00
|
|
|
export const FileSection = ({ storageId }: { storageId: string }) => {
|
|
|
|
|
const { data: fileInfos, isLoading } = api.storage.getFileInfos.useQuery({
|
2025-08-28 18:27:07 +02:00
|
|
|
storageId,
|
|
|
|
|
});
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
if (isLoading) return <LoadingPage />;
|
|
|
|
|
if (!fileInfos) return <p>{t.file_section.error}</p>;
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<AllegatoIframe
|
2025-10-24 16:10:59 +02:00
|
|
|
allegato={fileInfos}
|
2025-08-28 18:27:07 +02:00
|
|
|
className="h-full max-h-[70vh] min-h-[60vh]"
|
|
|
|
|
/>
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-10-24 16:10:59 +02:00
|
|
|
<Link
|
2025-08-29 16:18:32 +02:00
|
|
|
className="underline underline-offset-1 after:content-['_↗']"
|
2025-10-24 16:10:59 +02:00
|
|
|
href={`/storage-api/get/${fileInfos.id}?mode=download`}
|
2025-08-28 18:27:07 +02:00
|
|
|
>
|
|
|
|
|
{t.file_section.download}
|
2025-10-24 16:10:59 +02:00
|
|
|
</Link>
|
2025-08-28 18:27:07 +02:00
|
|
|
</>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|