winofy-front/src/components/home/store-card.tsx
Afra ‌ e5b00c4d55 feat: consume MinIO presigned media URLs (feature/minio-integration)
icon/image/logo/cover_image are now MinIO object keys, not URLs -- every
serializer with one of these fields now returns a <field>_url sibling
that's an already-absolute, freshly presigned URL. Added those fields to
every affected type (StoreCategory, StoreListItem, ProductCategory,
ProductListItem) and switched every <img> call site to use the _url field
directly.

Deleted resolveMediaUrl/resolveClientMediaUrl and the
NEXT_PUBLIC_WINOFY_MEDIA_ORIGIN env var -- they existed only to turn
relative paths under the Winofy origin into absolute URLs, which no longer
applies now that media lives on a different host (MinIO) and comes back
pre-resolved.

Also fixes cart-item-row.tsx's product thumbnail, which had been commented
out (broken under the old relative-path assumption).

Restored image_url as a required non-optional field per the doc rather
than treating it as possibly-missing, since every serializer covered by
this migration always includes it (null when no image, not omitted).
2026-08-18 13:32:30 +03:30

27 lines
1.2 KiB
TypeScript

import Link from "next/link";
import type { StoreListItem } from "@/types/api";
/** winofyfrontenddoc (1).md §3.5 store-card. */
export function StoreCard({ store }: { store: StoreListItem }) {
return (
<Link
href={`/stores/${store.uuid}`}
className="flex items-center gap-3 rounded-xl border border-gray-300 bg-white p-3 shadow-sm"
>
<div className="h-[72px] w-[72px] shrink-0 overflow-hidden rounded-[10px] border border-gray-300 bg-muted">
{store.logo_url && (
// eslint-disable-next-line @next/next/no-img-element
<img src={store.logo_url} alt={store.name} className="h-full w-full object-cover" />
)}
</div>
<div className="flex flex-1 flex-col gap-1">
<h3 className="text-[15px] leading-[22px] font-bold text-foreground">{store.name}</h3>
<span className="w-fit rounded-full bg-muted px-2 py-0.5 text-label text-gray-600">{store.category.name}</span>
<div className="flex items-center justify-between text-label text-gray-600">
<span>⭐ {Number(store.rating_avg).toFixed(1)}</span>
<span>{store.is_open ? "باز" : "بسته"}</span>
</div>
</div>
</Link>
);
}