Refactor wallet module components for improved code organization and performance
- Updated import paths in the wallet module to enhance clarity and maintainability. - Removed unused imports in ReceiveDialog and SendDialog components to streamline the code. - Introduced a computed property in WalletPage to extract the base domain from the payment service configuration, improving readability and error handling. These changes contribute to a cleaner codebase and enhance the overall performance of the wallet module.
This commit is contained in:
parent
cdd00bf747
commit
d5a90c793b
4 changed files with 14 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, nextTick } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { useForm } from 'vee-validate'
|
import { useForm } from 'vee-validate'
|
||||||
import { toTypedSchema } from '@vee-validate/zod'
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
import * as z from 'zod'
|
import * as z from 'zod'
|
||||||
|
|
@ -55,7 +55,7 @@ const form = useForm({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { resetForm, values, meta } = form
|
const { resetForm, meta } = form
|
||||||
const isFormValid = computed(() => meta.value.valid)
|
const isFormValid = computed(() => meta.value.valid)
|
||||||
|
|
||||||
// State
|
// State
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useForm } from 'vee-validate'
|
import { useForm } from 'vee-validate'
|
||||||
import { toTypedSchema } from '@vee-validate/zod'
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
import * as z from 'zod'
|
import * as z from 'zod'
|
||||||
|
|
@ -8,7 +8,6 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } f
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import { Textarea } from '@/components/ui/textarea'
|
import { Textarea } from '@/components/ui/textarea'
|
||||||
import { Label } from '@/components/ui/label'
|
|
||||||
import { Send, AlertCircle, Loader2 } from 'lucide-vue-next'
|
import { Send, AlertCircle, Loader2 } from 'lucide-vue-next'
|
||||||
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'
|
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
import type { ModulePlugin } from '@/core/plugin-manager'
|
import type { ModulePlugin } from '@/core/types'
|
||||||
import { container, SERVICE_TOKENS } from '@/core/di-container'
|
import { container, SERVICE_TOKENS } from '@/core/di-container'
|
||||||
import WalletService from './services/WalletService'
|
import WalletService from './services/WalletService'
|
||||||
import { WalletPage, SendDialog, ReceiveDialog, WalletTransactions } from './components'
|
import { WalletPage, SendDialog, ReceiveDialog, WalletTransactions } from './components'
|
||||||
|
|
@ -37,15 +37,7 @@ export const walletModule: ModulePlugin = {
|
||||||
SendDialog,
|
SendDialog,
|
||||||
ReceiveDialog,
|
ReceiveDialog,
|
||||||
WalletTransactions
|
WalletTransactions
|
||||||
},
|
|
||||||
|
|
||||||
userMenuItems: [
|
|
||||||
{
|
|
||||||
name: 'Wallet',
|
|
||||||
href: '/wallet',
|
|
||||||
icon: 'Wallet'
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default walletModule
|
export default walletModule
|
||||||
|
|
@ -5,10 +5,8 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||||
import { Badge } from '@/components/ui/badge'
|
import { Badge } from '@/components/ui/badge'
|
||||||
import { Separator } from '@/components/ui/separator'
|
|
||||||
import { ScrollArea } from '@/components/ui/scroll-area'
|
import { ScrollArea } from '@/components/ui/scroll-area'
|
||||||
import { RefreshCw, Send, QrCode, ArrowUpRight, ArrowDownLeft, Clock, Wallet } from 'lucide-vue-next'
|
import { RefreshCw, Send, QrCode, ArrowUpRight, ArrowDownLeft, Clock, Wallet } from 'lucide-vue-next'
|
||||||
import CurrencyDisplay from '@/components/ui/CurrencyDisplay.vue'
|
|
||||||
import ReceiveDialog from '../components/ReceiveDialog.vue'
|
import ReceiveDialog from '../components/ReceiveDialog.vue'
|
||||||
import SendDialog from '../components/SendDialog.vue'
|
import SendDialog from '../components/SendDialog.vue'
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
|
|
@ -40,6 +38,14 @@ const totalBalance = computed(() => {
|
||||||
|
|
||||||
const payLinks = computed(() => walletService?.payLinks?.value || [])
|
const payLinks = computed(() => walletService?.payLinks?.value || [])
|
||||||
const firstPayLink = computed(() => payLinks.value[0] || null)
|
const firstPayLink = computed(() => payLinks.value[0] || null)
|
||||||
|
const baseDomain = computed(() => {
|
||||||
|
try {
|
||||||
|
const baseUrl = paymentService?.config?.baseUrl || 'http://localhost'
|
||||||
|
return new URL(baseUrl).hostname
|
||||||
|
} catch {
|
||||||
|
return 'localhost'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Get transactions grouped by date
|
// Get transactions grouped by date
|
||||||
const groupedTransactions = computed(() => {
|
const groupedTransactions = computed(() => {
|
||||||
|
|
@ -447,7 +453,7 @@ onMounted(async () => {
|
||||||
<div class="flex items-center gap-4 mt-2 text-sm text-muted-foreground">
|
<div class="flex items-center gap-4 mt-2 text-sm text-muted-foreground">
|
||||||
<span>{{ link.min }}-{{ link.max }} sats</span>
|
<span>{{ link.min }}-{{ link.max }} sats</span>
|
||||||
<Badge v-if="link.username" variant="secondary">
|
<Badge v-if="link.username" variant="secondary">
|
||||||
{{ link.username }}@{{ new URL(paymentService?.config?.baseUrl || 'http://localhost').hostname }}
|
{{ link.username }}@{{ baseDomain }}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue