feat(pdp): redesign variant comparison table for multi-variant products, exclude media keys, and add calendar invites
This commit is contained in:
parent
148ebceae4
commit
16dbaa0916
6 changed files with 335 additions and 194 deletions
|
|
@ -248,7 +248,6 @@ export default async function ProductDetailPage({ params }: ProductDetailPagePro
|
|||
|
||||
const { product, reviews = [], related_products = [], specifications = [] } = data;
|
||||
const related = related_products.slice(0, 5);
|
||||
const comparisonProducts = [product, ...related_products.filter((p: any) => p.product_id !== product.product_id)].slice(0, 5);
|
||||
const specGroups = groupSpecs(specifications, product);
|
||||
|
||||
const additionalInfoRows: { label: string; value: string }[] = [];
|
||||
|
|
@ -458,8 +457,8 @@ export default async function ProductDetailPage({ params }: ProductDetailPagePro
|
|||
|
||||
{related.length > 0 && <YouMayAlsoLike products={related} />}
|
||||
|
||||
{comparisonProducts.length > 0 && (
|
||||
<QuickComparisonTable products={comparisonProducts} />
|
||||
{(product.variants?.length || 0) > 1 && (
|
||||
<QuickComparisonTable product={product} />
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ import {
|
|||
Smartphone,
|
||||
Wrench,
|
||||
ArrowRight,
|
||||
Calendar,
|
||||
Download,
|
||||
ExternalLink,
|
||||
} from 'lucide-react';
|
||||
import { AnnouncementBar } from '@/layout/AnnouncementBar';
|
||||
import { Header } from '@/layout/Header';
|
||||
|
|
@ -96,6 +99,7 @@ function BookingSuccessContent() {
|
|||
const needsVerify = searchParams.get('verify') === '1';
|
||||
|
||||
const [jobDetails, setJobDetails] = useState<any | null>(null);
|
||||
const [calendarInvite, setCalendarInvite] = useState<any | null>(null);
|
||||
const [layoutCMS, setLayoutCMS] = useState<any[]>([]);
|
||||
const [verifyState, setVerifyState] = useState<'idle' | 'verifying' | 'done'>(
|
||||
needsVerify ? 'verifying' : 'idle'
|
||||
|
|
@ -276,6 +280,16 @@ function BookingSuccessContent() {
|
|||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const target = jobId || (jobNoParam && jobNoParam !== 'SRV-BOOKING' ? jobNoParam : '');
|
||||
if (target) {
|
||||
serviceBookingService
|
||||
.fetchCalendarInvite(target)
|
||||
.then((data) => setCalendarInvite(data))
|
||||
.catch(() => setCalendarInvite(null));
|
||||
}
|
||||
}, [jobId, jobNoParam]);
|
||||
|
||||
const job = unwrapJob(jobDetails);
|
||||
const payment = firstPayment(job);
|
||||
const isPaid =
|
||||
|
|
@ -454,6 +468,45 @@ function BookingSuccessContent() {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{calendarInvite && (
|
||||
<div className="bg-gradient-to-r from-blue-50 to-indigo-50 border border-blue-200 p-5 rounded-lg flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||
<div className="flex items-start gap-3.5">
|
||||
<div className="w-10 h-10 rounded-full bg-blue-600 text-white flex items-center justify-center shrink-0 mt-0.5">
|
||||
<Calendar className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-[11px] font-bold uppercase tracking-wider text-blue-700">Walk-In Calendar Invite</div>
|
||||
<h4 className="text-[15px] font-bold text-gray-900 mt-0.5">
|
||||
Slot: {new Date(calendarInvite.scheduled_start).toLocaleString('en-IN', { dateStyle: 'medium', timeStyle: 'short' })}
|
||||
</h4>
|
||||
<p className="text-[12px] text-gray-600 mt-1 max-w-xl">
|
||||
Add this repair appointment to your personal calendar to receive automatic pre-service notifications and a reminder before your slot.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap sm:flex-nowrap items-center gap-2 shrink-0">
|
||||
<a
|
||||
href={calendarInvite.google_calendar_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white text-[12px] font-bold rounded flex items-center gap-1.5 shadow-sm transition"
|
||||
>
|
||||
<Calendar className="w-3.5 h-3.5" />
|
||||
Add to Google Calendar
|
||||
<ExternalLink className="w-3 h-3 ml-0.5 opacity-80" />
|
||||
</a>
|
||||
<a
|
||||
href={`http://localhost:8000${calendarInvite.ics_download_url}`}
|
||||
download
|
||||
className="px-4 py-2.5 bg-white hover:bg-gray-50 border border-gray-300 text-gray-800 text-[12px] font-semibold rounded flex items-center gap-1.5 shadow-sm transition"
|
||||
>
|
||||
<Download className="w-3.5 h-3.5" />
|
||||
Download .ics Invite
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-5">
|
||||
<div className="border border-[#e5e5e5] p-5 space-y-4">
|
||||
<div className="flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider text-[#222] border-b border-[#e5e5e5] pb-2">
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import {
|
|||
Image as ImageIcon,
|
||||
Maximize2,
|
||||
KeyRound,
|
||||
Download,
|
||||
ExternalLink,
|
||||
} from 'lucide-react';
|
||||
import { BlurHashImage } from '@/components/ui/BlurHashImage';
|
||||
import { AnnouncementBar } from '@/layout/AnnouncementBar';
|
||||
|
|
@ -61,6 +63,7 @@ export default function ServiceJobTrackingPage({
|
|||
const { isAuthenticated, accessToken, authReady, bootstrapAuth } = useAuthStore();
|
||||
|
||||
const [job, setJob] = useState<any>(null);
|
||||
const [calendarInvite, setCalendarInvite] = useState<any | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
||||
const [actionLoading, setActionLoading] = useState(false);
|
||||
|
|
@ -99,6 +102,13 @@ export default function ServiceJobTrackingPage({
|
|||
job_id: item?.job_id || job_id,
|
||||
job_no: item?.job_no,
|
||||
});
|
||||
|
||||
if (item?.fulfillment_type === 'WALK_IN' || item?.appointment) {
|
||||
serviceBookingService
|
||||
.fetchCalendarInvite(item?.job_id || job_id)
|
||||
.then((cal) => setCalendarInvite(cal))
|
||||
.catch(() => setCalendarInvite(null));
|
||||
}
|
||||
} catch (err: any) {
|
||||
setErrorMsg(err.message || 'Failed to retrieve tracking details.');
|
||||
} finally {
|
||||
|
|
@ -533,10 +543,15 @@ export default function ServiceJobTrackingPage({
|
|||
})()}
|
||||
|
||||
{job.appointment && (
|
||||
<div className="bg-white border border-[#e5e5e5] p-5 space-y-3 text-[13px]">
|
||||
<h4 className="font-semibold text-[#222] uppercase tracking-wider text-[11px] border-b border-[#e5e5e5] pb-2">
|
||||
<div className="bg-white border border-[#e5e5e5] p-5 space-y-4 text-[13px]">
|
||||
<div className="flex items-center justify-between border-b border-[#e5e5e5] pb-2">
|
||||
<h4 className="font-semibold text-[#222] uppercase tracking-wider text-[11px]">
|
||||
Booking Schedule
|
||||
</h4>
|
||||
<span className="text-[11px] font-bold text-blue-600 bg-blue-50 px-2 py-0.5 rounded">
|
||||
Walk-In
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-start gap-3">
|
||||
<Calendar className="w-5 h-5 text-primary shrink-0 mt-0.5" />
|
||||
<div>
|
||||
|
|
@ -550,16 +565,46 @@ export default function ServiceJobTrackingPage({
|
|||
})}
|
||||
</div>
|
||||
<div className="text-gray-500 font-mono text-[12px] mt-0.5">
|
||||
Start:{' '}
|
||||
Slot:{' '}
|
||||
{new Date(
|
||||
job.appointment.scheduled_start
|
||||
).toLocaleTimeString('en-US', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})}{' '}
|
||||
–{' '}
|
||||
{new Date(
|
||||
job.appointment.scheduled_end
|
||||
).toLocaleTimeString('en-US', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{calendarInvite && (
|
||||
<div className="pt-2 border-t border-[#f0f0f0] space-y-2">
|
||||
<a
|
||||
href={calendarInvite.google_calendar_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="w-full py-2 px-3 bg-blue-600 hover:bg-blue-700 text-white font-bold text-[12px] rounded flex items-center justify-center gap-1.5 transition shadow-sm"
|
||||
>
|
||||
<Calendar className="w-3.5 h-3.5" />
|
||||
Add to Google Calendar
|
||||
<ExternalLink className="w-3 h-3 ml-0.5 opacity-80" />
|
||||
</a>
|
||||
<a
|
||||
href={`http://localhost:8000${calendarInvite.ics_download_url}`}
|
||||
download
|
||||
className="w-full py-2 px-3 bg-gray-50 hover:bg-gray-100 border border-gray-200 text-gray-700 font-semibold text-[12px] rounded flex items-center justify-center gap-1.5 transition"
|
||||
>
|
||||
<Download className="w-3.5 h-3.5" />
|
||||
Download .ics Calendar File
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,179 +1,206 @@
|
|||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import Image from 'next/image';
|
||||
import { useState } from 'react';
|
||||
import { Check, ShoppingCart } from 'lucide-react';
|
||||
import { Check, ShoppingCart, ShieldCheck, FileText } from 'lucide-react';
|
||||
import BlurHashImage from '@/components/ui/BlurHashImage';
|
||||
import { ProductResponse } from '@/services/api/catalogService';
|
||||
import { ProductResponse, ProductVariantResponse } from '@/services/api/catalogService';
|
||||
import { useCartStore } from '@/store/cartStore';
|
||||
import { formatCatalogPriceLabel, formatCurrency, getImageUrl } from '@/lib/utils';
|
||||
import { formatCurrency, getImageUrl } from '@/lib/utils';
|
||||
|
||||
interface QuickComparisonTableProps {
|
||||
products: ProductResponse[];
|
||||
product: ProductResponse;
|
||||
}
|
||||
|
||||
function priceLabel(product: ProductResponse): string {
|
||||
const label = formatCatalogPriceLabel(product);
|
||||
return label === formatCurrency(0) ? '—' : label;
|
||||
}
|
||||
|
||||
function productImage(product: ProductResponse): string {
|
||||
return getImageUrl(product.images?.[0]?.image_url || product.variants?.[0]?.images?.[0]?.image_url);
|
||||
}
|
||||
|
||||
function extraAttributes(product: ProductResponse): { label: string; values: string[] }[] {
|
||||
const buckets: Record<string, { label: string; values: Set<string> }> = {};
|
||||
|
||||
(product.variants || []).forEach((variant) => {
|
||||
(variant.attributes || []).forEach((attr) => {
|
||||
const raw = attr.attribute_name || attr.attribute_code || '';
|
||||
const value = String(attr.attribute_value || '').trim();
|
||||
if (!raw || !value) return;
|
||||
const key = raw.trim().toLowerCase().replace(/[\s-]+/g, '_');
|
||||
if (!buckets[key]) {
|
||||
let label = raw.replace(/[_-]+/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
if (['qul', 'qual'].includes(key)) label = 'Quality';
|
||||
else if (['clr'].includes(key)) label = 'Color';
|
||||
else if (['str'].includes(key)) label = 'Storage';
|
||||
buckets[key] = {
|
||||
label,
|
||||
values: new Set(),
|
||||
};
|
||||
}
|
||||
buckets[key].values.add(value);
|
||||
});
|
||||
function getVariantTitle(variant: ProductVariantResponse, fallbackIndex: number): string {
|
||||
const validAttrs = (variant.attributes || []).filter((a) => {
|
||||
const key = (a.attribute_name || a.attribute_code || '').toLowerCase().trim();
|
||||
return a.attribute_value && !['media_key', 'parent_media_key'].includes(key);
|
||||
});
|
||||
|
||||
return Object.values(buckets)
|
||||
.map((item) => ({
|
||||
label: item.label,
|
||||
values: Array.from(item.values),
|
||||
}))
|
||||
.slice(0, 3);
|
||||
if (validAttrs.length > 0) {
|
||||
return validAttrs
|
||||
.map((a) => {
|
||||
const name = a.attribute_name ? `${a.attribute_name}: ` : '';
|
||||
return `${name}${a.attribute_value}`;
|
||||
})
|
||||
.join(' | ');
|
||||
}
|
||||
|
||||
function ctaKind(product: ProductResponse): 'view' | 'cart' {
|
||||
return (product.variants?.length || 0) > 1 ? 'view' : 'cart';
|
||||
return variant.sku || `Variant ${fallbackIndex + 1}`;
|
||||
}
|
||||
|
||||
export function QuickComparisonTable({ products }: QuickComparisonTableProps) {
|
||||
function getVariantImage(product: ProductResponse, variant: ProductVariantResponse): string {
|
||||
const img = variant.images?.[0]?.image_url || product.images?.[0]?.image_url;
|
||||
return getImageUrl(img);
|
||||
}
|
||||
|
||||
export function QuickComparisonTable({ product }: QuickComparisonTableProps) {
|
||||
const addToCart = useCartStore((state) => state.addToCart);
|
||||
const [addedId, setAddedId] = useState<string | null>(null);
|
||||
const [addedVariantId, setAddedVariantId] = useState<string | null>(null);
|
||||
|
||||
if (!products.length) return null;
|
||||
const variants = product?.variants || [];
|
||||
// Strictly only show when the product has multiple variants (> 1)
|
||||
if (variants.length <= 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const handleAdd = async (product: ProductResponse) => {
|
||||
const variant = product.variants?.[0];
|
||||
if (!variant) return;
|
||||
const handleAdd = async (variant: ProductVariantResponse) => {
|
||||
await addToCart(product, variant, 1);
|
||||
setAddedId(product.product_id);
|
||||
setTimeout(() => setAddedId(null), 1800);
|
||||
setAddedVariantId(variant.variant_id);
|
||||
setTimeout(() => setAddedVariantId(null), 1800);
|
||||
};
|
||||
|
||||
const labelCls =
|
||||
'sticky left-0 z-10 w-[150px] min-w-[150px] px-4 py-4 text-[13px] font-medium text-gray-500 text-left align-middle bg-[#f3f4f6]';
|
||||
const cellCls = 'px-5 py-4 min-w-[170px] align-middle text-center';
|
||||
'sticky left-0 z-10 w-[160px] min-w-[160px] px-5 py-4 text-[13px] font-semibold text-gray-700 text-left align-middle bg-[#f3f4f6] border-b border-gray-200';
|
||||
const cellCls = 'px-5 py-4 min-w-[200px] align-middle text-center border-b border-gray-200';
|
||||
|
||||
return (
|
||||
<section className="mb-10">
|
||||
<h3 className="text-[20px] font-semibold text-gray-800 mb-4 tracking-tight">Quick Comparison</h3>
|
||||
<div className="overflow-x-auto rounded-md border border-gray-200">
|
||||
<table className="w-full border-collapse min-w-[860px]">
|
||||
<section className="mb-12">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<h3 className="text-[20px] font-bold text-gray-800 tracking-tight">Variant Comparison</h3>
|
||||
<span className="text-[12px] font-medium text-gray-500 bg-gray-100 px-2.5 py-0.5 rounded-full">
|
||||
{variants.length} Options
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-auto rounded-lg border border-gray-200 shadow-sm bg-white">
|
||||
<table className="w-full border-collapse min-w-[700px]">
|
||||
{/* Variant Header Row */}
|
||||
<thead>
|
||||
<tr className="bg-white">
|
||||
<th className={labelCls} />
|
||||
{products.map((prod) => {
|
||||
const img = productImage(prod);
|
||||
<th className={`${labelCls} bg-white text-gray-400 font-normal`}>Option</th>
|
||||
{variants.map((v, idx) => {
|
||||
const img = getVariantImage(product, v);
|
||||
const title = getVariantTitle(v, idx);
|
||||
return (
|
||||
<th key={prod.product_id} className={`${cellCls} font-normal bg-white`}>
|
||||
<Link
|
||||
href={`/products/${prod.slug}`}
|
||||
className="block text-[13px] font-medium text-gray-700 leading-snug hover:text-primary line-clamp-2 min-h-[36px] mb-3"
|
||||
>
|
||||
{prod.name}
|
||||
</Link>
|
||||
<Link
|
||||
href={`/products/${prod.slug}`}
|
||||
className="w-[92px] h-[92px] mx-auto bg-white border border-gray-200 rounded-md p-2 flex items-center justify-center hover:border-primary/40 transition-colors"
|
||||
>
|
||||
<th key={v.variant_id} className={`${cellCls} font-normal bg-white`}>
|
||||
<div className="w-[100px] h-[100px] mx-auto bg-gray-50 border border-gray-200 rounded-lg p-2 flex items-center justify-center mb-3">
|
||||
<BlurHashImage
|
||||
src={img}
|
||||
alt={prod.name}
|
||||
width={84}
|
||||
height={84}
|
||||
alt={title}
|
||||
width={90}
|
||||
height={90}
|
||||
className="max-h-full max-w-full object-contain"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
<div className="text-[13px] font-semibold text-gray-800 leading-snug line-clamp-2 px-1 min-h-[36px]">
|
||||
{title}
|
||||
</div>
|
||||
</th>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr className="bg-[#f8f8f8]">
|
||||
<td className={labelCls}>Price</td>
|
||||
{products.map((prod) => (
|
||||
<td key={prod.product_id} className={`${cellCls} text-[14px] font-bold text-gray-900`}>
|
||||
{priceLabel(prod)}
|
||||
{/* 1. Name / Specifications Row */}
|
||||
<tr className="bg-[#fcfcfd]">
|
||||
<td className={labelCls}>Name / Specification</td>
|
||||
{variants.map((v, idx) => (
|
||||
<td key={v.variant_id} className={`${cellCls} text-[13px] font-medium text-gray-800`}>
|
||||
{getVariantTitle(v, idx)}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
|
||||
{/* 2. Price Row */}
|
||||
<tr className="bg-white">
|
||||
<td className={labelCls}>Add to cart</td>
|
||||
{products.map((prod) => {
|
||||
const kind = ctaKind(prod);
|
||||
const justAdded = addedId === prod.product_id;
|
||||
<td className={labelCls}>Price</td>
|
||||
{variants.map((v) => {
|
||||
const price = Number(v.price) || 0;
|
||||
const comparePrice = v.compare_price ? Number(v.compare_price) : 0;
|
||||
const hasDiscount = comparePrice > price;
|
||||
const discountPercent = hasDiscount
|
||||
? Math.round(((comparePrice - price) / comparePrice) * 100)
|
||||
: 0;
|
||||
|
||||
return (
|
||||
<td key={prod.product_id} className={cellCls}>
|
||||
{kind === 'view' ? (
|
||||
<Link
|
||||
href={`/products/${prod.slug}`}
|
||||
className="inline-flex items-center justify-center min-w-[120px] bg-primary hover:bg-primary-hover text-white text-[13px] font-semibold px-4 py-2.5 rounded-md transition-colors"
|
||||
>
|
||||
View Products
|
||||
</Link>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void handleAdd(prod)}
|
||||
className="inline-flex items-center justify-center gap-1.5 min-w-[120px] bg-primary hover:bg-primary-hover text-white text-[13px] font-semibold px-4 py-2.5 rounded-md transition-colors cursor-pointer"
|
||||
>
|
||||
{justAdded ? <Check size={14} /> : <ShoppingCart size={14} />}
|
||||
{justAdded ? 'Added' : 'Add To Cart'}
|
||||
</button>
|
||||
<td key={v.variant_id} className={cellCls}>
|
||||
<div className="flex items-center justify-center gap-2 flex-wrap">
|
||||
<span className="text-[16px] font-bold text-gray-900">
|
||||
{formatCurrency(price)}
|
||||
</span>
|
||||
{hasDiscount && (
|
||||
<>
|
||||
<span className="text-[13px] text-gray-400 line-through">
|
||||
{formatCurrency(comparePrice)}
|
||||
</span>
|
||||
<span className="text-[11px] font-semibold text-emerald-700 bg-emerald-50 border border-emerald-200 px-1.5 py-0.5 rounded">
|
||||
{discountPercent}% OFF
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
|
||||
<tr className="bg-[#f8f8f8]">
|
||||
<td className={`${labelCls} align-top`}>Additional information</td>
|
||||
{products.map((prod) => {
|
||||
const attrs = extraAttributes(prod);
|
||||
{/* 3. Warranty Type Row */}
|
||||
<tr className="bg-[#fcfcfd]">
|
||||
<td className={labelCls}>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<ShieldCheck size={15} className="text-primary flex-shrink-0" />
|
||||
<span>Warranty Type</span>
|
||||
</div>
|
||||
</td>
|
||||
{variants.map((v) => (
|
||||
<td key={v.variant_id} className={`${cellCls} text-[13px] text-gray-700 font-medium`}>
|
||||
{product.warranty_type || 'Standard Warranty'}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
|
||||
{/* 4. Summary Row */}
|
||||
<tr className="bg-white">
|
||||
<td className={labelCls}>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<FileText size={15} className="text-primary flex-shrink-0" />
|
||||
<span>Summary</span>
|
||||
</div>
|
||||
</td>
|
||||
{variants.map((v) => (
|
||||
<td key={v.variant_id} className={`${cellCls} text-[13px] text-gray-600 leading-relaxed max-w-[280px]`}>
|
||||
{product.warranty_summary || '100% Quality Tested & Brand Verified'}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
|
||||
{/* Action Row */}
|
||||
<tr className="bg-[#fcfcfd]">
|
||||
<td className={labelCls}>Action</td>
|
||||
{variants.map((v) => {
|
||||
const justAdded = addedVariantId === v.variant_id;
|
||||
const isOutOfStock = v.status === 'inactive' || (v.available_stock !== undefined && v.available_stock <= 0);
|
||||
|
||||
return (
|
||||
<td key={prod.product_id} className={`${cellCls} align-top text-[12px] leading-relaxed`}>
|
||||
{attrs.length === 0 ? (
|
||||
<span className="text-gray-300">—</span>
|
||||
<td key={v.variant_id} className={cellCls}>
|
||||
<button
|
||||
type="button"
|
||||
disabled={isOutOfStock}
|
||||
onClick={() => void handleAdd(v)}
|
||||
className={`inline-flex items-center justify-center gap-2 min-w-[130px] text-[13px] font-semibold px-4 py-2.5 rounded-md transition-all cursor-pointer shadow-sm ${
|
||||
isOutOfStock
|
||||
? 'bg-gray-200 text-gray-400 cursor-not-allowed'
|
||||
: justAdded
|
||||
? 'bg-emerald-600 text-white'
|
||||
: 'bg-primary hover:bg-primary-hover text-white hover:shadow'
|
||||
}`}
|
||||
>
|
||||
{isOutOfStock ? (
|
||||
'Out of Stock'
|
||||
) : justAdded ? (
|
||||
<>
|
||||
<Check size={14} className="stroke-[2.5]" />
|
||||
<span>Added</span>
|
||||
</>
|
||||
) : (
|
||||
<div className="space-y-1.5 text-left inline-block">
|
||||
{attrs.map((attr) => (
|
||||
<div key={attr.label}>
|
||||
<span className="text-gray-700 font-medium">{attr.label}: </span>
|
||||
{attr.values.map((value, i) => (
|
||||
<span key={value}>
|
||||
<Link href={`/products/${prod.slug}`} className="text-primary hover:underline">
|
||||
{value}
|
||||
</Link>
|
||||
{i < attr.values.length - 1 ? <span className="text-gray-400">, </span> : null}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<>
|
||||
<ShoppingCart size={14} />
|
||||
<span>Add To Cart</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</td>
|
||||
);
|
||||
})}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,8 @@ export interface ProductResponse {
|
|||
created_at: string;
|
||||
images: ProductImageResponse[];
|
||||
variants: ProductVariantResponse[];
|
||||
warranty_type?: string | null;
|
||||
warranty_summary?: string | null;
|
||||
rating?: number;
|
||||
review_count?: number;
|
||||
badge?: 'HOT' | 'NEW' | 'SALE' | null;
|
||||
|
|
|
|||
|
|
@ -496,6 +496,21 @@ export const serviceBookingService = {
|
|||
});
|
||||
},
|
||||
|
||||
fetchCalendarInvite(jobId: string): Promise<{
|
||||
job_id: string;
|
||||
job_no: string;
|
||||
appointment_id: string;
|
||||
scheduled_start: string;
|
||||
scheduled_end: string;
|
||||
device_name: string;
|
||||
google_calendar_url: string;
|
||||
store_name: string;
|
||||
store_address: string;
|
||||
ics_download_url: string;
|
||||
}> {
|
||||
return apiFetch(`/api/v1/service/jobs/${jobId}/calendar-invite`);
|
||||
},
|
||||
|
||||
fetchServicePageLayout(): Promise<any[]> {
|
||||
return apiFetch<any[]>('/api/v1/storefront/layout/services');
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue