♻️ Migrated the rest pages

This commit is contained in:
2025-11-29 23:09:50 +08:00
parent f5a2be3598
commit be35bd24c2
3 changed files with 268 additions and 279 deletions

8
app/components.d.ts vendored
View File

@@ -29,12 +29,15 @@ declare module 'vue' {
NDialog: typeof import('naive-ui')['NDialog'] NDialog: typeof import('naive-ui')['NDialog']
NDialogProvider: typeof import('naive-ui')['NDialogProvider'] NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDivider: typeof import('naive-ui')['NDivider'] NDivider: typeof import('naive-ui')['NDivider']
NDrawer: typeof import('naive-ui')['NDrawer']
NDrawerContent: typeof import('naive-ui')['NDrawerContent']
NDropdown: typeof import('naive-ui')['NDropdown'] NDropdown: typeof import('naive-ui')['NDropdown']
NEmpty: typeof import('naive-ui')['NEmpty'] NEmpty: typeof import('naive-ui')['NEmpty']
NForm: typeof import('naive-ui')['NForm'] NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem'] NFormItem: typeof import('naive-ui')['NFormItem']
NIcon: typeof import('naive-ui')['NIcon'] NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage'] NImage: typeof import('naive-ui')['NImage']
NImagePreview: typeof import('naive-ui')['NImagePreview']
NImg: typeof import('naive-ui')['NImg'] NImg: typeof import('naive-ui')['NImg']
NInfiniteScroll: typeof import('naive-ui')['NInfiniteScroll'] NInfiniteScroll: typeof import('naive-ui')['NInfiniteScroll']
NInput: typeof import('naive-ui')['NInput'] NInput: typeof import('naive-ui')['NInput']
@@ -58,6 +61,7 @@ declare module 'vue' {
NTag: typeof import('naive-ui')['NTag'] NTag: typeof import('naive-ui')['NTag']
NTextarea: typeof import('naive-ui')['NTextarea'] NTextarea: typeof import('naive-ui')['NTextarea']
NThemeEditor: typeof import('naive-ui')['NThemeEditor'] NThemeEditor: typeof import('naive-ui')['NThemeEditor']
NTooltip: typeof import('naive-ui')['NTooltip']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView'] RouterView: typeof import('vue-router')['RouterView']
} }
@@ -82,12 +86,15 @@ declare global {
const NDialog: typeof import('naive-ui')['NDialog'] const NDialog: typeof import('naive-ui')['NDialog']
const NDialogProvider: typeof import('naive-ui')['NDialogProvider'] const NDialogProvider: typeof import('naive-ui')['NDialogProvider']
const NDivider: typeof import('naive-ui')['NDivider'] const NDivider: typeof import('naive-ui')['NDivider']
const NDrawer: typeof import('naive-ui')['NDrawer']
const NDrawerContent: typeof import('naive-ui')['NDrawerContent']
const NDropdown: typeof import('naive-ui')['NDropdown'] const NDropdown: typeof import('naive-ui')['NDropdown']
const NEmpty: typeof import('naive-ui')['NEmpty'] const NEmpty: typeof import('naive-ui')['NEmpty']
const NForm: typeof import('naive-ui')['NForm'] const NForm: typeof import('naive-ui')['NForm']
const NFormItem: typeof import('naive-ui')['NFormItem'] const NFormItem: typeof import('naive-ui')['NFormItem']
const NIcon: typeof import('naive-ui')['NIcon'] const NIcon: typeof import('naive-ui')['NIcon']
const NImage: typeof import('naive-ui')['NImage'] const NImage: typeof import('naive-ui')['NImage']
const NImagePreview: typeof import('naive-ui')['NImagePreview']
const NImg: typeof import('naive-ui')['NImg'] const NImg: typeof import('naive-ui')['NImg']
const NInfiniteScroll: typeof import('naive-ui')['NInfiniteScroll'] const NInfiniteScroll: typeof import('naive-ui')['NInfiniteScroll']
const NInput: typeof import('naive-ui')['NInput'] const NInput: typeof import('naive-ui')['NInput']
@@ -111,6 +118,7 @@ declare global {
const NTag: typeof import('naive-ui')['NTag'] const NTag: typeof import('naive-ui')['NTag']
const NTextarea: typeof import('naive-ui')['NTextarea'] const NTextarea: typeof import('naive-ui')['NTextarea']
const NThemeEditor: typeof import('naive-ui')['NThemeEditor'] const NThemeEditor: typeof import('naive-ui')['NThemeEditor']
const NTooltip: typeof import('naive-ui')['NTooltip']
const RouterLink: typeof import('vue-router')['RouterLink'] const RouterLink: typeof import('vue-router')['RouterLink']
const RouterView: typeof import('vue-router')['RouterView'] const RouterView: typeof import('vue-router')['RouterView']
} }

View File

@@ -1,91 +1,65 @@
<template> <template>
<div class="lightbox-container"> <div class="lightbox-container h-compact-layout">
<!-- Top Toolbar --> <!-- Top Toolbar -->
<v-app-bar v-if="fileInfo" class="top-toolbar" flat height="56"> <header v-if="fileInfo" class="top-toolbar bg-neutral-900/50 text-white">
<v-container fluid> <div class="container mx-auto px-4 h-full">
<v-row align="center" class="pa-2"> <div class="flex items-center h-full">
<v-col cols="12" md="4"> <div class="flex items-center gap-2 w-full md:w-1/3">
<div class="d-flex align-center gap-2"> <n-tooltip trigger="hover">
<v-tooltip location="bottom" :text="fileInfo.mimeType"> <template #trigger>
<template #activator="{ props }"> <n-icon :component="fileIcon" />
<v-icon v-bind="props" :icon="fileIcon"></v-icon> </template>
</template> {{ fileInfo.mimeType }}
</v-tooltip> </n-tooltip>
<v-tooltip location="bottom" :text="fileInfo.name || 'File'"> <n-tooltip trigger="hover">
<template #activator="{ props }"> <template #trigger>
<span class="line-clamp-1" v-bind="props"> <span class="line-clamp-1">
{{ fileInfo.name || "File" }} {{ fileInfo.name || "File" }}
</span> </span>
</template> </template>
</v-tooltip> {{ fileInfo.name || "File" }}
<!-- Action buttons on mobile --> </n-tooltip>
<div class="d-flex d-md-none gap-2 ml-auto"> <!-- Action buttons on mobile -->
<v-btn <div class="flex md:hidden gap-2 ml-auto">
icon <n-button text style="font-size: 20px" @click="handleDownload">
size="small" <n-icon :component="Download" />
density="compact" </n-button>
@click="handleDownload" <n-button text style="font-size: 20px" @click="infoDialog = true">
> <n-icon :component="Info" />
<v-icon>mdi-download</v-icon> </n-button>
</v-btn>
<v-btn
icon
size="small"
density="compact"
@click="infoDialog = true"
>
<v-icon>mdi-information</v-icon>
</v-btn>
</div>
</div> </div>
</v-col> </div>
<v-col cols="12" md="8" class="d-none d-md-block"> <div class="hidden md:flex items-center justify-end gap-4 w-2/3">
<div class="d-flex align-center justify-end gap-4"> <span>{{ formatBytes(fileInfo.size) }}</span>
<span>{{ formatBytes(fileInfo.size) }}</span> <span>{{ new Date(fileInfo.createdAt).toLocaleString() }}</span>
<span>{{ new Date(fileInfo.createdAt).toLocaleString() }}</span> <n-button text style="font-size: 20px" @click="handleDownload">
<v-btn <n-icon :component="Download" />
icon </n-button>
size="small" <n-button text style="font-size: 20px" @click="infoDialog = true">
density="compact" <n-icon :component="Info" />
@click="handleDownload" </n-button>
> </div>
<v-icon>mdi-download</v-icon> </div>
</v-btn> </div>
<v-btn </header>
icon
size="small"
density="compact"
@click="infoDialog = true"
>
<v-icon>mdi-information</v-icon>
</v-btn>
</div>
</v-col>
</v-row>
</v-container>
</v-app-bar>
<!-- Main Content - File Preview --> <!-- Main Content - File Preview -->
<div class="preview-container"> <div class="preview-container">
<v-progress-circular <n-spin v-if="!fileInfo && !error" size="large" />
v-if="!fileInfo && !error" <n-alert
indeterminate
size="64"
class="loading-spinner"
></v-progress-circular>
<v-alert
v-else-if="error" v-else-if="error"
type="error" type="error"
title="No file was found" title="No file was found"
:text="error" class="max-w-md"
class="error-alert" >
></v-alert> {{ error }}
</n-alert>
<div v-else class="preview-content"> <div v-else class="preview-content">
<div v-if="fileInfo?.isEncrypted" class="encrypted-notice"> <div v-if="fileInfo?.isEncrypted" class="max-w-md">
<v-alert type="info" title="Encrypted file" class="mb-4"> <n-alert type="info" title="Encrypted file" class="mb-4">
The file has been encrypted. Preview not available. Please enter the The file has been encrypted. Preview not available. Please enter the
password to download it. password to download it.
</v-alert> </n-alert>
</div> </div>
<div <div
v-else v-else
@@ -96,11 +70,12 @@
@touchend="handleTouchEnd" @touchend="handleTouchEnd"
@dblclick="handleDoubleClick" @dblclick="handleDoubleClick"
> >
<v-img <img
v-if="fileType === 'image'" v-if="fileType === 'image'"
:src="fileSource" :src="fileSource"
class="preview-image" class="preview-image"
:style="{ transform: `scale(${zoomLevel})` }" :style="{ transform: `scale(${zoomLevel})` }"
alt="Image preview"
/> />
<video <video
v-else-if="fileType === 'video'" v-else-if="fileType === 'video'"
@@ -114,102 +89,113 @@
controls controls
class="preview-audio" class="preview-audio"
/> />
<v-alert <n-alert
v-else v-else
type="warning" type="warning"
title="Preview Unavailable" title="Preview Unavailable"
text="How can you preview this file?" class="max-w-md"
class="preview-unavailable" >
/> A preview for this file type is not available.
</n-alert>
</div> </div>
</div> </div>
</div> </div>
<!-- Password Dialog --> <!-- Password Dialog -->
<v-dialog v-model="secretDialog" max-width="400"> <n-modal v-model:show="secretDialog">
<v-card> <n-card
<v-card-title> style="width: 400px"
<v-icon left>mdi-lock</v-icon> title="Enter Password"
Enter Password :bordered="false"
</v-card-title> size="huge"
<v-card-text> role="dialog"
<v-text-field aria-modal="true"
v-model="dialogPassword" >
label="Password" <n-input
type="password" v-model:value="dialogPassword"
variant="outlined" type="password"
autofocus show-password-on="click"
@keyup.enter="confirmDownload" placeholder="Password"
/> autofocus
</v-card-text> @keyup.enter="confirmDownload"
<v-card-actions> />
<v-spacer></v-spacer> <template #footer>
<v-btn @click="secretDialog = false">Cancel</v-btn> <div class="flex justify-end gap-2">
<v-btn color="primary" @click="confirmDownload">Download</v-btn> <n-button @click="secretDialog = false">Cancel</n-button>
</v-card-actions> <n-button type="primary" @click="confirmDownload"
</v-card> >Download</n-button
</v-dialog> >
</div>
</template>
</n-card>
</n-modal>
<!-- Technical Details Dialog --> <!-- Technical Details Dialog -->
<v-dialog v-model="infoDialog" max-width="640"> <n-drawer
<v-card title="File Information" prepend-icon="mdi-information"> v-model:show="infoDialog"
<v-card-text> :width="breakpoints.isGreaterOrEqual('md') ? '40vw' : '100vw'"
<v-row> >
<v-col cols="12" md="6"> <n-drawer-content>
<div class="mb-4"> <template #header>
<strong>File ID</strong> <div class="flex items-center justify-between gap-2">
<div class="text-xs">#{{ fileInfo?.id }}</div> <div>File Information</div>
</div> <n-button text size="small" @click="infoDialog = false">
<div class="mb-4"> <template #icon>
<strong>File Name</strong> <n-icon :component="XIcon" />
<div class="text-xs">{{ fileInfo?.name || "N/A" }}</div> </template>
</div> </n-button>
<div class="mb-4">
<strong>MIME Type</strong>
<div class="text-xs">{{ fileInfo?.mimeType || "N/A" }}</div>
</div>
<div class="mb-4">
<strong>File Size</strong>
<div class="text-xs">
{{ fileInfo?.size ? formatBytes(fileInfo.size) : "N/A" }}
</div>
</div>
</v-col>
<v-col cols="12" md="6">
<div class="mb-4">
<strong>Created At</strong>
<div class="text-xs">
{{
fileInfo?.createdAt
? new Date(fileInfo.createdAt).toLocaleString()
: "N/A"
}}
</div>
</div>
<div class="mb-4">
<strong>Encrypted</strong>
<div class="text-xs">
{{ fileInfo?.isEncrypted ? "Yes" : "No" }}
</div>
</div>
</v-col>
</v-row>
<div class="mb-4">
<strong>Metadata:</strong>
</div> </div>
<v-card variant="outlined" class="pa-2"> </template>
<pre <div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
class="overflow-x-auto" <div class="flex flex-col gap-4">
style="font-size: 14px" <div>
><code>{{ JSON.stringify(fileInfo?.fileMeta, null, 2) }}</code></pre> <strong class="font-semibold">File ID</strong>
</v-card> <div class="opacity-80">#{{ fileInfo?.id }}</div>
</v-card-text> </div>
<v-card-actions> <div>
<v-spacer></v-spacer> <strong class="font-semibold">File Name</strong>
<v-btn @click="infoDialog = false">Close</v-btn> <div class="opacity-80">{{ fileInfo?.name || "N/A" }}</div>
</v-card-actions> </div>
</v-card> <div>
</v-dialog> <strong class="font-semibold">MIME Type</strong>
<div class="opacity-80">{{ fileInfo?.mimeType || "N/A" }}</div>
</div>
<div>
<strong class="font-semibold">File Size</strong>
<div class="opacity-80">
{{ fileInfo?.size ? formatBytes(fileInfo.size) : "N/A" }}
</div>
</div>
</div>
<div class="flex flex-col gap-4">
<div>
<strong class="font-semibold">Created At</strong>
<div class="opacity-80">
{{
fileInfo?.createdAt
? new Date(fileInfo.createdAt).toLocaleString()
: "N/A"
}}
</div>
</div>
<div>
<strong class="font-semibold">Encrypted</strong>
<div class="opacity-80">
{{ fileInfo?.isEncrypted ? "Yes" : "No" }}
</div>
</div>
</div>
</div>
<div class="mt-4">
<strong class="font-semibold">Metadata:</strong>
</div>
<n-card :bordered="true" class="mt-2">
<pre
class="overflow-x-auto text-xs"
><code>{{ JSON.stringify(fileInfo?.fileMeta, null, 2) }}</code></pre>
</n-card>
</n-drawer-content>
</n-drawer>
<!-- View Transition Overlay --> <!-- View Transition Overlay -->
<div <div
@@ -228,11 +214,24 @@
<script setup lang="ts"> <script setup lang="ts">
import { useRoute } from "vue-router" import { useRoute } from "vue-router"
import { computed, onMounted, ref } from "vue" import { computed, onMounted, ref, type Component } from "vue"
import {
Download,
Info,
Lock,
File,
FileImage,
FileVideo,
FileMusic,
FileText,
FileCode,
FileArchive,
XIcon
} from "lucide-vue-next"
import { downloadAndDecryptFile } from "./secure" import { downloadAndDecryptFile } from "./secure"
import { formatBytes } from "./format" import { formatBytes } from "./format"
import type { SnCloudFile } from "~/types/api/post" import type { SnCloudFile } from "~/types/api/post"
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core"
const route = useRoute() const route = useRoute()
@@ -289,7 +288,6 @@ function checkForTransition() {
isTransitioning.value = true isTransitioning.value = true
transitionImage.value = data.src transitionImage.value = data.src
// Calculate final position (centered in viewport)
const viewportWidth = window.innerWidth const viewportWidth = window.innerWidth
const viewportHeight = window.innerHeight const viewportHeight = window.innerHeight
const finalWidth = Math.min( const finalWidth = Math.min(
@@ -300,7 +298,6 @@ function checkForTransition() {
const finalX = (viewportWidth - finalWidth) / 2 const finalX = (viewportWidth - finalWidth) / 2
const finalY = (viewportHeight - finalHeight) / 2 const finalY = (viewportHeight - finalHeight) / 2
// Set initial position (from original image location)
transitionStyle.value = { transitionStyle.value = {
position: "fixed", position: "fixed",
top: `${data.y}px`, top: `${data.y}px`,
@@ -311,7 +308,6 @@ function checkForTransition() {
transition: "all 0.3s ease-out" transition: "all 0.3s ease-out"
} }
// Animate to final position
requestAnimationFrame(() => { requestAnimationFrame(() => {
transitionStyle.value = { transitionStyle.value = {
...transitionStyle.value, ...transitionStyle.value,
@@ -320,8 +316,6 @@ function checkForTransition() {
width: `${finalWidth}px`, width: `${finalWidth}px`,
height: `${finalHeight}px` height: `${finalHeight}px`
} }
// Hide transition after animation
setTimeout(() => { setTimeout(() => {
isTransitioning.value = false isTransitioning.value = false
sessionStorage.removeItem("imageTransition") sessionStorage.removeItem("imageTransition")
@@ -345,38 +339,38 @@ const fileType = computed(() => {
if (!fileInfo.value) return "unknown" if (!fileInfo.value) return "unknown"
return fileInfo.value.mimeType?.split("/")[0] || "unknown" return fileInfo.value.mimeType?.split("/")[0] || "unknown"
}) })
const fileIcon = computed(() => { const fileIcon = computed<Component>(() => {
if (!fileInfo.value?.mimeType) return "mdi-file" if (!fileInfo.value?.mimeType) return File
const mime = fileInfo.value.mimeType.toLowerCase() const mime = fileInfo.value.mimeType.toLowerCase()
if (mime.startsWith("image/")) return "mdi-file-image" if (mime.startsWith("image/")) return FileImage
if (mime.startsWith("video/")) return "mdi-file-video" if (mime.startsWith("video/")) return FileVideo
if (mime.startsWith("audio/")) return "mdi-file-music" if (mime.startsWith("audio/")) return FileMusic
if (mime === "application/pdf") return "mdi-file-pdf" if (mime === "application/pdf") return FileText
if ( if (
mime.startsWith("text/") || mime.startsWith("text/") ||
mime.includes("javascript") || mime.includes("javascript") ||
mime.includes("json") || mime.includes("json") ||
mime.includes("xml") mime.includes("xml")
) )
return "mdi-file-code" return FileCode
if (mime.includes("zip") || mime.includes("rar") || mime.includes("tar")) if (mime.includes("zip") || mime.includes("rar") || mime.includes("tar"))
return "mdi-zip-box" return FileArchive
if ( if (
mime.includes("document") || mime.includes("document") ||
mime.includes("word") || mime.includes("word") ||
mime.includes("excel") || mime.includes("excel") ||
mime.includes("powerpoint") mime.includes("powerpoint")
) )
return "mdi-file-document" return FileText
return "mdi-file" return File
}) })
const fileSource = computed(() => { const fileSource = computed(() => {
let url = `${apiBase}/drive/files/${fileId}?original=true` let url = `${apiBase}/drive/files/${fileId}?original=true`
if (passcode) { if (passcode) {
url += `?passcode=${passcode}` url += `&passcode=${passcode}`
} }
return url return url
}) })
@@ -436,7 +430,7 @@ function handleTouchMove(event: TouchEvent) {
) )
const scale = currentDistance / initialDistance.value const scale = currentDistance / initialDistance.value
zoomLevel.value = Math.max(0.1, Math.min(5, scale)) zoomLevel.value = Math.max(0.1, Math.min(5, zoomLevel.value * scale))
} }
function handleTouchEnd(_event: TouchEvent) { function handleTouchEnd(_event: TouchEvent) {
@@ -451,7 +445,14 @@ function handleDoubleClick() {
zoomLevel.value = zoomLevel.value > 1 ? 1 : 2 zoomLevel.value = zoomLevel.value > 1 ? 1 : 2
} }
const breakpoints = useBreakpoints(breakpointsTailwind)
const message = useMessage()
async function performDownload(password: string) { async function performDownload(password: string) {
const progressMessage = message.loading("Downloading file...", {
duration: 0
})
if (fileInfo.value!.isEncrypted) { if (fileInfo.value!.isEncrypted) {
downloadAndDecryptFile( downloadAndDecryptFile(
fileSource.value, fileSource.value,
@@ -503,6 +504,9 @@ async function performDownload(password: string) {
a.click() a.click()
a.remove() a.remove()
window.URL.revokeObjectURL(blobUrl) window.URL.revokeObjectURL(blobUrl)
progressMessage.destroy()
message.success("File has been downloaded successfully.")
} }
} }
@@ -513,11 +517,7 @@ definePageMeta({
<style scoped> <style scoped>
.lightbox-container { .lightbox-container {
position: fixed;
top: 0;
left: 0;
width: 100vw; width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.9); background: rgba(0, 0, 0, 0.9);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -525,6 +525,7 @@ definePageMeta({
} }
.top-toolbar { .top-toolbar {
height: 56px;
position: relative; position: relative;
z-index: 1001; z-index: 1001;
} }
@@ -536,6 +537,7 @@ definePageMeta({
justify-content: center; justify-content: center;
padding: 20px; padding: 20px;
overflow: auto; overflow: auto;
min-height: 0;
} }
.preview-content { .preview-content {
@@ -549,21 +551,17 @@ definePageMeta({
.file-preview { .file-preview {
width: 100%; width: 100%;
height: 100%; height: 100%;
max-width: calc(100vw - 40px);
max-height: calc(
100vh - 88px
); /* Account for top toolbar (48px) + padding (40px) */
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.preview-image { .preview-image {
width: 100%; max-width: 100%;
height: 100%; max-height: 100%;
object-fit: contain; object-fit: contain;
transition: all 0.3s ease-in-out; transition: transform 0.2s ease-out;
will-change: contents; will-change: transform;
} }
.preview-video, .preview-video,
@@ -572,27 +570,6 @@ definePageMeta({
max-height: 100%; max-height: 100%;
} }
.preview-unavailable {
max-width: 500px;
}
.loading-spinner {
color: white;
}
.error-alert {
max-width: 500px;
}
.encrypted-notice {
max-width: 500px;
}
/* Ensure toolbar doesn't interfere with content */
.top-toolbar :deep(.v-app-bar__content) {
padding: 0;
}
/* View transition styles */ /* View transition styles */
.transition-overlay { .transition-overlay {
pointer-events: none; pointer-events: none;

View File

@@ -1,68 +1,63 @@
<template> <template>
<div class="d-flex align-center justify-center fill-height"> <div class="flex items-center justify-center min-h-screen">
<v-card <n-card title="Order Payment" class="max-w-sm">
max-width="400" <template #header-icon>
title="Order Payment" <n-icon :component="Wallet" />
prepend-icon="mdi-cash" </template>
class="pa-2" <n-alert v-if="done" type="success" class="mb-4">
> The order has been paid successfully. You can now close this tab and
<v-card-text> return to Solar Network!
<v-alert v-if="done" type="success" class="mb-4"> </n-alert>
The order has been paid successfully. Now you can close this tab and <n-alert
back to the Solar Network! v-else-if="!!error"
</v-alert> type="error"
<v-alert title="Something went wrong"
v-else-if="!!error" class="mb-4"
type="error" >
title="Something went wrong" {{ error }}
class="mb-4" </n-alert>
>{{ error }}</v-alert <div v-else-if="!!order" class="flex flex-col gap-2">
> <p>Order for {{ order.productIdentifier ?? "unknown" }}</p>
<div v-else-if="!!order"> <div class="flex items-center gap-2">
<p class="mb-2"> <n-icon :component="Tag" />
Order for {{ order.productIdentifier ?? "unknown" }} <strong>{{ order.remarks }}</strong>
</p>
<div class="d-flex align-center gap-2 mb-2">
<v-icon size="18">mdi-tag</v-icon>
<strong>{{ order.remarks }}</strong>
</div>
<div class="d-flex align-center gap-2 mb-2">
<v-icon size="18">mdi-cash</v-icon>
<span>Amount</span>
<strong>{{ order.amount }} {{ order.currency }}</strong>
</div>
<div v-if="order.expiredAt" class="d-flex align-center gap-2 mb-4">
<v-icon size="18">mdi-calendar</v-icon>
<span>Until</span>
<strong>{{ new Date(order.expiredAt).toLocaleString() }}</strong>
</div>
<div class="mt-4">
<v-otp-input
v-model="pinCode"
label="Pin Code"
length="6"
type="password"
density="comfortable"
></v-otp-input>
<v-btn
color="primary"
:loading="submitting"
class="mt-4"
@click="pay"
>
<v-icon left>mdi-check</v-icon>
Pay
</v-btn>
</div>
</div> </div>
<v-progress-circular <div class="flex items-center gap-2">
v-else <n-icon :component="CircleDollarSign" />
indeterminate <span>Amount</span>
size="32" <strong>{{ order.amount }} {{ order.currency }}</strong>
class="mt-4" </div>
></v-progress-circular> <div v-if="order.expiredAt" class="flex items-center gap-2">
</v-card-text> <n-icon :component="Calendar" />
</v-card> <span>Until</span>
<strong>{{ new Date(order.expiredAt).toLocaleString() }}</strong>
</div>
<div class="mt-4">
<n-input
v-model:value="pinCode"
type="password"
show-password-on="click"
placeholder="6-digit PIN"
maxlength="6"
:input-props="{ autocomplete: 'one-time-code' }"
/>
<n-button
type="primary"
:loading="submitting"
class="mt-4 w-full"
@click="pay"
>
<template #icon>
<n-icon :component="Check" />
</template>
Pay
</n-button>
</div>
</div>
<div v-else class="flex justify-center p-8">
<n-spin size="medium" />
</div>
</n-card>
</div> </div>
</template> </template>
@@ -70,6 +65,13 @@
import { onMounted, ref } from "vue" import { onMounted, ref } from "vue"
import { useRoute } from "vue-router" import { useRoute } from "vue-router"
import type { SnWalletOrder } from "~/types/api/order" import type { SnWalletOrder } from "~/types/api/order"
import {
Wallet,
Tag,
CircleDollarSign,
Calendar,
Check
} from "lucide-vue-next"
const route = useRoute() const route = useRoute()
@@ -99,6 +101,7 @@ async function fetchOrder() {
} }
async function pay() { async function pay() {
if (submitting.value) return
submitting.value = true submitting.value = true
try { try {
await api(`/id/orders/${encodeURIComponent(orderId)}/pay`, { await api(`/id/orders/${encodeURIComponent(orderId)}/pay`, {
@@ -109,6 +112,8 @@ async function pay() {
done.value = true done.value = true
} catch (err: unknown) { } catch (err: unknown) {
error.value = err instanceof Error ? err.message : String(err) error.value = err instanceof Error ? err.message : String(err)
} finally {
submitting.value = false
} }
} }
@@ -118,5 +123,4 @@ definePageMeta({
middleware: ["auth"], middleware: ["auth"],
title: "Solarpay" title: "Solarpay"
}) })
</script> </script>