wip(freight): migration 0017 + model/column-list groundwork for add-freight-templates
This commit is contained in:
@@ -41,13 +41,21 @@ async function load(): Promise<Paged<Favorite> | null> {
|
||||
page: requestedPage,
|
||||
per_page: perPage,
|
||||
});
|
||||
if (version !== loadVersion || activeTab.value !== requestedKind || page.value !== requestedPage) {
|
||||
if (
|
||||
version !== loadVersion ||
|
||||
activeTab.value !== requestedKind ||
|
||||
page.value !== requestedPage
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
result.value = next;
|
||||
return next;
|
||||
} catch {
|
||||
if (version === loadVersion && activeTab.value === requestedKind && page.value === requestedPage) {
|
||||
if (
|
||||
version === loadVersion &&
|
||||
activeTab.value === requestedKind &&
|
||||
page.value === requestedPage
|
||||
) {
|
||||
error.value = t("user.favoriteLoadFailed");
|
||||
result.value = { ...emptyPage };
|
||||
}
|
||||
@@ -61,9 +69,13 @@ watch(activeTab, () => {
|
||||
page.value = 1;
|
||||
});
|
||||
|
||||
watch([activeTab, page], () => {
|
||||
void load();
|
||||
}, { immediate: true });
|
||||
watch(
|
||||
[activeTab, page],
|
||||
() => {
|
||||
void load();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
async function removeProductFavorite(productId: string): Promise<void> {
|
||||
if (removingId.value) return;
|
||||
@@ -96,22 +108,49 @@ async function removeStoreFavorite(storeId: string): Promise<void> {
|
||||
|
||||
<template>
|
||||
<VCard class="min-h-[560px]">
|
||||
<h1 class="mb-4 text-xl font-bold text-text">{{ t("user.favoritesTitle") }}</h1>
|
||||
<p v-if="error" class="mb-4 text-sm text-muted">{{ error }}</p>
|
||||
<h1 class="text-text mb-4 text-xl font-bold">{{ t("user.favoritesTitle") }}</h1>
|
||||
<p v-if="error" class="text-muted mb-4 text-sm">{{ error }}</p>
|
||||
<UiTabs v-model="activeTab" :tabs="tabs">
|
||||
<template #default>
|
||||
<div v-if="loading" class="py-5 text-muted">{{ t("common.loading") }}</div>
|
||||
<div v-if="loading" class="text-muted py-5">{{ t("common.loading") }}</div>
|
||||
<div v-else-if="activeTab === 'product'">
|
||||
<UiEmptyState v-if="productRows.length === 0" :text="t('user.noFavorites')" />
|
||||
<div v-else class="grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(220px,1fr))]">
|
||||
<VCard v-for="item in productRows" :key="item.id" :padded="false" class="overflow-hidden transition-shadow hover:shadow-md">
|
||||
<NuxtLink :to="`/goods/${item.product.slug}`" class="block border-b border-border">
|
||||
<img class="block h-[150px] w-full object-contain" :src="item.product.image || '/mock/product-1.svg'" :alt="pick(item.product.name, locale)" />
|
||||
<div
|
||||
v-else
|
||||
class="grid [grid-template-columns:repeat(auto-fill,minmax(220px,1fr))] gap-3"
|
||||
>
|
||||
<VCard
|
||||
v-for="item in productRows"
|
||||
:key="item.id"
|
||||
:padded="false"
|
||||
class="overflow-hidden transition-shadow hover:shadow-md"
|
||||
>
|
||||
<NuxtLink :to="`/goods/${item.product.slug}`" class="border-border block border-b">
|
||||
<img
|
||||
class="block h-[150px] w-full object-contain"
|
||||
:src="item.product.image || '/mock/product-1.svg'"
|
||||
:alt="pick(item.product.name, locale)"
|
||||
/>
|
||||
</NuxtLink>
|
||||
<div class="p-2.5">
|
||||
<NuxtLink :to="`/goods/${item.product.slug}`" class="mb-2 block h-9 overflow-hidden text-[13px] leading-5 text-text no-underline hover:text-primary">{{ pick(item.product.name, locale) }}</NuxtLink>
|
||||
<PriceText v-if="item.product.price_minor !== null && item.product.currency" class="mb-2.5 block text-primary" :amount-minor="item.product.price_minor" :currency="item.product.currency" />
|
||||
<VBtn size="sm" type="button" :disabled="removingId === item.product.id" @click="removeProductFavorite(item.product.id)">{{ t("user.removeFavorite") }}</VBtn>
|
||||
<NuxtLink
|
||||
:to="`/goods/${item.product.slug}`"
|
||||
class="text-text hover:text-primary mb-2 block h-9 overflow-hidden text-[13px] leading-5 no-underline"
|
||||
>{{ pick(item.product.name, locale) }}</NuxtLink
|
||||
>
|
||||
<PriceText
|
||||
v-if="item.product.price_minor !== null && item.product.currency"
|
||||
class="text-primary mb-2.5 block"
|
||||
:amount-minor="item.product.price_minor"
|
||||
:currency="item.product.currency"
|
||||
/>
|
||||
<VBtn
|
||||
size="sm"
|
||||
type="button"
|
||||
:disabled="removingId === item.product.id"
|
||||
@click="removeProductFavorite(item.product.id)"
|
||||
>{{ t("user.removeFavorite") }}</VBtn
|
||||
>
|
||||
</div>
|
||||
</VCard>
|
||||
</div>
|
||||
@@ -120,16 +159,39 @@ async function removeStoreFavorite(storeId: string): Promise<void> {
|
||||
<div v-else>
|
||||
<UiEmptyState v-if="storeRows.length === 0" :text="t('user.noFavoriteStores')" />
|
||||
<div v-else class="space-y-2.5">
|
||||
<article v-for="item in storeRows" :key="item.id" class="flex items-center gap-3.5 border border-border p-3 max-sm:flex-col max-sm:items-start">
|
||||
<img v-if="item.shop.logo" class="h-14 w-14 rounded-sm border border-border object-cover" :src="item.shop.logo" :alt="pick(item.shop.name, locale)" />
|
||||
<span v-else class="flex h-14 w-14 items-center justify-center rounded-sm border border-border bg-bg text-lg text-muted">{{ pick(item.shop.name, locale).slice(0, 1) }}</span>
|
||||
<article
|
||||
v-for="item in storeRows"
|
||||
:key="item.id"
|
||||
class="border-border flex items-center gap-3.5 border p-3 max-sm:flex-col max-sm:items-start"
|
||||
>
|
||||
<img
|
||||
v-if="item.shop.logo"
|
||||
class="border-border h-14 w-14 rounded-sm border object-cover"
|
||||
:src="item.shop.logo"
|
||||
:alt="pick(item.shop.name, locale)"
|
||||
/>
|
||||
<span
|
||||
v-else
|
||||
class="border-border bg-bg text-muted flex h-14 w-14 items-center justify-center rounded-sm border text-lg"
|
||||
>{{ pick(item.shop.name, locale).slice(0, 1) }}</span
|
||||
>
|
||||
<div class="flex min-w-0 flex-1 flex-col gap-1">
|
||||
<strong class="text-sm text-text">{{ pick(item.shop.name, locale) }}</strong>
|
||||
<span class="text-xs text-muted">{{ item.shop.company }}</span>
|
||||
<strong class="text-text text-sm">{{ pick(item.shop.name, locale) }}</strong>
|
||||
<span class="text-muted text-xs">{{ item.shop.company }}</span>
|
||||
</div>
|
||||
<div class="flex gap-2 max-sm:w-full">
|
||||
<NuxtLink class="inline-flex items-center rounded-md border border-border bg-surface px-2.5 py-1 text-[13px] font-medium text-text no-underline" :to="`/stores/${item.shop.slug}`">{{ t("user.enterStore") }}</NuxtLink>
|
||||
<VBtn size="sm" type="button" :disabled="removingId === item.shop.id" @click="removeStoreFavorite(item.shop.id)">{{ t("user.removeFavorite") }}</VBtn>
|
||||
<NuxtLink
|
||||
class="border-border bg-surface text-text inline-flex items-center rounded-md border px-2.5 py-1 text-[13px] font-medium no-underline"
|
||||
:to="`/stores/${item.shop.slug}`"
|
||||
>{{ t("user.enterStore") }}</NuxtLink
|
||||
>
|
||||
<VBtn
|
||||
size="sm"
|
||||
type="button"
|
||||
:disabled="removingId === item.shop.id"
|
||||
@click="removeStoreFavorite(item.shop.id)"
|
||||
>{{ t("user.removeFavorite") }}</VBtn
|
||||
>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
@@ -145,4 +207,3 @@ async function removeStoreFavorite(storeId: string): Promise<void> {
|
||||
</UiTabs>
|
||||
</VCard>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user