Skip to content

Commit

Permalink
fix: routes restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 committed Dec 22, 2023
1 parent 310f6de commit 0f74e18
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 268 deletions.
6 changes: 3 additions & 3 deletions components/header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<div class="links-container">
<NuxtLink
class="link-item"
:to="{ name: 'bridge' }"
:class="{ 'router-link-exact-active': route.name === 'bridge-withdraw' }"
:to="{ name: 'index' }"
:class="{ 'router-link-exact-active': route.name === 'withdraw' }"
>
<ArrowsUpDownIcon class="link-icon" aria-hidden="true" />
Bridge
</NuxtLink>
<NuxtLink class="link-item" :to="{ name: 'index' }">
<NuxtLink class="link-item" :to="{ name: 'assets' }">
<WalletIcon class="link-icon" aria-hidden="true" />
Assets
</NuxtLink>
Expand Down
4 changes: 2 additions & 2 deletions components/header/MobileMainNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

<TypographyCategoryLabel size="sm">Portal</TypographyCategoryLabel>
<CommonCardWithLineButtons>
<DestinationItem label="Bridge" as="RouterLink" :to="{ name: 'bridge' }" size="sm">
<DestinationItem label="Bridge" as="RouterLink" :to="{ name: 'index' }" size="sm">
<template #image>
<DestinationIconContainer>
<ArrowsUpDownIcon aria-hidden="true" />
</DestinationIconContainer>
</template>
</DestinationItem>
<DestinationItem label="Assets" as="RouterLink" :to="{ name: 'index' }" size="sm">
<DestinationItem label="Assets" as="RouterLink" :to="{ name: 'assets' }" size="sm">
<template #image>
<DestinationIconContainer>
<WalletIcon aria-hidden="true" />
Expand Down
2 changes: 1 addition & 1 deletion components/modal/transaction/DepositUnavailable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Deposit is not available on <span class="font-medium">{{ eraNetwork.name }}</span> since it doesn't have L1
network
</p>
<CommonButton as="RouterLink" :to="{ name: 'index' }" replace variant="primary" class="mt-4 w-full">
<CommonButton as="RouterLink" :to="{ name: 'assets' }" replace variant="primary" class="mt-4 w-full">
Go to Assets page
</CommonButton>
</CommonModal>
Expand Down
2 changes: 1 addition & 1 deletion components/modal/transaction/WithdrawalUnavailable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Withdrawal is not available on <span class="font-medium">{{ eraNetwork.name }}</span> since it doesn't have L1
network
</p>
<CommonButton as="RouterLink" :to="{ name: 'index' }" replace variant="primary" class="mt-4 w-full">
<CommonButton as="RouterLink" :to="{ name: 'assets' }" replace variant="primary" class="mt-4 w-full">
Go to Assets page
</CommonButton>
</CommonModal>
Expand Down
2 changes: 1 addition & 1 deletion error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="error-info-container">
<h1 class="error-status-code">{{ error.statusCode }}</h1>
<p class="error-message">{{ error.message }}</p>
<CommonButton as="RouterLink" :to="{ name: 'index' }" class="mt-4" variant="primary">Back to Portal</CommonButton>
<CommonButton as="RouterLink" :to="{ name: 'index' }" class="mt-4" variant="primary">Back to Bridge</CommonButton>
</div>
</div>
</template>
Expand Down
5 changes: 5 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**", "**/*.map"],
"rewrites": [
{
"source": "/",
"destination": "/bridge",
"type": "302"
},
{
"source": "**",
"destination": "/index.html"
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { portal as portalMeta } from "./data/meta";
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
app: {
baseURL: "/bridge",
head: {
htmlAttrs: {
lang: "en",
Expand Down
246 changes: 246 additions & 0 deletions pages/assets.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
<template>
<div>
<PageTitle>Assets</PageTitle>

<template v-if="!isConnected">
<ConnectWalletBlock>Connect wallet to view your balances on {{ eraNetwork.name }}</ConnectWalletBlock>
</template>
<template v-else>
<EcosystemBlock
v-if="eraNetwork.displaySettings?.showPartnerLinks && ecosystemBannerVisible"
show-close-button
class="mb-block-padding-1/2 sm:mb-block-gap"
/>
<CommonContentBlock class="mb-block-gap">
<div class="flex flex-col flex-wrap gap-block-gap sm:flex-row sm:items-center sm:justify-between">
<CommonTotalBalance :balance="balance" :loading="loading" :error="balanceError" />
<CommonButtonGroup v-if="!noBalances">
<CommonButton
variant="primary"
as="RouterLink"
:to="{
name: eraNetwork.l1Network ? 'receive-methods' : 'receive',
}"
>
<template #icon>
<ArrowDownLeftIcon aria-hidden="true" />
</template>
<template #default>Receive</template>
</CommonButton>
<CommonButton
variant="primary"
as="RouterLink"
:to="{ name: eraNetwork.l1Network ? 'send-methods' : 'send' }"
>
<template #icon>
<ArrowUpRightIcon aria-hidden="true" />
</template>
<template #default>Send</template>
</CommonButton>
</CommonButtonGroup>
</div>
</CommonContentBlock>

<template v-if="!noBalances">
<TypographyCategoryLabel>
<span>Balance</span>
<template #right>
<CommonButtonLabel as="RouterLink" variant="light" :to="{ name: 'balances' }">View all</CommonButtonLabel>
</template>
</TypographyCategoryLabel>
<CommonCardWithLineButtons>
<template v-if="loading">
<TokenBalanceLoader v-for="index in 2" :key="index" send-route-name />
</template>
<div v-else-if="balanceError" class="m-3 -mt-1 mb-2.5">
<CommonErrorBlock @try-again="fetch">
{{ balanceError.message }}
</CommonErrorBlock>
</div>
<template v-else-if="displayedBalances.length">
<TokenBalance
v-for="item in displayedBalances"
as="div"
:key="item.address"
show-name-link
:send-route-name="eraNetwork.l1Network ? 'send-methods' : 'send'"
v-bind="item"
/>
</template>
<template v-else>
<CommonEmptyBlock class="mx-3 mb-3 mt-1">
<div class="wrap-balance">
You don't have any balances on
<span class="font-medium">{{ destinations.era.label }}</span>
</div>
<span v-if="eraNetwork.l1Network" class="mt-1.5 inline-block">
Proceed to
<NuxtLink class="link" :to="{ name: 'receive-methods' }">Add funds</NuxtLink> page to add balance to
your account
</span>
</CommonEmptyBlock>
</template>
</CommonCardWithLineButtons>
</template>

<template v-if="noBalances">
<TypographyCategoryLabel>
To start using zkSync ecosystem, deposit tokens in any convenient way
</TypographyCategoryLabel>

<div class="flex flex-col gap-block-gap">
<BridgeFromEthereumButton v-if="eraNetwork.l1Network" />

<CommonCardWithLineButtons v-for="(item, index) in depositMethods" :key="index">
<DestinationItem v-bind="item.props">
<template #image v-if="item.icon">
<DestinationIconContainer>
<component :is="item.icon" aria-hidden="true" />
</DestinationIconContainer>
</template>
</DestinationItem>
</CommonCardWithLineButtons>
</div>
</template>
<template v-else>
<TypographyCategoryLabel>Deposit more tokens to zkSync</TypographyCategoryLabel>

<CommonCardWithLineButtons>
<DestinationItem v-for="(item, index) in depositMethods" :key="index" v-bind="item.props">
<template #image v-if="item.icon">
<DestinationIconContainer>
<component :is="item.icon" aria-hidden="true" />
</DestinationIconContainer>
</template>
</DestinationItem>
</CommonCardWithLineButtons>
</template>
</template>
</div>
</template>

<script lang="ts" setup>
import { computed, onBeforeUnmount } from "vue";
import {
ArrowDownLeftIcon,
ArrowsUpDownIcon,
ArrowTopRightOnSquareIcon,
ArrowUpRightIcon,
BanknotesIcon,
QrCodeIcon,
} from "@heroicons/vue/24/outline";
import { storeToRefs } from "pinia";
import useInterval from "@/composables/useInterval";
import useSingleLoading from "@/composables/useSingleLoading";
import useEcosystemBanner from "@/composables/zksync/deposit/useEcosystemBanner";
import type { FunctionalComponent } from "vue";
import { useDestinationsStore } from "@/store/destinations";
import { useOnboardStore } from "@/store/onboard";
import { useZkSyncProviderStore } from "@/store/zksync/provider";
import { useZkSyncWalletStore } from "@/store/zksync/wallet";
import { parseTokenAmount, removeSmallAmount } from "@/utils/formatters";
import { isOnlyZeroes } from "@/utils/helpers";
const onboardStore = useOnboardStore();
const walletEraStore = useZkSyncWalletStore();
const { isConnected } = storeToRefs(onboardStore);
const { balance, balanceInProgress, balanceError } = storeToRefs(walletEraStore);
const { destinations } = storeToRefs(useDestinationsStore());
const { eraNetwork } = storeToRefs(useZkSyncProviderStore());
const { ecosystemBannerVisible } = useEcosystemBanner();
const { loading, reset: resetSingleLoading } = useSingleLoading(computed(() => balanceInProgress.value));
const displayedBalances = computed(() => {
return balance.value.filter(({ amount, decimals, price }) => {
const decimalAmount = price ? removeSmallAmount(amount, decimals, price) : parseTokenAmount(amount, decimals);
if (!isOnlyZeroes(decimalAmount)) {
return true;
}
return false;
});
});
const noBalances = computed(() => !loading.value && !balanceError.value && !displayedBalances.value.length);
const depositMethods = computed(() => {
const methods: { props: Record<string, unknown>; icon?: FunctionalComponent }[] = [];
if (eraNetwork.value.l1Network && !noBalances.value) {
methods.push({
props: {
iconUrl: destinations.value.ethereum.iconUrl,
label: `Bridge from ${eraNetwork.value.l1Network?.name}`,
description: `Receive tokens from your ${eraNetwork.value.l1Network?.name} account`,
as: "RouterLink",
to: {
name: "index",
},
},
});
}
methods.push({
props: {
label: "View your address",
description: `Receive tokens from another ${eraNetwork.value.name} account`,
as: "RouterLink",
to: {
name: "receive",
},
},
icon: QrCodeIcon,
});
if (eraNetwork.value.displaySettings?.showPartnerLinks) {
methods.push({
props: {
label: "Top-up with cash",
description: "Buy tokens using a card or another method for fiat",
as: "a",
href: "https://zksync.dappradar.com/ecosystem?category-de=gateways",
target: "_blank",
icon: ArrowTopRightOnSquareIcon,
},
icon: BanknotesIcon,
});
methods.push({
props: {
label: "Bridge from other networks",
description: "Explore ecosystem of third party bridges",
as: "a",
href: "https://zksync.dappradar.com/ecosystem?category-de=bridges",
target: "_blank",
icon: ArrowTopRightOnSquareIcon,
},
icon: ArrowsUpDownIcon,
});
}
return methods;
});
const fetch = () => {
if (!isConnected.value) return;
walletEraStore.requestBalance();
};
fetch();
const { reset: resetAutoUpdate, stop: stopAutoUpdate } = useInterval(() => {
fetch();
}, 60000);
const unsubscribe = onboardStore.subscribeOnAccountChange((newAddress) => {
if (!newAddress) return;
resetSingleLoading();
resetAutoUpdate();
fetch();
});
onBeforeUnmount(() => {
stopAutoUpdate();
unsubscribe();
});
</script>

<style lang="scss" scoped></style>
2 changes: 1 addition & 1 deletion pages/balances.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<PageTitle :fallback-route="{ name: 'index' }">Balances</PageTitle>
<PageTitle :fallback-route="{ name: 'assets' }">Balances</PageTitle>

<template v-if="!isConnected">
<ConnectWalletBlock>Connect wallet to view your assets on {{ eraNetwork.name }}</ConnectWalletBlock>
Expand Down
11 changes: 0 additions & 11 deletions pages/bridge/index.vue

This file was deleted.

Loading

0 comments on commit 0f74e18

Please sign in to comment.