From f5a6c6ffb670929ee82994d8ec01e16ffb84770e Mon Sep 17 00:00:00 2001 From: Jared Date: Tue, 31 Jan 2023 20:57:18 -0500 Subject: [PATCH] Componentized a common control --- src/components/ModifyWithConfirmation.vue | 63 +++++++++++++ src/views/FundView.vue | 108 +++++++--------------- 2 files changed, 95 insertions(+), 76 deletions(-) create mode 100644 src/components/ModifyWithConfirmation.vue diff --git a/src/components/ModifyWithConfirmation.vue b/src/components/ModifyWithConfirmation.vue new file mode 100644 index 0000000..1d45afe --- /dev/null +++ b/src/components/ModifyWithConfirmation.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/views/FundView.vue b/src/views/FundView.vue index 1ac3bed..06c1555 100644 --- a/src/views/FundView.vue +++ b/src/views/FundView.vue @@ -155,21 +155,13 @@
-
-
- -
-
- -
-
+
Submit Group Fund -
-
- -
-
- -
-
+
Close Group Fund
-
-
- -
-
- -
-
+
@@ -258,6 +230,7 @@ import { submitRewardFund, } from '@/api/composed'; import Decimal from 'decimal.js'; +import ModifyWithConfirmation from '@/components/ModifyWithConfirmation.vue'; const route = useRoute(); const router = useRouter(); @@ -437,23 +410,25 @@ const selectContribution = (contribution: SelectableContribution) => { }; const allowDelete = ref(false); +const allowDistribution = ref(false); +const allowSubmit = ref(false); +const setAllowDelete = (val: boolean) => { + allowDelete.value = val; +}; +const setAllowDistribution = (val: boolean) => { + allowDistribution.value = val; +}; +const setAllowSubmit = (val: boolean) => { + allowSubmit.value = val; +}; + const deleteFund = async () => { const deleted = await deleteRewardFund(identifier, allowDelete.value); if (deleted && deleted.success) { await router.push('/'); } }; -const delTimeout = ref(undefined as number | undefined); - -watch(allowDelete, () => { - if (delTimeout.value) window.clearTimeout(delTimeout.value); - delTimeout.value = window.setTimeout(() => { - allowDelete.value = false; - delTimeout.value = undefined; - }, 10000); -}); -const allowDistribution = ref(false); const distributeFund = async () => { const distributed = await distributeRewardFund( identifier, @@ -467,32 +442,13 @@ const distributeFund = async () => { console.log('distributed'); // TODO: provide feedback for distribution } }; -const distTimeout = ref(undefined as number | undefined); - -watch(allowDistribution, () => { - if (distTimeout.value) window.clearTimeout(distTimeout.value); - distTimeout.value = window.setTimeout(() => { - allowDistribution.value = false; - distTimeout.value = undefined; - }, 10000); -}); -const allowSubmit = ref(false); const submitFund = async () => { const submitted = await submitRewardFund(identifier, allowSubmit.value); if (submitted && submitted.success) { console.log('submitted'); // TODO: provide feedback for submission } }; -const subTimeout = ref(undefined as number | undefined); - -watch(allowSubmit, () => { - if (subTimeout.value) window.clearTimeout(subTimeout.value); - subTimeout.value = window.setTimeout(() => { - allowSubmit.value = false; - subTimeout.value = undefined; - }, 10000); -}); const errs: SignetError[] = [ {