2025-06-11 00:14:17 +02:00
|
|
|
import { LocalFileNode } from '@colanode/client/types';
|
|
|
|
|
import { FileBody } from '@colanode/ui/components/files/file-body';
|
|
|
|
|
import { FileNotFound } from '@colanode/ui/components/files/file-not-found';
|
|
|
|
|
import { useNodeContainer } from '@colanode/ui/hooks/use-node-container';
|
2025-07-03 20:42:21 +02:00
|
|
|
import { useNodeRadar } from '@colanode/ui/hooks/use-node-radar';
|
2024-10-23 18:33:49 +02:00
|
|
|
|
|
|
|
|
interface FileContainerProps {
|
2024-12-25 00:37:50 +01:00
|
|
|
fileId: string;
|
2024-10-23 18:33:49 +02:00
|
|
|
}
|
|
|
|
|
|
2024-12-25 00:37:50 +01:00
|
|
|
export const FileContainer = ({ fileId }: FileContainerProps) => {
|
2025-02-05 22:40:35 +01:00
|
|
|
const data = useNodeContainer<LocalFileNode>(fileId);
|
2025-07-03 20:42:21 +02:00
|
|
|
useNodeRadar(data.node);
|
2024-12-22 17:47:39 +01:00
|
|
|
|
2025-01-27 12:32:15 +01:00
|
|
|
if (data.isPending) {
|
2024-12-30 21:50:08 +01:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 22:40:35 +01:00
|
|
|
if (!data.node) {
|
2025-01-06 18:46:53 +01:00
|
|
|
return <FileNotFound />;
|
2024-11-11 21:33:55 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-11 09:49:16 -08:00
|
|
|
return <FileBody file={data.node} />;
|
2024-10-23 18:33:49 +02:00
|
|
|
};
|