diff --git a/src/components/proposal/PrepareProposal.jsx b/src/components/proposal/PrepareProposal.jsx
new file mode 100644
index 00000000..20d10e54
--- /dev/null
+++ b/src/components/proposal/PrepareProposal.jsx
@@ -0,0 +1,101 @@
+import React from 'react';
+import {CopyToClipboard} from 'react-copy-to-clipboard';
+import {useForm} from 'react-hook-form';
+import {ErrorMessage} from '@hookform/error-message';
+import {yupResolver} from '@hookform/resolvers';
+import * as yup from 'yup';
+import swal from 'sweetalert2';
+
+const schema = yup.object().shape({
+ paymentTxId: yup.string()
+ .test('len', 'Must be exactly 64 characters', val => val && val.length === 64)
+ .required('Payment txid is required')
+});
+
+/**
+ * Component to show the prepare proposal step (Step 5)
+ * @component
+ * @subcategory Proposal
+ * @example
+ * return (
+ *
+ * )
+ */
+function PrepareProposal({ prepareCommand, onSubmit, onCancel }) {
+ const {register, handleSubmit, errors} = useForm({
+ mode: 'onSubmit',
+ resolver: yupResolver(schema)
+ });
+
+ /**
+ * function that triggers sweet alert to show the copy is successful
+ * @function
+ */
+ const copyButton = () => {
+ swal.fire({
+ icon: 'success',
+ title: 'Copied',
+ timer: 2000,
+ showConfirmButton: false,
+ });
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ Prepare command is ready to be copied. Please copy and paste it into Syscoin Q.T console for payment txid.
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default PrepareProposal;
diff --git a/src/components/proposal/ProposalForm.jsx b/src/components/proposal/ProposalForm.jsx
index afbc721a..21ce6219 100644
--- a/src/components/proposal/ProposalForm.jsx
+++ b/src/components/proposal/ProposalForm.jsx
@@ -1,12 +1,6 @@
-import React, {useState, useEffect, useMemo, useRef} from "react";
-import {CopyToClipboard} from "react-copy-to-clipboard";
+import React, {useState, useEffect, useMemo, useRef, useCallback} from "react";
import swal from "sweetalert2";
-import {Collapse} from 'react-collapse';
import {useHistory} from "react-router";
-import {useForm} from "react-hook-form";
-import {ErrorMessage} from '@hookform/error-message';
-import {yupResolver} from '@hookform/resolvers';
-import * as yup from "yup";
import {checkProposal, prepareProposal, notCompletedProposal, destroyProposal} from "../../utils/request";
import {getAxiosErrorFooter, getAxiosErrorMessage, logAxiosError} from "../../utils/errorHandler";
@@ -16,21 +10,11 @@ import TitleProposal from './TitleProposal';
import DescriptionProposal from './DescriptionProposal';
import PaymentProposal from './PaymentProposal';
import ProposalPreview from "./ProposalPreview";
+import PrepareProposal from "./PrepareProposal";
+import SubmitProposal from "./SubmitProposal";
import axios from 'axios';
import useProposalSubmission from './hooks/useProposalSubmission';
-
-const schema = yup.object().shape({
- paymentTxId: yup.string()
- .test('len', 'Must be exactly 64 characters', val => val.length === 64)
- .required('Payment txid is required')
-});
-const schema2 = yup.object().shape({
- proposalHash: yup.string()
- .test('len', 'Must be exactly 64 characters', val => val.length === 64)
- .required('proposal hash is required')
-});
-
/**
* Component to show the create Proposal form
* @component
@@ -46,8 +30,6 @@ function ProposalForm() {
//COMPONENT STATES
const [currentStep, setCurrentStep] = useState(0);
const [openModal, setOpenModal] = useState(false);
- const [collapse, setCollapse] = useState(true);
- const [useCollapse, setUseCollapse] = useState(false);
//PROPOSAL STATES
const [title, setTitle] = useState('');
@@ -61,21 +43,15 @@ function ProposalForm() {
const cancelSource = useMemo(() => axios.CancelToken.source(), []);
+ const onPaymentTxIdEntered = useCallback(() => {
+ setCurrentStep(prev => prev + 1); // Move to step 6 (submit proposal)
+ }, []);
+
const { enterPaymentTxId, enterProposalHash } = useProposalSubmission({
proposalUid,
history,
setSubmitCommand,
- setUseCollapse,
- setCollapse,
- });
-
- const {register, handleSubmit, errors} = useForm({
- mode: 'onSubmit',
- resolver: yupResolver(schema)
- });
- const {register: register2, handleSubmit: handleSubmit2, errors: errors2} = useForm({
- mode: 'onSubmit',
- resolver: yupResolver(schema2)
+ onPaymentTxIdEntered,
});
/**
@@ -179,10 +155,15 @@ function ProposalForm() {
* @function
*/
const continueProposal = () => {
- setCurrentStep(4);
if (submitCommand !== "") {
- setUseCollapse(true);
- setCollapse(false);
+ // If submit command exists, go to step 6 (submit)
+ setCurrentStep(5);
+ } else if (prepareCommand !== "") {
+ // If only prepare command exists, go to step 5 (prepare)
+ setCurrentStep(4);
+ } else {
+ // Otherwise go to step 5 (prepare) to start fresh
+ setCurrentStep(4);
}
setOpenModal(false);
}
@@ -200,8 +181,6 @@ function ProposalForm() {
confirmButtonText: 'Delete'
})
if (swalConfirm.isConfirmed) {
- setUseCollapse(false);
- setCollapse(true);
cancelCurrentProposal();
}
}
@@ -216,25 +195,12 @@ function ProposalForm() {
/**
* function to set next step of the proposal form
- * @function
+ * @function
*/
const next = () => {
setCurrentStep(currentStep + 1);
};
- /**
- * function that triggers sweet alert to show the copy is successful
- * @function
- */
- const copyButton = () => {
- swal.fire({
- icon: "success",
- title: "Copied",
- timer: 2000,
- showConfirmButton: false,
- });
- }
-
/**
* function that sets in the state the title from the input
* @function
@@ -371,122 +337,25 @@ function ProposalForm() {
- 5Create proposal
+ 5Prepare proposal
-
-
-
-
-
-
-
-
-
-
- Prepare command is ready to be copied. Please copy and paste it into Syscoin Q.T console for payment txid.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/* Disclaimer about waiting before go_submit */}
-
- Important: Please wait at least 5 minutes or 1 block confirmation after sending the payment transaction before running go_submit. Submitting too early may cause your proposal to fail.
-
-
-
-
-
-
-
-
-
- Submit command is ready to be copied. Please copy and paste it into Syscoin Q.T console to submit your proposal. This could take a couple minutes.
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+ 6Submit proposal
+
+
+
diff --git a/src/components/proposal/SubmitProposal.jsx b/src/components/proposal/SubmitProposal.jsx
new file mode 100644
index 00000000..e38f9c03
--- /dev/null
+++ b/src/components/proposal/SubmitProposal.jsx
@@ -0,0 +1,105 @@
+import React from 'react';
+import {CopyToClipboard} from 'react-copy-to-clipboard';
+import {useForm} from 'react-hook-form';
+import {ErrorMessage} from '@hookform/error-message';
+import {yupResolver} from '@hookform/resolvers';
+import * as yup from 'yup';
+import swal from 'sweetalert2';
+
+const schema = yup.object().shape({
+ proposalHash: yup.string()
+ .test('len', 'Must be exactly 64 characters', val => val && val.length === 64)
+ .required('proposal hash is required')
+});
+
+/**
+ * Component to show the submit proposal step (Step 6)
+ * @component
+ * @subcategory Proposal
+ * @example
+ * return (
+ *
+ * )
+ */
+function SubmitProposal({ submitCommand, onSubmit, onCancel }) {
+ const {register, handleSubmit, errors} = useForm({
+ mode: 'onSubmit',
+ resolver: yupResolver(schema)
+ });
+
+ /**
+ * function that triggers sweet alert to show the copy is successful
+ * @function
+ */
+ const copyButton = () => {
+ swal.fire({
+ icon: 'success',
+ title: 'Copied',
+ timer: 2000,
+ showConfirmButton: false,
+ });
+ };
+
+ return (
+
+
+ {/* Disclaimer about waiting before go_submit */}
+
+ Important: Please wait at least 5 minutes or 1 block confirmation after sending the payment transaction before running go_submit. Submitting too early may cause your proposal to fail.
+
+
+
+
+
+
+
+
+
+ Submit command is ready to be copied. Please copy and paste it into Syscoin Q.T console to submit your proposal. This could take a couple minutes.
+