2025-08-20 16:54:30 +01:00
|
|
|
import React from "react";
|
2025-08-22 17:12:14 +01:00
|
|
|
import { Text, Anchor } from "@mantine/core";
|
2025-08-20 16:54:30 +01:00
|
|
|
import { useTranslation } from "react-i18next";
|
2025-08-22 17:12:14 +01:00
|
|
|
import FolderIcon from '@mui/icons-material/Folder';
|
|
|
|
import { useFilesModalContext } from "../../../contexts/FilesModalContext";
|
|
|
|
import { useAllFiles } from "../../../contexts/FileContext";
|
2025-07-16 17:53:50 +01:00
|
|
|
|
|
|
|
export interface FileStatusIndicatorProps {
|
|
|
|
selectedFiles?: File[];
|
|
|
|
placeholder?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FileStatusIndicator = ({
|
|
|
|
selectedFiles = [],
|
2025-08-20 16:54:30 +01:00
|
|
|
placeholder,
|
2025-07-16 17:53:50 +01:00
|
|
|
}: FileStatusIndicatorProps) => {
|
2025-08-20 16:54:30 +01:00
|
|
|
const { t } = useTranslation();
|
2025-08-22 17:12:14 +01:00
|
|
|
const { openFilesModal } = useFilesModalContext();
|
|
|
|
const { files: workbenchFiles } = useAllFiles();
|
|
|
|
|
|
|
|
// Check if there are no files in the workbench
|
|
|
|
if (workbenchFiles.length === 0) {
|
|
|
|
return (
|
|
|
|
<Text size="sm" c="dimmed">
|
|
|
|
{t("files.noFiles", "No files uploaded. ")}{" "}
|
|
|
|
<Anchor
|
|
|
|
size="sm"
|
|
|
|
onClick={openFilesModal}
|
|
|
|
style={{ cursor: 'pointer', display: 'inline-flex', alignItems: 'center', gap: '4px' }}
|
|
|
|
>
|
|
|
|
<FolderIcon style={{ fontSize: '14px' }} />
|
|
|
|
{t("files.addFiles", "Add files")}
|
|
|
|
</Anchor>
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show selection status when there are files in workbench
|
2025-07-16 17:53:50 +01:00
|
|
|
if (selectedFiles.length === 0) {
|
|
|
|
return (
|
|
|
|
<Text size="sm" c="dimmed">
|
2025-08-22 17:12:14 +01:00
|
|
|
{t("files.selectFromWorkbench", "Select files from the workbench or ") + " "}
|
|
|
|
<Anchor
|
|
|
|
size="sm"
|
|
|
|
onClick={openFilesModal}
|
|
|
|
style={{ cursor: 'pointer', display: 'inline-flex', alignItems: 'center', gap: '4px' }}
|
|
|
|
>
|
|
|
|
<FolderIcon style={{ fontSize: '14px' }} />
|
|
|
|
{t("files.addFiles", "Add files")}
|
|
|
|
</Anchor>
|
2025-07-16 17:53:50 +01:00
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-08-20 16:54:30 +01:00
|
|
|
return (
|
|
|
|
<Text size="sm" c="dimmed" style={{ wordBreak: 'break-word', whiteSpace: 'normal' }}>
|
|
|
|
✓ {selectedFiles.length === 1 ? t("fileSelected", "Selected: {{filename}}", { filename: selectedFiles[0]?.name }) : t("filesSelected", "{{count}} files selected", { count: selectedFiles.length })}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
};
|
2025-07-16 17:53:50 +01:00
|
|
|
|
2025-08-20 16:54:30 +01:00
|
|
|
export default FileStatusIndicator;
|