Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1751 - Dismissing a payment causes user to get banned #1759

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 2 additions & 37 deletions frontend/views/containers/payments/PaymentRowTodo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,20 @@

template(slot='cellActions')
.cpr-date(:class='payment.isLate ? "pill is-danger" : "has-text-1"') {{ humanDate(payment.date) }}
payment-actions-menu
menu-item(
tag='button'
item-id='message'
icon='times'
@click='cancelPayment'
)
i18n Dismiss this payment
</template>

<script>
import sbp from '@sbp/sbp'
import { mapGetters } from 'vuex'
import { humanDate } from '@model/contracts/shared/time.js'
import { MenuItem } from '@components/menu/index.js'
import { PAYMENT_CANCELLED, PAYMENT_NOT_RECEIVED } from '@model/contracts/shared/payments/index.js'
import { L } from '@common/common.js'
import { PAYMENT_NOT_RECEIVED } from '@model/contracts/shared/payments/index.js'
import PaymentRow from './payment-row/PaymentRow.vue'
import PaymentActionsMenu from './payment-row/PaymentActionsMenu.vue'
import PaymentNotReceivedTooltip from './payment-row/PaymentNotReceivedTooltip.vue'

export default ({
name: 'PaymentRowTodo',
components: {
MenuItem,
PaymentActionsMenu,
PaymentNotReceivedTooltip,
PaymentRow
},
Expand All @@ -80,34 +68,11 @@ export default ({
wasNotReceived () {
const { data } = this.payment
return data && data.status === PAYMENT_NOT_RECEIVED
},
hash () {
return this.payment?.hash
}
},
methods: {
humanDate,
// TODO: make multiple payments
async cancelPayment () {
try {
if (this.hash) {
await sbp('gi.actions/group/paymentUpdate', {
contractID: this.$store.state.currentGroupId,
data: {
paymentHash: this.hash,
updatedProperties: {
status: PAYMENT_CANCELLED
}
}
})
} else {
alert(L("Cannot dismiss a payment that hasn't been sent yet."))
}
} catch (e) {
console.error(e)
alert(e.message)
}
},
select () {
this.form.checked = true
},
Expand All @@ -118,7 +83,7 @@ export default ({
watch: {
'form.checked' (checked) {
this.$emit('change', {
hash: this.hash,
hash: this.payment?.hash,
checked
})
}
Expand Down