Skip to content

Commit

Permalink
type: added typings for the respective schema
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurparalkar committed Apr 13, 2024
1 parent c8304af commit 690e890
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
1 change: 0 additions & 1 deletion src/components/fields/InputField.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { FieldType } from "./field";

export type GroupField = {
type: "group";
fields: FieldType[];
fields: (FieldType | GroupField)[];
};
5 changes: 5 additions & 0 deletions src/schemas/forms/personal_info.d.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SchemaType } from "@/interfaces/schema";

declare const personal_info: SchemaType;

export default personal_info;
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"dataType": "number",
"fieldName": "Mobile Number",
"accessorKey": "mobNo"
},
{
"type": "field",
"dataType": "email",
"fieldName": "Email Address",
"accessorKey": "email"
}
]
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Bundler mode */
"moduleResolution": "bundler",
"allowArbitraryExtensions": true,
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
Expand Down

0 comments on commit 690e890

Please sign in to comment.