Skip to content

Commit

Permalink
Merge pull request #361 from suvarnakale/shiksha-2.0
Browse files Browse the repository at this point in the history
Issue #PS-1247 feat: Integrated RJSF library
  • Loading branch information
itsvick authored Jul 9, 2024
2 parents 9682db3 + 7a52a91 commit 480d8bb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.15.15",
"@mui/material": "^5.15.15",
"@mui/material": "^5.15.21",
"@project-sunbird/client-services": "^7.0.6",
"@project-sunbird/telemetry-sdk": "^1.3.0",
"@rjsf/core": "^5.18.5",
"@rjsf/material-ui": "^5.18.5",
"@rjsf/utils": "^5.18.5",
"@rjsf/validator-ajv8": "^5.18.5",
"@tanstack/react-query": "^5.45.1",
"axios": "^1.6.8",
"date-fns": "^3.6.0",
Expand All @@ -42,7 +46,9 @@
"react-circular-progressbar": "^2.1.0",
"react-dom": "^18",
"react-ga4": "^2.1.0",
"react-i18next": "^14.1.2",
"react-joyride": "^2.8.2",
"react-select": "^5.8.0",
"react-toastify": "^10.0.5",
"sharp": "^0.33.3",
"zustand": "^4.5.4"
Expand Down
42 changes: 42 additions & 0 deletions src/components/DynamicForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import Form, { IChangeEvent } from '@rjsf/core';
import ISubmitEvent from '@rjsf/core';
import validator from '@rjsf/validator-ajv8';
import { Theme as MaterialUITheme } from '@rjsf/material-ui';
import { withTheme } from '@rjsf/core';

const FormWithMaterialUI = withTheme(MaterialUITheme);

interface DynamicFormProps {
schema: any;
uiSchema: any;
formData?: any;
onSubmit: (data: ISubmitEvent<any>, event: React.FormEvent<any>) => void;
onChange: (event: IChangeEvent<any>) => void;
onError: (errors: any) => void;
showErrorList: boolean;
}
const DynamicForm: React.FC<DynamicFormProps> = ({
schema,
uiSchema,
formData,
onSubmit,
onChange,
onError,
}) => {
return (
<FormWithMaterialUI
schema={schema}
uiSchema={uiSchema}
formData={formData}
onChange={onChange}
onSubmit={onSubmit}
onError={onError}
validator={validator}
liveValidate
showErrorList={false}
/>
);
};

export default DynamicForm;

0 comments on commit 480d8bb

Please sign in to comment.