refactor: use ToolContent in palindrome

This commit is contained in:
Ibrahima G. Coulibaly
2025-03-09 01:29:50 +00:00
parent 0fadb91b2c
commit b372692971
2 changed files with 28 additions and 34 deletions

28
.idea/workspace.xml generated
View File

@@ -4,9 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="refactor: use ToolContent"> <list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="refactor: use ToolContent in ExtractSubstring">
<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/pages/tools/string/extract-substring/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/string/extract-substring/index.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pages/tools/string/palindrome/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/string/palindrome/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" />
@@ -333,15 +333,7 @@
<workItem from="1740880919391" duration="4395000" /> <workItem from="1740880919391" duration="4395000" />
<workItem from="1740923024259" duration="23000" /> <workItem from="1740923024259" duration="23000" />
<workItem from="1740933006573" duration="3679000" /> <workItem from="1740933006573" duration="3679000" />
<workItem from="1741475969294" duration="6863000" /> <workItem from="1741475969294" duration="6986000" />
</task>
<task id="LOCAL-00103" summary="feat: update readme">
<option name="closed" value="true" />
<created>1740276092528</created>
<option name="number" value="00103" />
<option name="presentableId" value="LOCAL-00103" />
<option name="project" value="LOCAL" />
<updated>1740276092528</updated>
</task> </task>
<task id="LOCAL-00104" summary="feat: compress png"> <task id="LOCAL-00104" summary="feat: compress png">
<option name="closed" value="true" /> <option name="closed" value="true" />
@@ -727,7 +719,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1741483345639</updated> <updated>1741483345639</updated>
</task> </task>
<option name="localTasksCounter" value="152" /> <task id="LOCAL-00152" summary="refactor: use ToolContent in ExtractSubstring">
<option name="closed" value="true" />
<created>1741483603658</created>
<option name="number" value="00152" />
<option name="presentableId" value="LOCAL-00152" />
<option name="project" value="LOCAL" />
<updated>1741483603658</updated>
</task>
<option name="localTasksCounter" value="153" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@@ -786,7 +786,6 @@
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_NEW_TODO" value="false" /> <option name="CHECK_NEW_TODO" value="false" />
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="chore: handle enter press on search" />
<MESSAGE value="chore: show tooloptions in example" /> <MESSAGE value="chore: show tooloptions in example" />
<MESSAGE value="refact: examples" /> <MESSAGE value="refact: examples" />
<MESSAGE value="fix: examples" /> <MESSAGE value="fix: examples" />
@@ -811,7 +810,8 @@
<MESSAGE value="feat: change pgn opacity" /> <MESSAGE value="feat: change pgn opacity" />
<MESSAGE value="feat: csv to json" /> <MESSAGE value="feat: csv to json" />
<MESSAGE value="refactor: use ToolContent" /> <MESSAGE value="refactor: use ToolContent" />
<option name="LAST_COMMIT_MESSAGE" value="refactor: use ToolContent" /> <MESSAGE value="refactor: use ToolContent in ExtractSubstring" />
<option name="LAST_COMMIT_MESSAGE" value="refactor: use ToolContent in ExtractSubstring" />
</component> </component>
<component name="XSLT-Support.FileAssociations.UIState"> <component name="XSLT-Support.FileAssociations.UIState">
<expand /> <expand />

View File

@@ -11,6 +11,7 @@ import ToolExamples, {
} from '@components/examples/ToolExamples'; } from '@components/examples/ToolExamples';
import { ToolComponentProps } from '@tools/defineTool'; import { ToolComponentProps } from '@tools/defineTool';
import { FormikProps } from 'formik'; import { FormikProps } from 'formik';
import ToolContent from '@components/ToolContent';
const initialValues = { const initialValues = {
splitOperatorType: 'symbol' as SplitOperatorType, splitOperatorType: 'symbol' as SplitOperatorType,
@@ -76,7 +77,6 @@ const exampleCards: CardExampleType<typeof initialValues>[] = [
export default function Palindrome({ title }: ToolComponentProps) { export default function Palindrome({ title }: ToolComponentProps) {
const [input, setInput] = useState<string>(''); const [input, setInput] = useState<string>('');
const [result, setResult] = useState<string>(''); const [result, setResult] = useState<string>('');
const formRef = useRef<FormikProps<typeof initialValues>>(null);
const computeExternal = ( const computeExternal = (
optionsValues: typeof initialValues, optionsValues: typeof initialValues,
@@ -109,24 +109,18 @@ export default function Palindrome({ title }: ToolComponentProps) {
]; ];
return ( return (
<Box> <ToolContent
<ToolInputAndResult title={title}
input={<ToolTextInput value={input} onChange={setInput} />} initialValues={initialValues}
result={<ToolTextResult title={'Palindrome results'} value={result} />} getGroups={getGroups}
/> compute={computeExternal}
<ToolOptions input={input}
compute={computeExternal} setInput={setInput}
getGroups={getGroups} inputComponent={<ToolTextInput value={input} onChange={setInput} />}
initialValues={initialValues} resultComponent={
input={input} <ToolTextResult title={'Palindrome results'} value={result} />
/> }
<ToolExamples exampleCards={exampleCards}
title={title} />
exampleCards={exampleCards}
getGroups={getGroups}
formRef={formRef}
setInput={setInput}
/>
</Box>
); );
} }