Skip to content

Commit

Permalink
FEAT: Enhance Form Components with Formik Integration and Configurabi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
Jagadeeshftw committed Jan 29, 2025
1 parent b764036 commit 3ccf699
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app/(auth)/setup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import React from "react";

export default function page() {
return <SetupPage />;
}
}
18 changes: 10 additions & 8 deletions src/components/ui/form/formwrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import * as Yup from "yup";

interface FormWrapperProps {
onSubmit: (values: Record<string, any>) => void;
inputs: React.ReactNode; // Form fields (inputs) as children
button: React.ReactNode; // Custom button component
initialValues: Record<string, any>; // Form's initial values
validationSchema: Yup.ObjectSchema<any>; // Form validation schema
formClassName?: string; // Optional class name for styling the form
inputs: React.ReactNode; // Accept Input components or other inputs as props
button: React.ReactNode; // Accept a custom button as a prop
initialValues: Record<string, any>; // Configurable initial values
validationSchema: Yup.ObjectSchema<any>; // Configurable validation schema
}

export const FormWrapper: React.FC<FormWrapperProps> = ({
Expand All @@ -16,12 +15,15 @@ export const FormWrapper: React.FC<FormWrapperProps> = ({
button,
initialValues,
validationSchema,
formClassName = "flex flex-col gap-6", // Default styling
}) => {
return (
<Formik initialValues={initialValues} validationSchema={validationSchema} onSubmit={onSubmit}>
<Formik
initialValues={initialValues}
validationSchema={validationSchema}
onSubmit={onSubmit}
>
{() => (
<Form className={formClassName}>
<Form>
{inputs}
{button}
</Form>
Expand Down

0 comments on commit 3ccf699

Please sign in to comment.