Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Jan 24, 2025
1 parent 45c035f commit db45aee
Show file tree
Hide file tree
Showing 9 changed files with 1,090 additions and 22 deletions.
4 changes: 4 additions & 0 deletions src/components/modals/BuyOptionsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<script lang="ts">
import { computed, defineComponent, onMounted, ref } from '@vue/composition-api';
import { PageBody, FiatAmount, CircleSpinner } from '@nimiq/vue-components';
import { useDemoStore } from '@/stores/Demo';
import Modal from './Modal.vue';
import CountrySelector from '../CountrySelector.vue';
import CountryFlag from '../CountryFlag.vue';
Expand Down Expand Up @@ -234,13 +235,16 @@ export default defineComponent({
const country = ref<Country>(null);
const { isDemoEnabled } = useDemoStore();
const isMoonpayAvailable = computed(() => { // eslint-disable-line arrow-body-style
if (isDemoEnabled.value) return true;
if (!config.moonpay.enabled) return false;
if (!country.value) return true;
return MOONPAY_COUNTRY_CODES.includes(country.value.code);
});
const isSimplexAvailable = computed(() => { // eslint-disable-line arrow-body-style
if (isDemoEnabled.value) return true;
if (!config.simplex.enabled) return false;
if (!country.value) return true;
return SIMPLEX_COUNTRY_CODES.includes(country.value.code);
Expand Down
3 changes: 2 additions & 1 deletion src/components/modals/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ const Modal = defineComponent({
while (context.root.$route.matched.find((routeRecord) => 'modal' in routeRecord.components
|| 'persistent-modal' in routeRecord.components
|| Object.values(routeRecord.components).some((component) => /modal/i.test(component.name || '')))
|| Object.values(routeRecord.components).some((component) => /modal/i.test(
'name' in component ? component.name as string : '')))
) {
context.root.$router.back();
Expand Down
146 changes: 146 additions & 0 deletions src/components/modals/demos/DemoModalBuy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<template>
<Modal :showOverlay="showOverlay">
<PageHeader class="flex-column">
<h1 class="nq-h1">{{ $t('Buy NIM') }}</h1>
<div class="demo-warning nq-label">
{{ $t('DEMO') }}
</div>
</PageHeader>
<PageBody>
<div class="flex-row">

<AmountInput v-model="amount" :decimals="5">
<AmountMenu slot="suffix" class="ticker" currency="nim" :open="amountMenuOpened"
:activeCurrency="activeCurrency" :fiatCurrency="fiatCurrency" :feeOption="false"
:otherFiatCurrencies="otherFiatCurrencies"
@click.native.stop="amountMenuOpened = !amountMenuOpened"
/>
</AmountInput>
</div>
</PageBody>
<PageFooter>
<button class="nq-button light-blue" @click="buyDummyNim" :disabled="!amount">
{{ $t('Buy NIM') }}
</button>
</PageFooter>

<PageBody slot="overlay" class="overlay-content">
<HighFiveIcon />
<h2 class="nq-h2">
{{ $t('Your NIM is under its way!') }}
</h2>
<p>
{{ $t('This transaction is instant and secure.') }}
</p>
</PageBody>
</Modal>
</template>

<script lang="ts">
import { computed, defineComponent, ref } from '@vue/composition-api';
import { PageBody, PageHeader, PageFooter } from '@nimiq/vue-components';
import AmountInput from '@/components/AmountInput.vue';
import AmountMenu from '@/components/AmountMenu.vue';
import Modal from '@/components/modals/Modal.vue';
import { useAccountStore } from '@/stores/Account';
import { useFiatStore } from '@/stores/Fiat';
import { FIAT_CURRENCIES_OFFERED } from '@/lib/Constants';
// import { useTransactionsStore } from '@/stores/Transactions';
import { useDemoStore } from '@/stores/Demo';
import { useRouter } from '@/router';
import HighFiveIcon from '@/components/icons/HighFiveIcon.vue';
// import { useAddressStore } from '@/stores/Address';
export default defineComponent({
setup() {
const { activeCurrency } = useAccountStore();
const { currency: fiatCurrency } = useFiatStore();
const otherFiatCurrencies = computed(() =>
FIAT_CURRENCIES_OFFERED.filter((fiat) => fiat !== fiatCurrency.value));
const amount = ref(0);
const amountMenuOpened = ref(false);
const showOverlay = ref(false);
const router = useRouter();
// const { activeAddressInfo } = useAddressStore();
// const maxSendableAmount = computed(() => Math.max((activeAddressInfo.value!.balance || 0), 0));
// const sendMax = () => amount.value = maxSendableAmount.value;
function buyDummyNim() {
useDemoStore().buyDemoNim(amount.value);
showOverlay.value = true;
setTimeout(() => {
showOverlay.value = false;
router.push('/');
}, 4000);
}
return {
amount,
activeCurrency,
fiatCurrency,
otherFiatCurrencies,
amountMenuOpened,
buyDummyNim,
showOverlay,
// sendMax,
};
},
components: {
Modal,
AmountInput,
AmountMenu,
PageHeader,
PageBody,
PageFooter,
HighFiveIcon,
},
});
</script>

<style scoped lang="scss">
.small-page {
> .page-header {
overflow: hidden;
.demo-warning {
margin: 0;
text-align: center;
position: absolute;
top: 0;
left: 0;
right: 0;
background: var(--nimiq-orange-bg);
color: white;
padding: 0.5rem 0;
}
}
}
::v-deep .nq-card.overlay {
background: var(--nimiq-green);
color: white;
.overlay-content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
svg {
width: 128px;
height: 128px;
}
p {
margin-top: 0;
text-wrap: pretty;
}
}
.close-button {
display: none;
}
}
</style>
35 changes: 35 additions & 0 deletions src/components/modals/demos/DemoModalFallback.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<Modal>
<PageHeader class="flex-column">
<h1 class="nq-h1">{{ $t('Nimiq Demo') }}</h1>
</PageHeader>
<PageBody>
<p class="nq-p">
{{ $t('This is not a real Nimiq Wallet. It is just a demo so it is limited in functionality.') }}
</p>
<p>
{{ $t('You can open a free NIM account in less than a minute.') }}
</p>
</PageBody>
<PageFooter>
<a href="https://wallet.nimiq.com" target="_blank" class="nq-button light-blue">
{{ $t('Open Nimiq Wallet') }}
</a>
</PageFooter>
</Modal>
</template>

<script lang="ts">
import { defineComponent } from '@vue/composition-api';
import { PageBody, PageHeader, PageFooter } from '@nimiq/vue-components';
import Modal from '../Modal.vue';
export default defineComponent({
components: {
Modal,
PageHeader,
PageBody,
PageFooter,
},
});
</script>
4 changes: 2 additions & 2 deletions src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { WELCOME_MODAL_LOCALSTORAGE_KEY, WELCOME_STAKING_MODAL_LOCALSTORAGE_KEY
import { usePwaInstallPrompt } from './composables/usePwaInstallPrompt';
import type { SetupSwapWithKycResult, SWAP_KYC_HANDLER_STORAGE_KEY } from './swap-kyc-handler'; // avoid bundling
import type { RelayServerInfo } from './lib/usdc/OpenGSN';
import { HubApiMock, isPlaygroundEnabled } from './stores/Playground';
import { DemoHubApi, checkIfDemoIsActive } from './stores/Demo';

export function shouldUseRedirects(ignoreSettings = false): boolean {
if (!ignoreSettings) {
Expand Down Expand Up @@ -115,7 +115,7 @@ function getBehavior({

// We can't use the reactive config via useConfig() here because that one can only be used after the composition-api
// plugin has been registered in Vue 2.
const hubApi = new HubApi(Config.hubEndpoint);
const hubApi = checkIfDemoIsActive() ? DemoHubApi.create() : new HubApi(Config.hubEndpoint);

hubApi.on(HubApi.RequestType.ONBOARD, async (accounts) => {
const { config } = useConfig();
Expand Down
30 changes: 30 additions & 0 deletions src/i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ msgstr ""
msgid "Buy more here in the wallet."
msgstr ""

#: src/components/modals/demos/DemoModalBuy.vue:23
#: src/components/modals/demos/DemoModalBuy.vue:4
#: src/components/TransactionList.vue:56
#: src/components/TransactionList.vue:66
msgid "Buy NIM"
Expand Down Expand Up @@ -894,6 +896,10 @@ msgstr ""
msgid "Delete validator"
msgstr ""

#: src/components/modals/demos/DemoModalBuy.vue:6
msgid "DEMO"
msgstr ""

#: src/components/modals/BuyOptionsModal.vue:10
msgid ""
"Depending on your country of residence,\n"
Expand Down Expand Up @@ -1650,6 +1656,10 @@ msgstr ""
msgid "NIM network fee"
msgstr ""

#: src/components/modals/demos/DemoModalFallback.vue:4
msgid "Nimiq Demo"
msgstr ""

#: src/components/modals/DisclaimerModal.vue:16
msgid "Nimiq is not responsible for any loss. Nimiq, wallet.nimiq.com, hub.nimiq.com & keyguard.nimiq.com, and some of the underlying libraries are under active development."
msgstr ""
Expand Down Expand Up @@ -1780,6 +1790,10 @@ msgstr ""
msgid "One Account, many Addresses"
msgstr ""

#: src/components/modals/demos/DemoModalFallback.vue:16
msgid "Open Nimiq Wallet"
msgstr ""

#: src/components/modals/BtcActivationModal.vue:14
msgid "Or buy BTC directly in the wallet."
msgstr ""
Expand Down Expand Up @@ -2786,6 +2800,10 @@ msgstr ""
msgid "This is a single-use address"
msgstr ""

#: src/components/modals/demos/DemoModalFallback.vue:8
msgid "This is not a real Nimiq Wallet. It is just a demo so it is limited in functionality."
msgstr ""

#: src/components/BtcAddressInput.vue:30
msgid "This is not a valid address"
msgstr ""
Expand Down Expand Up @@ -2873,6 +2891,10 @@ msgstr ""
msgid "This swap is as decentralized as the blockchain itself."
msgstr ""

#: src/components/modals/demos/DemoModalBuy.vue:33
msgid "This transaction is instant and secure."
msgstr ""

#: src/components/swap/SwapAnimation.vue:312
msgid "This usually takes {time} seconds."
msgstr ""
Expand Down Expand Up @@ -3159,6 +3181,10 @@ msgstr ""
msgid "You can now choose{linebreak}between USDC and USDT"
msgstr ""

#: src/components/modals/demos/DemoModalFallback.vue:11
msgid "You can open a free NIM account in less than a minute."
msgstr ""

#: src/components/PolygonWarningFooter.vue:9
msgid "You can receive from Polygon {ticker} addresses only!"
msgstr ""
Expand Down Expand Up @@ -3262,6 +3288,10 @@ msgstr ""
msgid "Your NIM are stored in a legacy account. Transfer them to a regular account to profit from new features."
msgstr ""

#: src/components/modals/demos/DemoModalBuy.vue:30
msgid "Your NIM is under its way!"
msgstr ""

#: src/lib/GoCrypto.ts:244
msgid "Your payment failed"
msgstr ""
Expand Down
Loading

0 comments on commit db45aee

Please sign in to comment.