2025-08-28 10:59:38 +01:00
|
|
|
import { useEffect } from "react";
|
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-16 17:53:50 +01:00
|
|
|
import SplitSettings from "../components/tools/split/SplitSettings";
|
|
|
|
import { useSplitParameters } from "../hooks/tools/split/useSplitParameters";
|
|
|
|
import { useSplitOperation } from "../hooks/tools/split/useSplitOperation";
|
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-06-27 18:00:35 +01:00
|
|
|
|
2025-08-28 10:59:38 +01:00
|
|
|
const Split = (props: BaseToolProps) => {
|
2025-07-16 17:53:50 +01:00
|
|
|
const { t } = useTranslation();
|
2025-06-27 18:00:35 +01:00
|
|
|
|
2025-08-28 10:59:38 +01:00
|
|
|
const base = useBaseTool(
|
|
|
|
'split',
|
|
|
|
useSplitParameters,
|
|
|
|
useSplitOperation,
|
|
|
|
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.hasResults ? base.handleSettingsReset : undefined,
|
2025-08-15 14:43:30 +01:00
|
|
|
content: (
|
|
|
|
<SplitSettings
|
2025-08-28 10:59:38 +01:00
|
|
|
parameters={base.params.parameters}
|
|
|
|
onParameterChange={base.params.updateParameter}
|
|
|
|
disabled={base.endpointLoading}
|
2025-05-21 21:47:44 +01:00
|
|
|
/>
|
2025-08-15 14:43:30 +01:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
executeButton: {
|
|
|
|
text: t("split.submit", "Split PDF"),
|
|
|
|
loadingText: t("loading"),
|
2025-08-28 10:59:38 +01:00
|
|
|
onClick: base.handleExecute,
|
|
|
|
isVisible: !base.hasResults,
|
|
|
|
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: "Split 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 Split as ToolComponent;
|