diff --git a/.vscode/settings.json b/.vscode/settings.json index 6a521b2..ebc5ec0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "cSpell.words": [ "aldeen", + "antd", "Datepicker", "formik", "Karim", diff --git a/src/Components/Utils/getNestedValue.ts b/src/Components/Utils/getNestedValue.ts new file mode 100644 index 0000000..6d17979 --- /dev/null +++ b/src/Components/Utils/getNestedValue.ts @@ -0,0 +1,10 @@ +export const getNestedValue = (obj: any, path: string): any => { + return path.split('.').reduce((acc, part) => { + const arrayMatch = part.match(/(\w+)\[(\d+)\]/); + if (arrayMatch) { + const [, key, index] = arrayMatch; + return acc && acc[key] && acc[key][index]; + } + return acc && acc[part]; + }, obj); + }; \ No newline at end of file diff --git a/src/Components/ValidationField/View/Default.tsx b/src/Components/ValidationField/View/Default.tsx index 1d0678d..53cc796 100644 --- a/src/Components/ValidationField/View/Default.tsx +++ b/src/Components/ValidationField/View/Default.tsx @@ -6,7 +6,8 @@ const Default = ({ name, label, placeholder, isDisabled, onChange, props,type }: const { Field, formik, isError, errorMsg, t } = useFormField(name, props); - + console.log(name); + return (