neptune-web-wallet/src/views/Auth/components/ImportWalletComponent.vue

136 lines
3.7 KiB
Vue
Raw Normal View History

2025-10-23 03:27:02 +07:00
<script setup lang="ts">
2025-10-28 22:57:03 +07:00
import { ref } from 'vue'
import { ButtonCommon } from '@/components'
import SeedPhraseTab from './SeedPhraseTab.vue'
import KeystoreTab from './KeystoreTab.vue'
2025-10-23 03:27:02 +07:00
const emit = defineEmits<{
2025-10-28 22:57:03 +07:00
(e: 'import-success', data: { type: 'seed' | 'keystore'; value: string | string[] }): void
2025-10-23 03:27:02 +07:00
}>()
2025-10-23 18:36:58 +07:00
const tab = ref<'seedphrase' | 'keystore'>('seedphrase')
2025-10-28 22:57:03 +07:00
const seedPhraseTabRef = ref<InstanceType<typeof SeedPhraseTab>>()
const keystoreTabRef = ref<InstanceType<typeof KeystoreTab>>()
const isSeedPhraseValid = ref(false)
const isKeystoreValid = ref(false)
2025-10-23 03:27:02 +07:00
2025-10-28 22:57:03 +07:00
const handleSeedPhraseSubmit = (words: string[]) => {
emit('import-success', {
type: 'seed',
value: words,
})
}
2025-10-28 22:57:03 +07:00
const handleKeystoreSubmit = (keystore: string) => {
emit('import-success', { type: 'keystore', value: keystore })
2025-10-23 03:27:02 +07:00
}
const handleContinue = () => {
if (tab.value === 'seedphrase') {
2025-10-28 22:57:03 +07:00
seedPhraseTabRef.value?.handleSubmit()
2025-10-23 03:27:02 +07:00
} else {
2025-10-28 22:57:03 +07:00
keystoreTabRef.value?.handleSubmit()
2025-10-23 03:27:02 +07:00
}
}
</script>
<template>
<div class="import-wallet dark-card">
<h2 class="title">Import Wallet</h2>
<div class="desc">Pick your import method</div>
<div class="tabs">
<button
:class="['tab-btn', tab === 'seedphrase' && 'active']"
@click="tab = 'seedphrase'"
>
Import by seed phrase
</button>
2025-10-23 18:36:58 +07:00
<button :class="['tab-btn', tab === 'keystore' && 'active']" @click="tab = 'keystore'">
Import by keystore
2025-10-23 03:27:02 +07:00
</button>
</div>
<div v-if="tab === 'seedphrase'" class="tab-pane">
2025-10-28 22:57:03 +07:00
<SeedPhraseTab
ref="seedPhraseTabRef"
@update:valid="isSeedPhraseValid = $event"
@submit="handleSeedPhraseSubmit"
/>
2025-10-23 03:27:02 +07:00
</div>
<div v-else class="tab-pane">
2025-10-28 22:57:03 +07:00
<KeystoreTab
ref="keystoreTabRef"
@update:valid="isKeystoreValid = $event"
@submit="handleKeystoreSubmit"
/>
2025-10-23 03:27:02 +07:00
</div>
<ButtonCommon
class="mt-lg"
type="primary"
block
size="large"
2025-10-28 22:57:03 +07:00
:disabled="tab === 'seedphrase' ? !isSeedPhraseValid : !isKeystoreValid"
2025-10-23 03:27:02 +07:00
@click="handleContinue"
>Continue</ButtonCommon
>
</div>
</template>
<style lang="scss" scoped>
.import-wallet {
max-width: 420px;
width: 100%;
margin: 24px auto;
background: var(--bg-light);
border-radius: var(--radius-xl);
box-shadow: var(--shadow-primary);
padding: 32px 28px 24px 28px;
color: var(--text-primary);
.title {
font-weight: 700;
font-size: 1.45rem;
text-align: center;
margin-bottom: 5px;
}
.desc {
text-align: center;
color: var(--text-secondary);
font-size: 1rem;
margin-bottom: 24px;
}
.tabs {
display: flex;
background: var(--text-primary);
border-radius: 13px;
overflow: hidden;
margin-bottom: 18px;
.tab-btn {
flex: 1;
padding: 13px;
border: none;
background: none;
color: var(--text-secondary);
font-size: 1rem;
cursor: pointer;
transition: 0.18s;
&.active {
background: var(--primary-color);
color: var(--text-light);
}
&:hover:not(.active) {
background: var(--bg-secondary);
}
}
}
.tab-pane {
margin-top: 0.5rem;
}
.mt-lg {
margin-top: 32px;
}
}
2025-10-24 22:49:46 +07:00
@include screen(mobile) {
2025-10-23 03:27:02 +07:00
.import-wallet {
padding: 16px 5px;
}
}
</style>