- Add tailwindcss v4 + @tailwindcss/vite to mall, shop-admin, admin - Add @vmall/shared/theme.css tokens with html[data-accent] presets - Add @vmall/ui kit (VBtn/VBadge/VField/VInput/VCard/VPanel/VTable/VPage, VAccentSwatch, useAccent) as a Nuxt module - Convert all three apps to kit + utilities; delete ui.css/mall.css and every <style scoped>; consoles get accent presets, mall locked to red - Fix VCard boolean prop default (padding) and PDP/store stale useAsyncData keys on param navigation - Archive adopt-tailwind-design-system; new frontend-ui capability spec
104 lines
3.5 KiB
Vue
104 lines
3.5 KiB
Vue
<script setup lang="ts">
|
|
import type { IntegralOrder, IntegralOrderStatus } from "@vmall/shared";
|
|
|
|
definePageMeta({ middleware: "auth" });
|
|
|
|
const { $api } = useNuxtApp();
|
|
const { locale, t } = useI18n();
|
|
|
|
const orders = ref<IntegralOrder[]>([]);
|
|
const loading = ref(true);
|
|
const actionId = ref("");
|
|
const error = ref("");
|
|
const notice = ref("");
|
|
|
|
function rewardName(order: IntegralOrder): string {
|
|
return order.items.map((line) => line.name[locale.value] ?? line.name.en).join(", ");
|
|
}
|
|
|
|
function statusClass(status: IntegralOrderStatus): "green" | "red" | "orange" {
|
|
if (status === "fulfilled") return "green";
|
|
if (status === "cancelled") return "red";
|
|
return "orange";
|
|
}
|
|
|
|
async function load(): Promise<void> {
|
|
loading.value = true;
|
|
error.value = "";
|
|
try {
|
|
const page = await $api.admin.listPointsRedemptions();
|
|
orders.value = page.items;
|
|
} catch (err: unknown) {
|
|
error.value = err instanceof Error ? err.message : t("common.error");
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
async function transition(
|
|
order: IntegralOrder,
|
|
action: "fulfill" | "cancel",
|
|
): Promise<void> {
|
|
actionId.value = order.id;
|
|
error.value = "";
|
|
notice.value = "";
|
|
try {
|
|
if (action === "fulfill") await $api.admin.fulfillRedemption(order.id);
|
|
else await $api.admin.cancelRedemption(order.id);
|
|
notice.value =
|
|
action === "fulfill"
|
|
? t("admin.redemptionFulfilled")
|
|
: t("admin.redemptionCancelled");
|
|
await load();
|
|
} catch (err: unknown) {
|
|
error.value = err instanceof Error ? err.message : t("common.error");
|
|
} finally {
|
|
actionId.value = "";
|
|
}
|
|
}
|
|
|
|
onMounted(() => void load());
|
|
</script>
|
|
|
|
<template>
|
|
<VPage :title="$t('admin.pointsOrderManagement')">
|
|
<p v-if="error" class="my-2 text-sm text-danger" role="alert">{{ error }}</p>
|
|
<p v-if="notice" class="text-sm text-muted" role="status">{{ notice }}</p>
|
|
<p v-if="loading" class="text-sm text-muted">{{ $t("common.loading") }}</p>
|
|
<VCard v-else-if="orders.length === 0" class="text-muted">{{ $t("common.empty") }}</VCard>
|
|
<div v-else class="overflow-x-auto"><div class="min-w-[980px]"><VTable>
|
|
<thead>
|
|
<tr>
|
|
<th>{{ $t("admin.redemptionNo") }}</th>
|
|
<th>{{ $t("admin.redemptionCustomer") }}</th>
|
|
<th>{{ $t("admin.redemptionReward") }}</th>
|
|
<th>{{ $t("admin.redemptionPoints") }}</th>
|
|
<th>{{ $t("admin.created") }}</th>
|
|
<th>{{ $t("admin.redemptionStatus") }}</th>
|
|
<th>{{ $t("common.actions") }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="order in orders" :key="order.id">
|
|
<td>{{ order.order_no }}</td>
|
|
<td class="text-muted">{{ order.user_id }}</td>
|
|
<td>{{ rewardName(order) }}</td>
|
|
<td>{{ order.total_points }}</td>
|
|
<td>{{ order.created_at.slice(0, 10) }}</td>
|
|
<td><VBadge :tone="statusClass(order.status)">{{ $t(`admin.redemptionStatuses.${order.status}`) }}</VBadge></td>
|
|
<td><div class="flex gap-2">
|
|
<template v-if="order.status === 'pending_fulfillment'">
|
|
<VBtn size="sm" variant="primary" :disabled="actionId === order.id" @click="transition(order, 'fulfill')">
|
|
{{ $t("admin.fulfillRedemption") }}
|
|
</VBtn>
|
|
<VBtn size="sm" :disabled="actionId === order.id" @click="transition(order, 'cancel')">
|
|
{{ $t("admin.cancelRedemption") }}
|
|
</VBtn>
|
|
</template>
|
|
</div></td>
|
|
</tr>
|
|
</tbody>
|
|
</VTable></div></div>
|
|
</VPage>
|
|
</template>
|