form field fixes
This commit is contained in:
@@ -10,12 +10,12 @@ import GenericForm from "../components/GenericForm";
|
|||||||
|
|
||||||
function wrapFormField(merged: FieldComponents) {
|
function wrapFormField(merged: FieldComponents) {
|
||||||
return (props: Omit<React.ComponentProps<typeof FormField>, 'components'>) =>
|
return (props: Omit<React.ComponentProps<typeof FormField>, 'components'>) =>
|
||||||
<FormField {...props} components={merged} />;
|
React.createElement(FormField, { ...props, components: merged });
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapGenericForm(merged: FieldComponents) {
|
function wrapGenericForm(merged: FieldComponents) {
|
||||||
return (props: Omit<React.ComponentProps<typeof GenericForm>, 'fieldComponents'>) =>
|
return (props: Omit<React.ComponentProps<typeof GenericForm>, 'fieldComponents'>) =>
|
||||||
<GenericForm {...props} fieldComponents={merged} />;
|
React.createElement(GenericForm, { ...props, fieldComponents: merged });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useResource<T = any>(config: ResourceConfig | undefined, options?: { fieldComponents: FieldComponents }) {
|
export function useResource<T = any>(config: ResourceConfig | undefined, options?: { fieldComponents: FieldComponents }) {
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ function parseSchemaFields(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const type = mapOpenApiType(resolvedProp);
|
const type = mapOpenApiType(resolvedProp);
|
||||||
|
if (type === 'enum' && (!resolvedProp.enum || resolvedProp.enum.length === 0)) {
|
||||||
|
throw new Error(
|
||||||
|
`OpenAPI schema error: field "${resourceName}.${key}" is type "enum" but has no enum values. ` +
|
||||||
|
`Add an "enum" array with at least one value to the OpenAPI schema definition.`
|
||||||
|
);
|
||||||
|
}
|
||||||
const override = overrides[key];
|
const override = overrides[key];
|
||||||
|
|
||||||
// Explicitly skip 'id' as it's the primary key and handled elsewhere
|
// Explicitly skip 'id' as it's the primary key and handled elsewhere
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ export default function FetchRequests() {
|
|||||||
|
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const fetchRes = config?.resources.find((r: any) => r.name === "fetch-requests");
|
const fetchRes = config?.resources.find((r: any) => r.name === "fetch-requests");
|
||||||
const formatField: ResourceField | undefined = fetchRes?.fields?.source?.schema?.fields?.format;
|
const formatField: ResourceField | undefined = fetchRes?.fields?.source?.schema?.format;
|
||||||
const formatOptions: string[] = formatField?.options ?? formatField?.schema?.options as string[] ?? [];
|
const formatOptions: string[] = formatField?.options ?? [];
|
||||||
const startDateField: ResourceField | undefined = fetchRes?.fields?.start_date;
|
const startDateField: ResourceField | undefined = fetchRes?.fields?.start_date;
|
||||||
const endDateField: ResourceField | undefined = fetchRes?.fields?.end_date;
|
const endDateField: ResourceField | undefined = fetchRes?.fields?.end_date;
|
||||||
const payorUsernameField: ResourceField | undefined = fetchRes?.fields?.payor_username;
|
const payorUsernameField: ResourceField | undefined = fetchRes?.fields?.payor_username;
|
||||||
@@ -396,12 +396,14 @@ export default function FetchRequests() {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<TextField
|
<Autocomplete
|
||||||
label="Account"
|
options={accountOptions}
|
||||||
value={accountFilter}
|
value={accountFilter || null}
|
||||||
onChange={(e) => setAccountFilter(e.target.value)}
|
onChange={(_, val) => setAccountFilter(val ?? "")}
|
||||||
size="small"
|
renderInput={(params) => (
|
||||||
sx={{ minWidth: 160 }}
|
<TextField {...params} label="Account" size="small" sx={{ minWidth: 160 }} />
|
||||||
|
)}
|
||||||
|
sx={{ minWidth: 160, "& .MuiOutlinedInput-root": { height: "auto", minHeight: "2.5rem" } }}
|
||||||
/>
|
/>
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
value={sourceFilter}
|
value={sourceFilter}
|
||||||
|
|||||||
Reference in New Issue
Block a user