2022-04-21 23:05:56 -04:00
|
|
|
<template>
|
|
|
|
<div class="has-text-centered">
|
2022-05-27 05:28:20 -04:00
|
|
|
<ErrorIcon :is404="statusCode === 404" />
|
2022-04-21 23:05:56 -04:00
|
|
|
<h1 class="title is-1">{{ $t('errorPage.title') }}</h1>
|
2022-05-27 05:28:20 -04:00
|
|
|
<template v-if="statusCode === 204">
|
|
|
|
<p class="p mb-6">
|
|
|
|
{{
|
|
|
|
$t('errorPage.switchNetwork.description', {
|
|
|
|
pageName: $t(`errorPage.switchNetwork.pageName.${error.pageName}`)
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</p>
|
|
|
|
<b-button type="is-primary" icon-left="logo" outlined @click="handleSwitchNetwork">{{
|
|
|
|
$t('errorPage.switchNetwork.button')
|
|
|
|
}}</b-button>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<p class="p mb-6">{{ $t('errorPage.description') }}</p>
|
|
|
|
<b-button type="is-primary" icon-left="logo" outlined @click="handleRedirect">{{
|
|
|
|
$t('errorPage.button')
|
|
|
|
}}</b-button>
|
|
|
|
</template>
|
2022-04-21 23:05:56 -04:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2022-05-27 05:28:20 -04:00
|
|
|
import { mapActions } from 'vuex'
|
|
|
|
|
2022-05-30 09:27:44 -04:00
|
|
|
import { sleep } from '@/utils'
|
2022-05-27 05:28:20 -04:00
|
|
|
import { ErrorIcon } from '@/components/icons'
|
2022-04-21 23:05:56 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ErrorPage',
|
|
|
|
components: {
|
2022-05-27 05:28:20 -04:00
|
|
|
ErrorIcon
|
2022-04-21 23:05:56 -04:00
|
|
|
},
|
2022-05-27 05:28:20 -04:00
|
|
|
props: {
|
|
|
|
error: {
|
|
|
|
type: Object,
|
|
|
|
default: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
statusCode() {
|
|
|
|
return this.error?.statusCode || 404
|
|
|
|
}
|
2022-04-21 23:05:56 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2022-05-27 05:28:20 -04:00
|
|
|
...mapActions('metamask', ['networkChangeHandler']),
|
2022-05-30 09:27:44 -04:00
|
|
|
...mapActions('loading', ['enable', 'disable']),
|
2022-04-21 23:05:56 -04:00
|
|
|
handleRedirect() {
|
|
|
|
this.$router.push('/')
|
2022-05-27 05:28:20 -04:00
|
|
|
},
|
|
|
|
async handleSwitchNetwork() {
|
2022-05-30 09:27:44 -04:00
|
|
|
this.enable({ message: this.$t('changingNetwork') })
|
2022-05-27 05:28:20 -04:00
|
|
|
|
2022-05-30 09:27:44 -04:00
|
|
|
await sleep(800)
|
2022-05-27 05:28:20 -04:00
|
|
|
|
2022-05-30 09:27:44 -04:00
|
|
|
try {
|
|
|
|
const providerName = window.localStorage.getItem('provider')
|
|
|
|
|
|
|
|
await this.networkChangeHandler({ netId: 1 })
|
|
|
|
|
|
|
|
if (!providerName) {
|
|
|
|
this.$router.go()
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
console.log(`handleSwitchNetwork has error ${err.message}`)
|
|
|
|
} finally {
|
|
|
|
this.disable()
|
2022-05-27 05:28:20 -04:00
|
|
|
}
|
2022-04-21 23:05:56 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
head() {
|
|
|
|
return {
|
|
|
|
bodyAttrs: {
|
|
|
|
class: 'is-centered-main-content'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2022-05-27 05:28:20 -04:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.p {
|
|
|
|
max-width: 560px;
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
</style>
|