-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor(data-hooks): centralize is field mutabale logic
- Loading branch information
1 parent
b4bc92d
commit 19aa42d
Showing
19 changed files
with
90 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,28 @@ | ||
import { FormApi } from "final-form"; | ||
import { ISharedFormInput } from "frontend/design-system/components/Form/_types"; | ||
import { FieldInputProps, FieldMetaState } from "react-final-form"; | ||
import { ISchemaFormConfig } from "shared/form-schemas/types"; | ||
import { IColorableSelection } from "shared/types/ui"; | ||
import { FIELD_TYPES_CONFIG_MAP } from "shared/validations"; | ||
|
||
export interface IFormExtension { | ||
fieldsState: string; | ||
beforeSubmit: string; | ||
} | ||
|
||
export interface IRenderFormInputProps { | ||
type: keyof typeof FIELD_TYPES_CONFIG_MAP; | ||
renderProps: { | ||
input: FieldInputProps<any, HTMLElement>; | ||
meta: FieldMetaState<any>; | ||
}; | ||
apiSelections?: ISchemaFormConfig["apiSelections"]; | ||
entityFieldSelections?: IColorableSelection[]; | ||
required: boolean; | ||
disabled: boolean; | ||
form: FormApi; | ||
label: string; | ||
placeholder?: string; | ||
description?: string; | ||
rightActions?: ISharedFormInput["rightActions"]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
src/frontend/views/data/hooks/useIsEntityFieldMutatable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useAppConfiguration } from "frontend/hooks/configuration/configuration.store"; | ||
import { IEntityCrudSettings } from "shared/configurations"; | ||
import { IEntityField } from "shared/types/db"; | ||
|
||
export const useIsEntityFieldMutatable = ( | ||
crudKey: keyof IEntityCrudSettings | "table" | ||
) => { | ||
const metaDataColumns = useAppConfiguration("metadata_columns"); | ||
|
||
return (entityField: IEntityField) => { | ||
if (entityField.isId) { | ||
return false; | ||
} | ||
|
||
if ( | ||
(crudKey === "create" || crudKey === "update") && | ||
[metaDataColumns.data.createdAt, metaDataColumns.data.updatedAt].includes( | ||
entityField.name | ||
) | ||
) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { | ||
usePortalExtendEntityFormConfig, | ||
PortalEntityFormComponent, | ||
useExtendRenderFormInputProps, | ||
} from "./main"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters