Skip to content

Commit

Permalink
Fix add rfp and clean local state after RFP is submitted (#940)
Browse files Browse the repository at this point in the history
* fix add rfp

* fmt

* clean draft after rfp is submitted
  • Loading branch information
Megha-Dev-19 authored Sep 24, 2024
1 parent ea53bde commit 4ca0f3e
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,6 @@ useEffect(() => {
showRfpViewModal,
]);

useEffect(() => {
if (!timeline) {
setTimeline({
status: RFP_TIMELINE_STATUS.ACCEPTING_SUBMISSIONS,
});
}
}, [RFP_TIMELINE_STATUS]);

const InputContainer = ({ heading, description, children }) => {
return (
<div className="d-flex flex-column gap-1 gap-sm-2 w-100">
Expand All @@ -401,6 +393,10 @@ const InputContainer = ({ heading, description, children }) => {
);
};

function cleanDraft() {
Storage.privateSet(draftKey, null);
}

// show RFP created after txn approval for popup wallet
useEffect(() => {
if (isTxnCreated) {
Expand All @@ -413,6 +409,7 @@ useEffect(() => {
typeof oldRfpData === "object" &&
JSON.stringify(editRfpData) !== JSON.stringify(oldRfpData)
) {
cleanDraft();
setCreateTxn(false);
setRfpId(editRfpData.id);
setShowRfpViewModal(true);
Expand All @@ -430,6 +427,7 @@ useEffect(() => {
Array.isArray(rfpIdsArray) &&
rfpIds.length !== rfpIdsArray.length
) {
cleanDraft();
setCreateTxn(false);
setRfpId(rfpIds[rfpIds.length - 1]);
setShowRfpViewModal(true);
Expand Down Expand Up @@ -464,8 +462,8 @@ useEffect(() => {
transaction_method_name == "edit_rfp";

if (is_edit_or_add_rfp_transaction) {
cleanDraft();
setShowRfpViewModal(true);
Storage.privateSet(draftKey, null);
}
// show the latest created rfp to user
if (transaction_method_name == "add_rfp") {
Expand Down Expand Up @@ -511,7 +509,10 @@ const onSubmit = () => {
description: description,
summary: summary,
submission_deadline: getTimestamp(submissionDeadline),
timeline: timeline ?? RFP_TIMELINE_STATUS.ACCEPTING_SUBMISSIONS,
timeline:
Object.keys(timeline || {}).length > 0
? timeline
: { status: RFP_TIMELINE_STATUS.ACCEPTING_SUBMISSIONS },
};
const args = { labels: (labels ?? []).map((i) => i.value), body: body };
if (isEditPage) {
Expand All @@ -528,10 +529,6 @@ const onSubmit = () => {
]);
};

function cleanDraft() {
Storage.privateSet(draftKey, null);
}

if (loading) {
return (
<div
Expand Down

0 comments on commit 4ca0f3e

Please sign in to comment.