From 690e89099981e7c56b9e48fa59d6b3f7da09f7f0 Mon Sep 17 00:00:00 2001 From: keyurparalkar Date: Sat, 13 Apr 2024 12:19:30 +0530 Subject: [PATCH] type: added typings for the respective schema --- src/App.tsx | 3 +-- src/components/fields/InputField.tsx | 1 - src/interfaces/group.ts | 2 +- src/schemas/forms/personal_info.d.json.ts | 5 +++++ src/schemas/{ => forms}/personal_info.json | 6 ++++++ tsconfig.json | 1 + 6 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/schemas/forms/personal_info.d.json.ts rename src/schemas/{ => forms}/personal_info.json (76%) diff --git a/src/App.tsx b/src/App.tsx index 8b2d999..7f2c78f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,9 +1,8 @@ import { useForm } from "react-hook-form"; import InputField from "./components/fields/InputField"; -import personalInfoSchema from "./schemas/personal_info.json"; +import personalInfoSchema from "./schemas/forms/personal_info.json"; function App() { - console.log({ personalInfoSchema }); const schema = personalInfoSchema; const { register, handleSubmit } = useForm(); diff --git a/src/components/fields/InputField.tsx b/src/components/fields/InputField.tsx index 8b48b04..1b50bd5 100644 --- a/src/components/fields/InputField.tsx +++ b/src/components/fields/InputField.tsx @@ -1,7 +1,6 @@ import { UseFormRegister } from "react-hook-form"; import { Input, InputProps } from "../ui/input"; import { Label } from "../ui/label"; -import { FieldType } from "@/interfaces/field"; interface InputFieldProps extends InputProps { labelText: string; diff --git a/src/interfaces/group.ts b/src/interfaces/group.ts index 332d623..a5df6e1 100644 --- a/src/interfaces/group.ts +++ b/src/interfaces/group.ts @@ -2,5 +2,5 @@ import { FieldType } from "./field"; export type GroupField = { type: "group"; - fields: FieldType[]; + fields: (FieldType | GroupField)[]; }; diff --git a/src/schemas/forms/personal_info.d.json.ts b/src/schemas/forms/personal_info.d.json.ts new file mode 100644 index 0000000..13ee3ee --- /dev/null +++ b/src/schemas/forms/personal_info.d.json.ts @@ -0,0 +1,5 @@ +import { SchemaType } from "@/interfaces/schema"; + +declare const personal_info: SchemaType; + +export default personal_info; diff --git a/src/schemas/personal_info.json b/src/schemas/forms/personal_info.json similarity index 76% rename from src/schemas/personal_info.json rename to src/schemas/forms/personal_info.json index d2309ef..acee490 100644 --- a/src/schemas/personal_info.json +++ b/src/schemas/forms/personal_info.json @@ -18,6 +18,12 @@ "dataType": "number", "fieldName": "Mobile Number", "accessorKey": "mobNo" + }, + { + "type": "field", + "dataType": "email", + "fieldName": "Email Address", + "accessorKey": "email" } ] } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index fb00b7d..4e63707 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ /* Bundler mode */ "moduleResolution": "bundler", + "allowArbitraryExtensions": true, "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true,