2025-05-29 17:26:32 +01:00
|
|
|
import { useTranslation } from "react-i18next";
|
2025-08-15 14:43:30 +01:00
|
|
|
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
2025-07-22 11:01:28 +01:00
|
|
|
import CompressSettings from "../components/tools/compress/CompressSettings";
|
|
|
|
import { useCompressParameters } from "../hooks/tools/compress/useCompressParameters";
|
|
|
|
import { useCompressOperation } from "../hooks/tools/compress/useCompressOperation";
|
2025-08-28 10:59:38 +01:00
|
|
|
import { useBaseTool } from "../hooks/tools/shared/useBaseTool";
|
2025-08-22 14:40:27 +01:00
|
|
|
import { BaseToolProps, ToolComponent } from "../types/tool";
|
2025-08-14 14:27:23 +01:00
|
|
|
import { useCompressTips } from "../components/tooltips/useCompressTips";
|
2025-07-22 11:01:28 +01:00
|
|
|
|
2025-08-28 10:59:38 +01:00
|
|
|
const Compress = (props: BaseToolProps) => {
|
2025-05-29 17:26:32 +01:00
|
|
|
const { t } = useTranslation();
|
2025-08-14 14:27:23 +01:00
|
|
|
const compressTips = useCompressTips();
|
2025-07-22 11:01:28 +01:00
|
|
|
|
2025-08-28 10:59:38 +01:00
|
|
|
const base = useBaseTool(
|
|
|
|
'compress',
|
|
|
|
useCompressParameters,
|
|
|
|
useCompressOperation,
|
|
|
|
props
|
|
|
|
);
|
2025-08-15 14:43:30 +01:00
|
|
|
|
|
|
|
return createToolFlow({
|
|
|
|
files: {
|
2025-08-28 10:59:38 +01:00
|
|
|
selectedFiles: base.selectedFiles,
|
|
|
|
isCollapsed: base.hasResults,
|
2025-08-15 14:43:30 +01:00
|
|
|
},
|
|
|
|
steps: [
|
|
|
|
{
|
|
|
|
title: "Settings",
|
2025-08-28 10:59:38 +01:00
|
|
|
isCollapsed: base.settingsCollapsed,
|
|
|
|
onCollapsedClick: base.settingsCollapsed ? base.handleSettingsReset : undefined,
|
2025-08-15 14:43:30 +01:00
|
|
|
tooltip: compressTips,
|
|
|
|
content: (
|
|
|
|
<CompressSettings
|
2025-08-28 10:59:38 +01:00
|
|
|
parameters={base.params.parameters}
|
|
|
|
onParameterChange={base.params.updateParameter}
|
|
|
|
disabled={base.endpointLoading}
|
2025-05-15 20:07:33 +01:00
|
|
|
/>
|
2025-08-15 14:43:30 +01:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
executeButton: {
|
|
|
|
text: t("compress.submit", "Compress"),
|
2025-08-28 10:59:38 +01:00
|
|
|
isVisible: !base.hasResults,
|
2025-08-15 14:43:30 +01:00
|
|
|
loadingText: t("loading"),
|
2025-08-28 10:59:38 +01:00
|
|
|
onClick: base.handleExecute,
|
|
|
|
disabled: !base.params.validateParameters() || !base.hasFiles || !base.endpointEnabled,
|
2025-08-15 14:43:30 +01:00
|
|
|
},
|
|
|
|
review: {
|
2025-08-28 10:59:38 +01:00
|
|
|
isVisible: base.hasResults,
|
|
|
|
operation: base.operation,
|
2025-08-15 14:43:30 +01:00
|
|
|
title: t("compress.title", "Compression Results"),
|
2025-08-28 10:59:38 +01:00
|
|
|
onFileClick: base.handleThumbnailClick,
|
2025-08-15 14:43:30 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2025-05-21 21:47:44 +01:00
|
|
|
|
2025-08-22 14:40:27 +01:00
|
|
|
|
|
|
|
export default Compress as ToolComponent;
|