fix: compute flow

This commit is contained in:
Ibrahima G. Coulibaly
2025-06-02 17:19:07 +01:00
parent fed0ef4e0d
commit 215f4027f2
3 changed files with 84 additions and 91 deletions

142
.idea/workspace.xml generated
View File

@@ -6,8 +6,8 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="chore: remove unnecessary prop"> <list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="chore: remove unnecessary prop">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/options/TextareaWithDesc.tsx" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/src/components/ToolContent.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolContent.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/csv/insert-csv-columns/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/csv/insert-csv-columns/index.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/pdf-to-epub/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/pdf-to-epub/index.tsx" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -24,7 +24,7 @@
<option name="PUSH_AUTO_UPDATE" value="true" /> <option name="PUSH_AUTO_UPDATE" value="true" />
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="main" /> <entry key="$PROJECT_DIR$" value="chesterkxng" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@@ -43,122 +43,122 @@
&quot;state&quot;: &quot;OPEN&quot; &quot;state&quot;: &quot;OPEN&quot;
} }
}</component> }</component>
<component name="GitHubPullRequestState"><![CDATA[{ <component name="GitHubPullRequestState">{
"prStates": [ &quot;prStates&quot;: [
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts51PkS9", &quot;id&quot;: &quot;PR_kwDOMJIfts51PkS9&quot;,
"number": 22 &quot;number&quot;: 22
}, },
"lastSeen": 1741207144695 &quot;lastSeen&quot;: 1741207144695
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6NiNYl", &quot;id&quot;: &quot;PR_kwDOMJIfts6NiNYl&quot;,
"number": 32 &quot;number&quot;: 32
}, },
"lastSeen": 1741209723869 &quot;lastSeen&quot;: 1741209723869
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6Nheyd", &quot;id&quot;: &quot;PR_kwDOMJIfts6Nheyd&quot;,
"number": 31 &quot;number&quot;: 31
}, },
"lastSeen": 1741213371410 &quot;lastSeen&quot;: 1741213371410
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6NmRBs", &quot;id&quot;: &quot;PR_kwDOMJIfts6NmRBs&quot;,
"number": 33 &quot;number&quot;: 33
}, },
"lastSeen": 1741282429036 &quot;lastSeen&quot;: 1741282429036
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts5zyFTs", &quot;id&quot;: &quot;PR_kwDOMJIfts5zyFTs&quot;,
"number": 15 &quot;number&quot;: 15
}, },
"lastSeen": 1741535540953 &quot;lastSeen&quot;: 1741535540953
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6QQB3c", &quot;id&quot;: &quot;PR_kwDOMJIfts6QQB3c&quot;,
"number": 59 &quot;number&quot;: 59
}, },
"lastSeen": 1743018960900 &quot;lastSeen&quot;: 1743018960900
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6QMPEg", &quot;id&quot;: &quot;PR_kwDOMJIfts6QMPEg&quot;,
"number": 58 &quot;number&quot;: 58
}, },
"lastSeen": 1743019452983 &quot;lastSeen&quot;: 1743019452983
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6QZvRI", &quot;id&quot;: &quot;PR_kwDOMJIfts6QZvRI&quot;,
"number": 61 &quot;number&quot;: 61
}, },
"lastSeen": 1743103196866 &quot;lastSeen&quot;: 1743103196866
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6QqPrQ", &quot;id&quot;: &quot;PR_kwDOMJIfts6QqPrQ&quot;,
"number": 73 &quot;number&quot;: 73
}, },
"lastSeen": 1743265865001 &quot;lastSeen&quot;: 1743265865001
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6Qp5nI", &quot;id&quot;: &quot;PR_kwDOMJIfts6Qp5nI&quot;,
"number": 72 &quot;number&quot;: 72
}, },
"lastSeen": 1743338472110 &quot;lastSeen&quot;: 1743338472110
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6QsjlS", &quot;id&quot;: &quot;PR_kwDOMJIfts6QsjlS&quot;,
"number": 76 &quot;number&quot;: 76
}, },
"lastSeen": 1743352150953 &quot;lastSeen&quot;: 1743352150953
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6Q0JBe", &quot;id&quot;: &quot;PR_kwDOMJIfts6Q0JBe&quot;,
"number": 82 &quot;number&quot;: 82
}, },
"lastSeen": 1743470267269 &quot;lastSeen&quot;: 1743470267269
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6UE9-x", &quot;id&quot;: &quot;PR_kwDOMJIfts6UE9-x&quot;,
"number": 102 &quot;number&quot;: 102
}, },
"lastSeen": 1747171977348 &quot;lastSeen&quot;: 1747171977348
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6XPua_", &quot;id&quot;: &quot;PR_kwDOMJIfts6XPua_&quot;,
"number": 117 &quot;number&quot;: 117
}, },
"lastSeen": 1747929835864 &quot;lastSeen&quot;: 1747929835864
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6XY-mZ", &quot;id&quot;: &quot;PR_kwDOMJIfts6XY-mZ&quot;,
"number": 119 &quot;number&quot;: 119
}, },
"lastSeen": 1748028108508 &quot;lastSeen&quot;: 1748028108508
}, },
{ {
"id": { &quot;id&quot;: {
"id": "PR_kwDOMJIfts6Xdz4n", &quot;id&quot;: &quot;PR_kwDOMJIfts6Xdz4n&quot;,
"number": 120 &quot;number&quot;: 120
}, },
"lastSeen": 1748282672214 &quot;lastSeen&quot;: 1748282672214
} }
] ]
}]]></component> }</component>
<component name="GithubPullRequestsUISettings">{ <component name="GithubPullRequestsUISettings">{
&quot;selectedUrlAndAccountId&quot;: { &quot;selectedUrlAndAccountId&quot;: {
&quot;url&quot;: &quot;https://github.com/iib0011/omni-tools.git&quot;, &quot;url&quot;: &quot;https://github.com/iib0011/omni-tools.git&quot;,
@@ -211,7 +211,7 @@
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run", "Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
"Vitest.replaceText function.executor": "Run", "Vitest.replaceText function.executor": "Run",
"Vitest.timeBetweenDates.executor": "Run", "Vitest.timeBetweenDates.executor": "Run",
"git-widget-placeholder": "#120 on chesterkxng", "git-widget-placeholder": "#131 on fork/ARRY7686/main",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true", "kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src", "last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src",

View File

@@ -38,25 +38,25 @@ const FormikListenerComponent = <T,>({
return null; // This component doesn't render anything return null; // This component doesn't render anything
}; };
interface ToolContentProps<T, I> extends ToolComponentProps { interface ToolContentProps<Options, Input> extends ToolComponentProps {
inputComponent?: ReactNode; inputComponent?: ReactNode;
resultComponent?: ReactNode; resultComponent?: ReactNode;
renderCustomInput?: ( renderCustomInput?: (
values: T, values: Options,
setFieldValue: (fieldName: string, value: any) => void setFieldValue: (fieldName: string, value: any) => void
) => ReactNode; ) => ReactNode;
initialValues: T; initialValues: Options;
getGroups: GetGroupsType<T> | null; getGroups: GetGroupsType<Options> | null;
compute: (optionsValues: T, input: I) => void; compute: (optionsValues: Options, input: Input) => void;
toolInfo?: { toolInfo?: {
title: string; title: string;
description?: string; description?: string;
}; };
input?: I; input?: Input;
exampleCards?: CardExampleType<T>[]; exampleCards?: CardExampleType<Options>[];
setInput?: React.Dispatch<React.SetStateAction<I>>; setInput?: React.Dispatch<React.SetStateAction<Input>>;
validationSchema?: any; validationSchema?: any;
onValuesChange?: (values: T) => void; onValuesChange?: (values: Options) => void;
verticalGroups?: boolean; verticalGroups?: boolean;
} }

View File

@@ -10,13 +10,12 @@ export default function PdfToEpub({ title }: ToolComponentProps) {
const [result, setResult] = useState<File | null>(null); const [result, setResult] = useState<File | null>(null);
const [isProcessing, setIsProcessing] = useState<boolean>(false); const [isProcessing, setIsProcessing] = useState<boolean>(false);
const compute = async (files: File[]) => { const compute = async (options: {}, input: File | null) => {
if (!files?.[0]) return; if (!input) return;
try { try {
setIsProcessing(true); setIsProcessing(true);
setResult(null); setResult(null);
const epub = await convertPdfToEpub(files[0]); const epub = await convertPdfToEpub(input);
setResult(epub); setResult(epub);
} catch (error) { } catch (error) {
console.error('Failed to convert PDF to EPUB:', 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 ( return (
<ToolContent <ToolContent
title={title} title={title}
input={input} input={input}
setInput={setInput} setInput={setInput}
initialValues={input ? [input] : []} initialValues={{}}
compute={compute} compute={compute}
inputComponent={ inputComponent={
<ToolPdfInput <ToolPdfInput