feat: json pretty

This commit is contained in:
Ibrahima G. Coulibaly
2025-02-27 13:05:38 +00:00
parent 18c305ac9b
commit d2eb7030d8
12 changed files with 78 additions and 49 deletions

View File

@@ -17,7 +17,7 @@ export interface ExampleCardProps<T> {
sampleText: string;
sampleResult: string;
sampleOptions: T;
changeInputResult: (newOptions: T) => void;
changeInputResult: (newInput: string, newOptions: T) => void;
getGroups: GetGroupsType<T>;
}
@@ -35,7 +35,7 @@ export default function ExampleCard<T>({
<Card
raised
onClick={() => {
changeInputResult(sampleOptions);
changeInputResult(sampleText, sampleOptions);
}}
sx={{
bgcolor: theme.palette.background.default,

View File

@@ -15,6 +15,7 @@ export interface ExampleProps<T> {
exampleCards: CardExampleType<T>[];
getGroups: GetGroupsType<T>;
formRef: React.RefObject<FormikProps<T>>;
setInput: React.Dispatch<React.SetStateAction<string>>;
}
export default function ToolExamples<T>({
@@ -22,9 +23,11 @@ export default function ToolExamples<T>({
subtitle,
exampleCards,
getGroups,
formRef
formRef,
setInput
}: ExampleProps<T>) {
function changeInputResult(newOptions: T) {
function changeInputResult(newInput: string, newOptions: T) {
setInput(newInput);
formRef.current?.setValues(newOptions);
const toolsElement = document.getElementById('tool');
if (toolsElement) {