mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
- Updated import statements in ComponentSettingsModal, ComponentValuePickerModal, ComponentsModal, DocumentationViewer, RunForm, RunModal, Utils, VariableModal, Workflow, WorkflowStatus, Config, EntityFieldType, and various API utility files to reflect the new directory structure. - Ensured all imports from "Common/Types" are now sourced from "../../../Types" to maintain consistency and improve module resolution.
67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
import { ButtonStyleType } from "../Button/Button";
|
|
import Card from "../Card/Card";
|
|
import ConfirmModal from "../Modal/ConfirmModal";
|
|
import IconProp from "../../../Types/Icon/IconProp";
|
|
import React, { ReactElement, useState } from "react";
|
|
|
|
export interface ConfirmAction {
|
|
actionName: string;
|
|
actionIcon: IconProp;
|
|
onConfirmAction: () => void;
|
|
actionButtonStyle?: ButtonStyleType;
|
|
isLoading?: boolean;
|
|
}
|
|
|
|
export interface ComponentProps {
|
|
title: string;
|
|
description: string;
|
|
actions: Array<ConfirmAction>;
|
|
}
|
|
|
|
const ActionCard: (props: ComponentProps) => ReactElement = (
|
|
props: ComponentProps,
|
|
): ReactElement => {
|
|
const [currentAction, setCurrentAction] = useState<ConfirmAction | undefined>(
|
|
undefined,
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<Card
|
|
title={props.title}
|
|
description={props.description}
|
|
buttons={props.actions.map((action: ConfirmAction) => {
|
|
return {
|
|
title: action.actionName,
|
|
buttonStyle: action.actionButtonStyle || ButtonStyleType.NORMAL,
|
|
onClick: () => {
|
|
setCurrentAction(action);
|
|
},
|
|
icon: action.actionIcon,
|
|
isLoading: action.isLoading,
|
|
};
|
|
})}
|
|
/>
|
|
|
|
{currentAction ? (
|
|
<ConfirmModal
|
|
description={`Are you sure you want to ${currentAction.actionName}?`}
|
|
title={`Confirm ${currentAction.actionName}`}
|
|
onSubmit={() => {
|
|
currentAction.onConfirmAction();
|
|
setCurrentAction(undefined);
|
|
}}
|
|
submitButtonText={`Confirm`}
|
|
onClose={() => {
|
|
setCurrentAction(undefined);
|
|
}}
|
|
/>
|
|
) : (
|
|
<></>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default ActionCard;
|