Skip to content

Commit

Permalink
add increased type safety for different input text types
Browse files Browse the repository at this point in the history
  • Loading branch information
NoorChasib committed Aug 11, 2023
1 parent e94f954 commit ad9dc95
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/frontend/src/components/common/InputText/InputText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { convertLabelToId } from '../../../utils/helper.util';
import { faUpRightFromSquare } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { TextInputType } from '../../../constant/constant';
import { TextType } from '../../../types/types/text.type';

interface InputTextProps {
id?: string;
Expand All @@ -18,7 +19,7 @@ interface InputTextProps {
linkText?: string;
linkHref?: string;
hasIcon?: boolean;
type?: TextInputType;
type?: TextType;
className?: string;
value?: string | null;
placeholder?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/components/common/Table/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextInputType } from '../../../constant/constant';
import { TextType } from '../../../types/types/text.type';

export interface ColumnMetaData {
key: string;
Expand All @@ -7,7 +7,7 @@ export interface ColumnMetaData {
isDisable?: boolean;
className?: string;
hint?: string;
type?: TextInputType;
type?: TextType;
}

// default tabular data format - [{key1: value1, key2: value2}]
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/constant/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export const ApprovalRoles: IapprovalRoles = {

export enum TextInputType {
INPUT_TEXT = 'text',
INPUT_TEXT_AREA = 'textArea',
INPUT_TEXT_AREA = 'textarea',
INPUT_EMAIL = 'email',
}

Expand All @@ -289,4 +289,4 @@ export enum SubmitButtonTextEnum {
FORM = 'Submit',
FINISH_REVIEW = 'Finish review',
COMPLETE_PIA = 'Complete PIA',
}
}
1 change: 1 addition & 0 deletions src/frontend/src/types/types/text.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TextType = 'text' | 'textarea' | 'email';

0 comments on commit ad9dc95

Please sign in to comment.