reading from openapi spec

This commit is contained in:
2026-04-01 18:06:09 +05:30
parent 3b472242a7
commit 344106f1a4
9 changed files with 265 additions and 103 deletions

View File

@@ -24,6 +24,8 @@ interface GenericFormProps {
loading?: boolean;
}
import { ConfigContext } from '../App';
export default function GenericForm({
config,
initialData = {},
@@ -33,6 +35,7 @@ export default function GenericForm({
}: GenericFormProps) {
const [formData, setFormData] = React.useState(initialData);
const { uploadFile, uploading } = useUpload();
const appConfig = React.useContext(ConfigContext);
const handleChange = (key: string, value: any) => {
setFormData((prev: any) => ({ ...prev, [key]: value }));
@@ -60,6 +63,7 @@ export default function GenericForm({
disabled={field.readOnly}
uploadFile={uploadFile}
uploading={uploading}
baseUrl={appConfig?.baseUrl || ""}
/>
))}
@@ -75,7 +79,7 @@ export default function GenericForm({
);
}
function FormField({ name, field, value, onChange, disabled, uploadFile, uploading }: any) {
function FormField({ name, field, value, onChange, disabled, uploadFile, uploading, baseUrl }: any) {
const label = field.label;
if (field.type === 'image') {
@@ -83,11 +87,12 @@ function FormField({ name, field, value, onChange, disabled, uploadFile, uploadi
<ImageUploadField
label={label}
value={value}
onUpload={async (file) => {
onUpload={async (file: any) => {
const url = await uploadFile(file);
if (url) onChange(url);
}}
uploading={uploading}
baseUrl={baseUrl}
/>
);
}