Refactor import statements and update component types in multiple files

This commit is contained in:
Simon Larsen 2024-04-22 09:24:58 +01:00
parent 48b850d350
commit 96926ffa63
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
5 changed files with 18 additions and 25 deletions

View File

@ -25,7 +25,7 @@ const Email: () => JSX.Element = (): ReactElement => {
useState<boolean>(false);
const [error, setError] = useState<string>('');
const [currentItem, setCurrentItem] = useState<JSONObject | null>(null);
const [currentItem, setCurrentItem] = useState<UserEmail | null>(null);
const [refreshToggle, setRefreshToggle] = useState<boolean>(false);
const [isLoading, setIsLoading] = useState<boolean>(false);
@ -58,7 +58,7 @@ const Email: () => JSX.Element = (): ReactElement => {
title: 'Verify',
buttonStyleType: ButtonStyleType.SUCCESS_OUTLINE,
icon: IconProp.Check,
isVisible: (item: JSONObject): boolean => {
isVisible: (item: UserEmail): boolean => {
if (item['isVerified']) {
return false;
}
@ -66,7 +66,7 @@ const Email: () => JSX.Element = (): ReactElement => {
return true;
},
onClick: async (
item: JSONObject,
item: UserEmail,
onCompleteAction: VoidFunction,
onError: ErrorFunction
) => {
@ -84,7 +84,7 @@ const Email: () => JSX.Element = (): ReactElement => {
title: 'Resend Code',
buttonStyleType: ButtonStyleType.NORMAL,
icon: IconProp.Email,
isVisible: (item: JSONObject): boolean => {
isVisible: (item: UserEmail): boolean => {
if (item['isVerified']) {
return false;
}
@ -92,7 +92,7 @@ const Email: () => JSX.Element = (): ReactElement => {
return true;
},
onClick: async (
item: JSONObject,
item: UserEmail,
onCompleteAction: VoidFunction,
onError: ErrorFunction
) => {

View File

@ -1,9 +1,9 @@
import React, { FunctionComponent, ReactElement } from 'react';
import BaseModel, { BaseModelType } from 'Common/Models/BaseModel';
import { JSONObject } from 'Common/Types/JSON';
import UserNotificationRule from 'Model/Models/UserNotificationRule';
export interface ComponentProps {
item: JSONObject;
item: UserNotificationRule;
modelType: BaseModelType;
}
@ -18,7 +18,7 @@ const NotificationMethodView: FunctionComponent<ComponentProps> = (
return (
<div>
{item.getColumnValue('userEmail') &&
(item.getColumnValue('userEmail') as JSONObject)['email'] && (
(item.getColumnValue('userEmail'))['email'] && (
<p>
Email:{' '}
{(item.getColumnValue('userEmail') as JSONObject)[

View File

@ -68,7 +68,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
title: 'View Status Message',
buttonStyleType: ButtonStyleType.NORMAL,
onClick: async (
item: JSONObject,
item: UserOnCallLogTimeline,
onCompleteAction: VoidFunction,
onError: ErrorFunction
) => {
@ -117,7 +117,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
},
title: 'Notification Method',
type: FieldType.Element,
getElement: (item: JSONObject): ReactElement => {
getElement: (item: UserOnCallLogTimeline): ReactElement => {
return (
<NotificationMethodView
item={item}
@ -140,7 +140,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
title: 'Status',
type: FieldType.Element,
getElement: (item: JSONObject): ReactElement => {
getElement: (item: UserOnCallLogTimeline): ReactElement => {
if (
item['status'] === UserNotificationStatus.Sent
) {

View File

@ -188,7 +188,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
},
title: 'Notification Method',
type: FieldType.Text,
getElement: (item: JSONObject): ReactElement => {
getElement: (item: UserNotificationRule): ReactElement => {
return (
<NotificationMethodView
item={item}
@ -203,7 +203,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
},
title: 'Notify After',
type: FieldType.Text,
getElement: (item: JSONObject): ReactElement => {
getElement: (item: UserNotificationRule): ReactElement => {
return (
<div>
{item['notifyAfterMinutes'] === 0 && (

View File

@ -4,15 +4,12 @@ import React, {
ReactElement,
useState,
} from 'react';
import BaseModel from 'Common/Models/BaseModel';
import PageComponentProps from '../PageComponentProps';
import ModelTable from 'CommonUI/src/Components/ModelTable/ModelTable';
import WorkflowLogs from 'Model/Models/WorkflowLog';
import FieldType from 'CommonUI/src/Components/Types/FieldType';
import IconProp from 'Common/Types/Icon/IconProp';
import Navigation from 'CommonUI/src/Utils/Navigation';
import { JSONObject } from 'Common/Types/JSON';
import Workflow from 'Model/Models/Workflow';
import WorkflowElement from '../../Components/Workflow/WorkflowElement';
import { ButtonStyleType } from 'CommonUI/src/Components/Button/Button';
import Modal, { ModalWidth } from 'CommonUI/src/Components/Modal/Modal';
@ -20,6 +17,7 @@ import BadDataException from 'Common/Types/Exception/BadDataException';
import WorkflowStatus from 'Common/Types/Workflow/WorkflowStatus';
import WorkflowStatusElement from 'CommonUI/src/Components/Workflow/WorkflowStatus';
import DropdownUtil from 'CommonUI/src/Utils/Dropdown';
import WorkflowLog from 'Model/Models/WorkflowLog';
const Workflows: FunctionComponent<PageComponentProps> = (
_props: PageComponentProps
@ -40,7 +38,7 @@ const Workflows: FunctionComponent<PageComponentProps> = (
buttonStyleType: ButtonStyleType.NORMAL,
icon: IconProp.List,
onClick: async (
item: JSONObject,
item: WorkflowLogs,
onCompleteAction: VoidFunction
) => {
setLogs(item['logs'] as string);
@ -120,16 +118,11 @@ const Workflows: FunctionComponent<PageComponentProps> = (
title: 'Workflow Name',
type: FieldType.Text,
getElement: (item: JSONObject): ReactElement => {
getElement: (item: WorkflowLogs): ReactElement => {
return (
<WorkflowElement
workflow={
BaseModel.fromJSON(
(item[
'workflow'
] as JSONObject) || [],
Workflow
) as Workflow
item.workflow!
}
/>
);
@ -142,7 +135,7 @@ const Workflows: FunctionComponent<PageComponentProps> = (
title: 'Workflow Status',
type: FieldType.Text,
getElement: (item: JSONObject): ReactElement => {
getElement: (item: WorkflowLog): ReactElement => {
if (!item['workflowStatus']) {
throw new BadDataException(
'Workflow Status not found'