Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
erfanmola committed Oct 9, 2023
1 parent cc9bc30 commit 575e024
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 7 deletions.
3 changes: 3 additions & 0 deletions webApp/src/i18n/lang-ar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const i18n_ar = {
buttons: {
import: "استيراد المحفظة",
create: "إنشاء محفظة"
},
toast: {
wallet_created: 'تم إنشاء المحفظة بنجاح'
}
},
settings: {
Expand Down
3 changes: 3 additions & 0 deletions webApp/src/i18n/lang-de.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const i18n_de = {
buttons: {
import: "Brieftasche importieren",
create: "Brieftasche erstellen"
},
toast: {
wallet_created: 'Brieftasche erfolgreich erstellt'
}
},
settings: {
Expand Down
5 changes: 4 additions & 1 deletion webApp/src/i18n/lang-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const i18n_en = {
buttons: {
import: "Import Wallet",
create: "Create Wallet"
}
},
toast: {
wallet_created: 'Wallet created successfully'
},
},
settings: {
language: {
Expand Down
3 changes: 3 additions & 0 deletions webApp/src/i18n/lang-fa.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const i18n_fa = {
buttons: {
import: 'وارد کردن کیف پول',
create: 'ایجاد کیف پول',
},
toast: {
wallet_created: 'کیف پول با موفقیت ایجاد شد'
}
},
settings: {
Expand Down
3 changes: 3 additions & 0 deletions webApp/src/i18n/lang-fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const i18n_fr = {
buttons: {
import: "Importer le portefeuille",
create: "Créer un portefeuille"
},
toast: {
wallet_created: 'Portefeuille créé avec succès'
}
},
settings: {
Expand Down
3 changes: 3 additions & 0 deletions webApp/src/i18n/lang-tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const i18n_tr = {
buttons: {
import: "Cüzdanı İçe Aktar",
create: "Cüzdan Oluştur"
},
toast: {
wallet_created: 'Cüzdan başarıyla oluşturuldu'
}
},
settings: {
Expand Down
12 changes: 8 additions & 4 deletions webApp/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@
onMounted(async () => {
let data = await Utils.DPXSendRequest(`/balance/${ wallet.value }`, [], 'GET', i18nLocale);
if (wallet.value) {
if (data && `result` in data && data.status === 'success') {
let data = await Utils.DPXSendRequest(`/balance/${ wallet.value }`, [], 'GET', i18nLocale);
balance.value = data.result;
rank.value = ranks.data.filter((item) => (item.min <= balance.value)).slice(-1)[0];
if (data && `result` in data && data.status === 'success') {
balance.value = data.result;
rank.value = ranks.data.filter((item) => (item.min <= balance.value)).slice(-1)[0];
}
}
Expand Down
49 changes: 47 additions & 2 deletions webApp/src/views/Login.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup>
import { inject } from 'vue';
import { inject, ref } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from "vue-i18n";
import WebApp from '@twa-dev/sdk';
import Utils from '../utils';
import CreditIcon from '../assets/images/credit.svg';
const router = useRouter();
Expand All @@ -14,6 +16,49 @@
// Set i18n locale based on the user's locale provided by <LocaleProvider>
i18nLocale.locale.value = localStorage.getItem('dpxwallet_locale') || inject('locale', 'en');
const creating_wallet = ref(false);
const createWallet = async () => {
if (!(creating_wallet.value)) {
creating_wallet.value = true;
WebApp.HapticFeedback.impactOccurred('medium');
let result = await Utils.DPXSendRequest('/generate', {}, 'POST', i18nLocale);
if (result) {
WebApp.HapticFeedback.notificationOccurred('success');
Utils.PlayAudio('Success.mp3');
Utils.SetWallet(result.result.wallet.toString().toLowerCase(), result.result.secret.toString().toLowerCase());
Utils.Toast(i18nLocale.t('login.toast.wallet_created'));
setTimeout(() => { router.push('/'); }, 2000);
} else {
WebApp.HapticFeedback.notificationOccurred('error');
Utils.PlayAudio('Failed.mp3');
}
}
};
// If user has wallet, redirect to home
if (Utils.GetWallet('wallet')) {
router.push('/');
}
WebApp.BackButton.hide();
</script>

Expand Down Expand Up @@ -43,7 +88,7 @@

<ul>
<li @click="router.push('/wallet/import')" class="w550-dots-1 button">{{ $t('login.buttons.import') }}</li>
<li @click="router.push('/wallet/create')" class="w550-dots-1 button secondary">{{ $t('login.buttons.create') }}</li>
<li @click="createWallet" class="w550-dots-1 button secondary">{{ $t('login.buttons.create') }}</li>
</ul>
</section>
</template>
Expand Down

0 comments on commit 575e024

Please sign in to comment.