diff --git a/src/components/ConfirmButton.jsx b/src/components/ConfirmButton.tsx
similarity index 80%
rename from src/components/ConfirmButton.jsx
rename to src/components/ConfirmButton.tsx
index b198e65..486aba0 100644
--- a/src/components/ConfirmButton.jsx
+++ b/src/components/ConfirmButton.tsx
@@ -1,16 +1,28 @@
import React, { useState } from 'react';
-import PropTypes from 'prop-types';
import classnames from 'classnames';
import { FiCheck } from 'react-icons/fi';
import useTimeoutFn from '../hooks/useTimeout';
-const CONFIRM_STATES = {
- CONFIRM: 'confirm',
- DONE: 'done',
- READY: null
-};
+enum CONFIRM_STATES {
+ CONFIRM = 'confirm',
+ DONE = 'done',
+ READY = 'ready'
+}
+
+interface ConfirmButtonProps {
+ className?: string;
+ disabled?: boolean;
+ label?: string;
+ confirmLabel?: string;
+ successLabel?: string;
+ defaultClass?: string;
+ successClass?: string;
+ confirmClass?: string;
+ timeout?: number | false;
+ onConfirm?: () => void;
+}
-const ConfirmButton = ({
+const ConfirmButton: React.FC = ({
className = '',
disabled = false,
@@ -18,14 +30,13 @@ const ConfirmButton = ({
confirmLabel = 'Are you sure?',
successLabel = 'Thanks!',
- type = 'submit',
defaultClass = 'btn-primary',
successClass = 'btn-success',
confirmClass = 'btn-danger',
timeout = 3000,
onConfirm = () => {}
}) => {
- const [buttonState, setButtonState] = useState(null);
+ const [buttonState, setButtonState] = useState(CONFIRM_STATES.READY);
const isConfirm = [CONFIRM_STATES.CONFIRM, CONFIRM_STATES.DONE].includes(buttonState);
@@ -80,16 +91,4 @@ const ConfirmButton = ({
);
};
-ConfirmButton.propTypes = {
- label: PropTypes.string,
- confirmLabel: PropTypes.string,
- successLabel: PropTypes.string,
-
- defaultClass: PropTypes.string,
- confirmClass: PropTypes.string,
- successClass: PropTypes.string,
-
- onConfirm: PropTypes.func.isRequired
-};
-
export default ConfirmButton;
diff --git a/src/components/DisplayFormikState.jsx b/src/components/DisplayFormikState.tsx
similarity index 74%
rename from src/components/DisplayFormikState.jsx
rename to src/components/DisplayFormikState.tsx
index dc02ae5..c5a0ebd 100644
--- a/src/components/DisplayFormikState.jsx
+++ b/src/components/DisplayFormikState.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import Code from './Code';
-const DisplayFormikState = (props) => (
+
+const DisplayFormikState = (props: React.PropsWithChildren