mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 05:59:34 +02:00
fix: compute flow
This commit is contained in:
@@ -38,25 +38,25 @@ const FormikListenerComponent = <T,>({
|
||||
return null; // This component doesn't render anything
|
||||
};
|
||||
|
||||
interface ToolContentProps<T, I> extends ToolComponentProps {
|
||||
interface ToolContentProps<Options, Input> extends ToolComponentProps {
|
||||
inputComponent?: ReactNode;
|
||||
resultComponent?: ReactNode;
|
||||
renderCustomInput?: (
|
||||
values: T,
|
||||
values: Options,
|
||||
setFieldValue: (fieldName: string, value: any) => void
|
||||
) => ReactNode;
|
||||
initialValues: T;
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
compute: (optionsValues: T, input: I) => void;
|
||||
initialValues: Options;
|
||||
getGroups: GetGroupsType<Options> | null;
|
||||
compute: (optionsValues: Options, input: Input) => void;
|
||||
toolInfo?: {
|
||||
title: string;
|
||||
description?: string;
|
||||
};
|
||||
input?: I;
|
||||
exampleCards?: CardExampleType<T>[];
|
||||
setInput?: React.Dispatch<React.SetStateAction<I>>;
|
||||
input?: Input;
|
||||
exampleCards?: CardExampleType<Options>[];
|
||||
setInput?: React.Dispatch<React.SetStateAction<Input>>;
|
||||
validationSchema?: any;
|
||||
onValuesChange?: (values: T) => void;
|
||||
onValuesChange?: (values: Options) => void;
|
||||
verticalGroups?: boolean;
|
||||
}
|
||||
|
||||
|
@@ -10,13 +10,12 @@ export default function PdfToEpub({ title }: ToolComponentProps) {
|
||||
const [result, setResult] = useState<File | null>(null);
|
||||
const [isProcessing, setIsProcessing] = useState<boolean>(false);
|
||||
|
||||
const compute = async (files: File[]) => {
|
||||
if (!files?.[0]) return;
|
||||
|
||||
const compute = async (options: {}, input: File | null) => {
|
||||
if (!input) return;
|
||||
try {
|
||||
setIsProcessing(true);
|
||||
setResult(null);
|
||||
const epub = await convertPdfToEpub(files[0]);
|
||||
const epub = await convertPdfToEpub(input);
|
||||
setResult(epub);
|
||||
} catch (error) {
|
||||
console.error('Failed to convert PDF to EPUB:', error);
|
||||
@@ -25,18 +24,12 @@ export default function PdfToEpub({ title }: ToolComponentProps) {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (input) {
|
||||
compute([input]);
|
||||
}
|
||||
}, [input]);
|
||||
|
||||
return (
|
||||
<ToolContent
|
||||
title={title}
|
||||
input={input}
|
||||
setInput={setInput}
|
||||
initialValues={input ? [input] : []}
|
||||
initialValues={{}}
|
||||
compute={compute}
|
||||
inputComponent={
|
||||
<ToolPdfInput
|
||||
|
Reference in New Issue
Block a user