further types to admin

This commit is contained in:
James
2020-12-26 14:51:07 -05:00
parent e2d370a415
commit 569ce08174
56 changed files with 230 additions and 456 deletions

View File

@@ -1,5 +1,5 @@
export type Props = {
label?: string
label?: string | JSX.Element
required?: boolean
htmlFor?: string
}

View File

@@ -11,8 +11,8 @@ export type Context = {
export type Props = {
className?: string
operation?: Operation
readOnly: boolean
permissions: {
readOnly?: boolean
permissions?: {
[field: string]: FieldPermissions
}
filter?: (field: Field) => boolean

View File

@@ -32,7 +32,7 @@ const Text: React.FC<Props> = (props) => {
return validationResult;
}, [validate, maxLength, minLength, required]);
const fieldType = useFieldType({
const fieldType = useFieldType<string>({
path,
validate: memoizedValidate,
enableDebouncedValue: true,
@@ -70,7 +70,7 @@ const Text: React.FC<Props> = (props) => {
required={required}
/>
<input
value={value as string || ''}
value={value || ''}
onChange={setValue}
disabled={readOnly}
placeholder={placeholder}

View File

@@ -66,7 +66,6 @@ const AddUploadModal: React.FC<Props> = (props) => {
</header>
<Upload
{...collection.upload}
fieldTypes={fieldTypes}
/>
<NegativeFieldGutterProvider allow>
<RenderFields

View File

@@ -7,7 +7,7 @@ import { Options, FieldType } from './types';
import './index.scss';
const useFieldType = (options: Options): FieldType => {
const useFieldType = <T extends unknown>(options: Options): FieldType<T> => {
const {
path,
validate,

View File

@@ -9,8 +9,8 @@ export type Options = {
stringify?: boolean
}
export type FieldType = {
value: unknown
export type FieldType<T> = {
value: T
errorMessage?: string
showError: boolean
formSubmitted: boolean