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

Refactoring #399

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import TransactionListModal from "./TransactionListModal.vue"
import ConfirmPaymentModal from "./ConfirmPaymentModal.vue"
import QrCodeModal from "./QrCodeModal.vue"
import MoneyRequestModal from "./MoneyRequestModal.vue"

@Options({
name: "Modal",
Expand All @@ -20,6 +21,7 @@
TransactionListModal,
ConfirmPaymentModal,
QrCodeModal,
MoneyRequestModal,
},
data() {
return {
Expand Down
236 changes: 236 additions & 0 deletions src/components/MoneyRequestModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<template>
<div class="modal is-active">
<div class="modal-background"></div>
<template v-if="$modal.step.value == 1">
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title is-title-shrink">
{{ $gettext("Request money") }} - 1/2
</p>
<button class="delete" aria-label="close" @click="close()"></button>
</header>
<section class="modal-card-body">
<MoneyTransaction
directionTransfer="receive"
:account="$modal.args.value[0].account"
:selectedRecipient="selectedRecipient"
:config="config"
@update:amount="(x) => (amount = x)"
@update:message="(x) => (message = x)"
@update:isValid="(x) => (isValid = x)"
/>
</section>
<footer
class="
modal-card-foot
custom-modal-card-foot
is-justify-content-flex-end
"
>
<button
:disabled="!isValid"
class="button custom-button-modal has-text-weight-medium"
id="send-money-button"
@click="$modal.next()"
>
{{ $gettext("Generate QrCode") }}
</button>
</footer>
</div>
</template>
<template v-if="$modal.step.value == 2">
<div class="modal-card">
<header class="modal-card-head">
<span class="is-flex is-flex-shrink-0">
<a class="mr-3 is-flex" @click="$modal.back()">
<span class="icon has-text-white">
<fa-icon icon="arrow-left" class="fa-lg" />
</span>
</a>
</span>
<p class="modal-card-title is-title-shrink">
{{ $gettext("Request money") }} - 2/2
</p>
<button class="delete" aria-label="close" @click="close()"></button>
</header>
<section class="modal-card-body">
<div class="qrcode-container" ref="qrCode">
<QrCodeVue
render-as="svg"
:size="200"
:value="
JSON.stringify({
rp: userProfile.id,
rpb: $modal.args.value[0].account.id,
amount: amount,
message: message,
})
"
/>
</div>
<p class="has-text-centered is-size-4 mt-2">
{{ $gettext("Please scan the QR code above to proceed") }}
</p>
</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"
id="send-money-button"
@click="$modal.close()"
>
{{ $gettext("Close") }}
</button>
</footer>
</div>
</template>
</div>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component"
import { mapModuleState } from "@/utils/vuex"
import { e as LokapiExc } from "@lokavaluto/lokapi-browser"

import Loading from "vue-loading-overlay"
import "vue-loading-overlay/dist/css/index.css"
import RecipientItem from "@/components/RecipientItem.vue"
import BankAccountItem from "@/components/BankAccountItem.vue"
import { Capacitor } from "@capacitor/core"
import { App as CapacitorApp } from "@capacitor/app"
import { Camera, CameraResultType } from "@capacitor/camera"
import { UIError } from "../exception"
import { makeUIProxyBackend } from "@/services/lokapiService"
import QrCodeVue from "qrcode.vue"
import MoneyTransaction from "@/components//MoneyTransaction.vue"
import UseBatchLoading from "@/services/UseBatchLoading"

@Options({
name: "MoneyRequestModal",
components: {
Loading,
RecipientItem,
BankAccountItem,
QrCodeVue,
MoneyTransaction,
},
data() {
return {
amount: null,
message: null,
isValid: false,
config: {},
}
},
computed: {
...mapModuleState("lokapi", ["userProfile"]),
},
watch: {
message: {
handler(newVal, oldVal) {
this.config.message = newVal
},
},
amount: {
handler(newVal, oldVal) {
this.config.amount = newVal
},
},
},
methods: {
close() {
this.amount = 0
this.$modal.close()
},
setFocus(refLabel: string) {
this.$nextTick(() => {
const ref = this.$refs[refLabel]
ref.focus()
ref.select()
})
},
},
})
export default class MoneyRequestModal extends Vue {}
</script>
<style lang="scss" scoped>
@import "@/assets/custom-variables";

.search-area {
background: #f0faf9;
}
.button.action {
white-space: normal;
height: auto;
}
.card-recipient-wrapper {
width: 90%;
}
.favorit-icon-wrapper {
width: 10%;
}
.modal-card-body {
min-height: 120px;
}
.loader-container {
position: relative;
height: 80px;
}
.amount-currency-symbol {
margin: auto;
font-size: 1.25em;
font-weight: bold;
line-height: 1em;
padding-bottom: calc(0.5em - 1px);
padding-left: calc(0.75em - 1px);
padding-right: calc(0.75em - 1px);
padding-top: calc(0.5em - 1px);
}
.w-100 {
width: 100%;
}
.custom-search-bar {
margin: auto;
}
.search-bar-container {
width: 75%;
}
.qrcode-icon {
font-size: 1.5em;
opacity: 0.8;
padding: 0.1em;
border: 0.2em solid #e8e8e8;
border-radius: 5px;
}
.custom-search-bar input {
background: #ffffff;
border: 1px solid #e8e8e8;
border-radius: 24px;
width: 100% !important;
}

.custom-pictogram-search svg {
width: 24px !important;
height: 24px !important;
}

.custom-pictogram-search path,
rect {
fill: $color-2 !important;
background: $color-2 !important;
}

.custom-button-pictogram {
background-color: inherit !important;
border: none;
cursor: pointer;
}
.qrcode-container {
width: fit-content;
margin: auto;
}
</style>
Loading
Loading