Skip to content

Commit

Permalink
new: add transaction confirmation screen after sending money and on a…
Browse files Browse the repository at this point in the history
…ll past transaction
  • Loading branch information
SeddikKadi committed Jul 26, 2023
1 parent 711e83b commit be11500
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 54 deletions.
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 135 additions & 0 deletions src/components/ConfirmPaymentModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<template>
<div class="modal is-active">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title is-title-shrink">
{{
{
transactionDetail: $gettext("Transaction details"),
paymentConfirmation: $gettext("Payment confirmation"),
}[$modal.args?.value[0].type]
}}
</p>
<button
class="delete"
aria-label="close"
@click="$modal.close()"
></button>
</header>

<section class="modal-card-body">
<div class="body-content is-size-4">
<p class="custom-card-title has-text-weight-bold">
{{
{
transactionDetail: $modal.args?.value[0].transaction.pending
? $gettext("Transaction sent")
: $gettext("Transaction processed"),
paymentConfirmation: $gettext("Payment sent"),
}[$modal.args?.value[0].type]
}}
</p>
<div class="confirm-icon-container">
<fa-icon icon="fa-check" class="confirm-icon fa-thin" />
</div>

<p
class="
amount
custom-card-destinataire
has-text-weight-bold
is-size-4
"
>
{{
((t) =>
t.amount < 0
? $gettext("Sent %{amount}", {
amount: `${numericFormat(-t.amount)} ${t.currency}`,
})
: $gettext("Received %{amount}", {
amount: `${numericFormat(t.amount)} ${t.currency}`,
}))($modal.args?.value[0].transaction)
}}
</p>

<h2 class="frame3-sub-title">
{{
$modal.args?.value[0].transaction.amount < 0
? $gettext("to")
: $gettext("from")
}}
</h2>
<p
class="
frame3-sub-title
has-text-weight-bold
is-size-3
hide-overflow
"
>
{{ $modal.args?.value[0].transaction.related }}
</p>

<p class="frame3-sub-title mb-3">
{{ dateFormat }}
</p>
</div>
</section>
<footer
class="
modal-card-foot
custom-modal-card-foot
is-justify-content-flex-end
"
>
<button
class="button custom-button-modal has-text-weight-medium"
:title="$gettext('Ok')"
@click="$modal.close()"
>
<span>{{ $gettext("Ok") }}</span>
</button>
</footer>
</div>
</div>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component"
import { mapGetters } from "vuex"
import moment from "moment"

@Options({
name: "ConfirmPaymentModal",
computed: {
...mapGetters(["numericFormat"]),
dateFormat() {
return moment(
this.$modal.args?.value[0].transaction.date.toString()
).format("YYYY-MM-DD HH:mm:ssZ")
},
},
})
export default class ConfirmPaymentModal extends Vue {}
</script>
<style lang="scss" scoped>
@import "../assets/custom-variables";

.confirm-icon-container {
width: fit-content;
margin: auto;
}
.confirm-icon {
font-size: 4em;
color: $color-2;
}
.body-content {
text-align: center;
}
.hide-overflow {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
2 changes: 2 additions & 0 deletions src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import MoneyCreditModal from "./MoneyCreditModal.vue"
import AboutModal from "./AboutModal.vue"
import TransactionListModal from "./TransactionListModal.vue"
import ConfirmPaymentModal from "./ConfirmPaymentModal.vue"
@Options({
name: "Modal",
Expand All @@ -16,6 +17,7 @@
MoneyCreditModal,
AboutModal,
TransactionListModal,
ConfirmPaymentModal,
},
data() {
return {
Expand Down
25 changes: 18 additions & 7 deletions src/components/MoneyTransferModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
balance: false,
amount: false,
},
account: null,
}
},
created() {
Expand All @@ -249,6 +250,7 @@
} else {
account = account._obj.parent
}
this.account = account
const backend = account.parent
this.recipientBatchLoader = UseBatchLoading({
Expand Down Expand Up @@ -315,9 +317,11 @@
}
// This to ensure we are left with 2 decimals only
this.amount = parseFloat(this.amount).toFixed(2)
let dateBegin = Date.now()
let payment
try {
this.$store.commit("setRequestLoadingAfterCreds", true)
await this.selectedRecipient.transfer(
payment = await this.selectedRecipient.transfer(
this.amount.toString(),
this.message
)
Expand Down Expand Up @@ -356,17 +360,17 @@
return
} finally {
this.transferOngoing = false
this.$loading.hide()
this.$store.commit("setRequestLoadingAfterCreds", false)
}
this.$loading.hide()
this.errors.balance = false
this.errors.amount = false
this.close(true)
this.$msg.success(
this.$gettext("Payment issued to %{ name }", {
name: this.selectedRecipient.name,
})
)
this.$modal.open("ConfirmPaymentModal", {
transaction: payment,
type: "paymentConfirmation",
})
if (!this.selectedRecipient.is_favorite) {
this.$dialog
.show({
Expand Down Expand Up @@ -399,6 +403,13 @@
}
await this.$store.dispatch("fetchAccounts")
},
wait(ms: number): Promise<void> {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, ms)
})
},
close(refreshTransactions: any = false) {
this.searchName = ""
this.amount = 0
Expand Down
6 changes: 4 additions & 2 deletions src/components/TransactionItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="pb-3 pt-3">
<div class="pb-3 pt-3 shadow-bottom">
<div class="is-pulled-right">
<h5 class="custom-card-destinataire has-text-right">
{{ dateFormat(transaction.date) }}
Expand Down Expand Up @@ -32,7 +32,6 @@
</h5>
</div>
</div>
<span class="custom-line-separator has-background-white-ter mb-2 mt-1"></span>
</template>

<script lang="ts">
Expand Down Expand Up @@ -82,4 +81,7 @@
.status .fa-check {
color: $color-2;
}
.shadow-bottom {
box-shadow: 0 3px 6px -6px black;
}
</style>
6 changes: 6 additions & 0 deletions src/components/TransactionListRecent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
v-for="transaction in transactions"
:key="transaction"
:transaction="transaction"
@click="
$modal.open('ConfirmPaymentModal', {
transaction,
type: 'transactionDetail',
})
"
/>
<div v-if="transactions.length" class="has-text-centered mt-5">
<button
Expand Down
Loading

0 comments on commit be11500

Please sign in to comment.