diff --git a/app/sitemap.ts b/app/sitemap.ts
new file mode 100644
index 0000000..0c5d1ee
--- /dev/null
+++ b/app/sitemap.ts
@@ -0,0 +1,71 @@
+import type { MetadataRoute } from 'next';
+
+const SITE_URL = 'https://ifixkart.trionixsolution.com';
+
+const API_URL =
+ process.env.API_URL ||
+ process.env.NEXT_PUBLIC_API_URL ||
+ 'https://ifixkartbe.trionixsolution.com';
+
+// Rebuild the sitemap at most once an hour
+export const revalidate = 3600;
+
+const STATIC_ROUTES: MetadataRoute.Sitemap = [
+ { url: `${SITE_URL}/`, changeFrequency: 'daily', priority: 1 },
+ { url: `${SITE_URL}/shop`, changeFrequency: 'daily', priority: 0.9 },
+ { url: `${SITE_URL}/repair-services`, changeFrequency: 'weekly', priority: 0.8 },
+ { url: `${SITE_URL}/about`, changeFrequency: 'monthly', priority: 0.4 },
+ { url: `${SITE_URL}/contact`, changeFrequency: 'monthly', priority: 0.4 },
+ { url: `${SITE_URL}/faqs`, changeFrequency: 'monthly', priority: 0.3 },
+ { url: `${SITE_URL}/blog`, changeFrequency: 'weekly', priority: 0.5 },
+];
+
+interface CatalogCard {
+ slug: string;
+ variant_sku?: string | null;
+ variant_url?: string | null;
+}
+
+/**
+ * Emits one URL per product variant (Sunsky-style):
+ * /products/[slug]?variant=[sku]
+ * Google indexes query-param variants as long as they are internally linked
+ * and each PDP URL carries a self-referential canonical tag.
+ */
+export default async function sitemap(): Promise
{
+ const entries: MetadataRoute.Sitemap = [...STATIC_ROUTES];
+ const seen = new Set();
+
+ try {
+ // 40 pages x 100 = up to 4000 variant cards per sitemap build
+ for (let page = 1; page <= 40; page++) {
+ const res = await fetch(
+ `${API_URL}/api/v1/catalog/products?page=${page}&limit=100&expand_variants=true`,
+ { next: { revalidate: 3600, tags: ['products'] } }
+ );
+ if (!res.ok) break;
+ const data = await res.json();
+ const products: CatalogCard[] = data?.products || [];
+ if (products.length === 0) break;
+
+ for (const p of products) {
+ const path = p.variant_url || `/products/${p.slug}`;
+ if (seen.has(path)) continue;
+ seen.add(path);
+ entries.push({
+ url: `${SITE_URL}${path}`,
+ changeFrequency: 'weekly',
+ priority: p.variant_url ? 0.7 : 0.8,
+ });
+ }
+
+ const total = typeof data?.total === 'number' ? data.total : 0;
+ if (page * 100 >= total) break;
+ }
+ } catch (err) {
+ // Backend unreachable: sitemap still ships with static routes
+ console.error('Sitemap: failed to fetch catalog for variant URLs:', err);
+ }
+
+ return entries;
+}
diff --git a/components/FloatingButtons.tsx b/components/FloatingButtons.tsx
index 76ec6d7..304a66a 100644
--- a/components/FloatingButtons.tsx
+++ b/components/FloatingButtons.tsx
@@ -1,20 +1,59 @@
"use client";
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useCallback } from 'react';
+import { usePathname } from 'next/navigation';
import { ChevronUp } from 'lucide-react';
import { motion, AnimatePresence } from 'framer-motion';
+import { useCartStore } from '@/store/cartStore';
+
+/** Height of the fixed compare strip at the bottom (CompareBar: py-3 + 36px row + border). */
+const COMPARE_BAR_HEIGHT_PX = 76;
export const FloatingButtons: React.FC = () => {
const [showScrollTop, setShowScrollTop] = useState(false);
+ /** Extra bottom offset so this button is never covered by fixed bottom bars. */
+ const [barOffset, setBarOffset] = useState(0);
+ const pathname = usePathname();
+
+ const compareList = useCartStore((s) => s.compareList) || [];
+ const hydrated = useCartStore((s) => s._hasHydrated);
+ const compareBarVisible =
+ hydrated && pathname !== '/compare' && compareList.length > 0;
+
+ const measure = useCallback(() => {
+ // PDP sticky purchase bar (rendered in ProductInteractiveGrid) — only counts
+ // while it is actually in the layout and visible.
+ const bar = document.querySelector('.sticky-purchase-bar');
+ const purchaseBarH =
+ bar && bar.offsetHeight > 0 && bar.getBoundingClientRect().height > 0
+ ? bar.offsetHeight
+ : 0;
+ const compareH = compareBarVisible ? COMPARE_BAR_HEIGHT_PX : 0;
+ setBarOffset((prev) => {
+ const next = Math.max(purchaseBarH, compareH);
+ return prev === next ? prev : next;
+ });
+ }, [compareBarVisible]);
useEffect(() => {
const handleScroll = () => {
setShowScrollTop(window.scrollY > 400);
+ measure();
};
- window.addEventListener('scroll', handleScroll);
- return () => window.removeEventListener('scroll', handleScroll);
- }, []);
+ handleScroll();
+ window.addEventListener('scroll', handleScroll, { passive: true });
+ window.addEventListener('resize', measure, { passive: true });
+ return () => {
+ window.removeEventListener('scroll', handleScroll);
+ window.removeEventListener('resize', measure);
+ };
+ }, [measure]);
+
+ // Re-measure when the compare strip appears/disappears without scrolling.
+ useEffect(() => {
+ measure();
+ }, [measure]);
const scrollToTop = () => {
window.scrollTo({
@@ -24,9 +63,14 @@ export const FloatingButtons: React.FC = () => {
};
return (
-
-
- {/* Scroll to Top */}
+
+ {/* Scroll to Top — hidden on phones (<640px): fixed bottom bars live there,
+ and both iOS and Android scroll to top from the status bar. */}
{showScrollTop && (
{
);
};
-
diff --git a/components/MobileDrawer.tsx b/components/MobileDrawer.tsx
index 9e9797d..c03d08d 100644
--- a/components/MobileDrawer.tsx
+++ b/components/MobileDrawer.tsx
@@ -31,11 +31,22 @@ export const MobileDrawer: React.FC
= ({ isOpen, onClose }) =
return () => document.removeEventListener('keydown', handleKeyDown);
}, [isOpen, onClose]);
+ // Lock background scroll while the drawer is open (same pattern as CartDrawer),
+ // and restore the previous value on close.
+ React.useEffect(() => {
+ if (!isOpen) return;
+ const prev = document.body.style.overflow;
+ document.body.style.overflow = 'hidden';
+ return () => {
+ document.body.style.overflow = prev;
+ };
+ }, [isOpen]);
+
const links = [
{ name: 'Home', href: '/' },
{ name: 'Shop', href: '/shop' },
- { name: 'Services', href: '/service' },
- { name: 'Top Deals', href: '/shop' },
+ { name: 'Top Deals', href: '/shop?tag=deals' },
+ { name: 'Services', href: '/services' },
];
return (
@@ -57,7 +68,7 @@ export const MobileDrawer: React.FC = ({ isOpen, onClose }) =
animate={{ x: 0 }}
exit={{ x: '-100%' }}
transition={{ type: 'tween', duration: 0.3 }}
- className="fixed top-0 left-0 bottom-0 w-[280px] bg-white z-50 xl:hidden flex flex-col justify-between shadow-xl overflow-y-auto"
+ className="fixed top-0 left-0 bottom-0 w-[280px] max-w-[85vw] bg-white z-50 xl:hidden flex flex-col justify-between shadow-xl overflow-y-auto overscroll-contain"
>
{/* Header */}
@@ -67,9 +78,10 @@ export const MobileDrawer: React.FC = ({ isOpen, onClose }) =
-
+
@@ -113,8 +125,8 @@ export const MobileDrawer: React.FC = ({ isOpen, onClose }) =
)}
- {/* Footer */}
-
+ {/* Footer — honors iOS home indicator / Android gesture bar */}
+
© {new Date().getFullYear()} iFixKart. All Rights Reserved.
diff --git a/components/QuickViewModal.tsx b/components/QuickViewModal.tsx
index 235a823..91af5da 100644
--- a/components/QuickViewModal.tsx
+++ b/components/QuickViewModal.tsx
@@ -242,7 +242,7 @@ export const QuickViewModal: React.FC
= ({
e.stopPropagation()}
- className="bg-white w-full max-w-[1000px] md:h-[min(500px,82vh)] md:w-[min(1000px,calc(82vh*2))] overflow-hidden shadow-2xl relative flex flex-col md:flex-row text-left mx-10 md:mx-16"
+ className="bg-white w-full max-w-[1000px] md:h-[min(500px,82dvh)] md:w-[min(1000px,calc(82dvh*2))] overflow-hidden shadow-2xl relative flex flex-col md:flex-row text-left mx-3 md:mx-16"
>
= ({ src, alt }) => {
+ const [hasError, setHasError] = useState(false);
+
+ useEffect(() => {
+ setHasError(false);
+ }, [src]);
+
+ if (!src || hasError) {
+ return ;
+ }
+ return (
+ setHasError(true)}
+ />
+ );
+};
+
function mapProducts(products: ProductCardResponse[]): RatedItem[] {
return products.slice(0, 6).map((p) => ({
id: p.product_id,
@@ -136,15 +157,7 @@ export const TopDealsMegaMenu: React.FC<{ cms?: MegaMenuData | null }> = ({
className="flex flex-col items-center gap-2 group/item text-center min-w-0"
>
- {item.image ? (
-
- ) : (
-
- )}
+
{item.name}
diff --git a/components/WishlistModal.tsx b/components/WishlistModal.tsx
index b462ea3..82c2b95 100644
--- a/components/WishlistModal.tsx
+++ b/components/WishlistModal.tsx
@@ -52,7 +52,7 @@ export const WishlistModal: React.FC = ({ onClose }) => {
>
e.stopPropagation()}
- className="bg-white w-full max-w-[740px] rounded-2xl shadow-2xl overflow-hidden relative flex flex-col max-h-[85vh] text-left"
+ className="bg-white w-full max-w-[740px] rounded-2xl shadow-2xl overflow-hidden relative flex flex-col max-h-[85dvh] text-left"
>
{/* Header */}
diff --git a/components/auth/GoogleAuthModal.tsx b/components/auth/GoogleAuthModal.tsx
index 6d5e56d..fb0b1ce 100644
--- a/components/auth/GoogleAuthModal.tsx
+++ b/components/auth/GoogleAuthModal.tsx
@@ -57,6 +57,7 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
const [loading, setLoading] = useState(false);
const [error, setError] = useState
(null);
const [csrfToken, setCsrfToken] = useState('');
+ const [fetchingCsrf, setFetchingCsrf] = useState(false);
const [mode, setMode] = useState<'login' | 'link'>('login');
const [linkEmail, setLinkEmail] = useState('');
const [linkPassword, setLinkPassword] = useState('');
@@ -64,21 +65,36 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
const setAuth = useAuthStore((state) => state.setAuth);
+ const fetchCsrfToken = async () => {
+ setFetchingCsrf(true);
+ try {
+ const res = await fetch(`${API_BASE_URL}/api/v1/customer/auth/google/state`, {
+ headers: {
+ 'X-Requested-With': 'XMLHttpRequest',
+ },
+ });
+ if (res.ok) {
+ const data = await res.json();
+ if (data?.state) {
+ setCsrfToken(data.state);
+ return data.state;
+ }
+ }
+ } catch (err) {
+ console.error('Failed to fetch OAuth state token:', err);
+ } finally {
+ setFetchingCsrf(false);
+ }
+ return '';
+ };
+
useEffect(() => {
if (!isOpen) return;
const prev = document.body.style.overflow;
document.body.style.overflow = 'hidden';
- const array = new Uint32Array(4);
- if (typeof window !== 'undefined' && window.crypto) {
- window.crypto.getRandomValues(array);
- setCsrfToken(Array.from(array, (dec) => dec.toString(16)).join(''));
- } else {
- setCsrfToken(
- Math.random().toString(36).substring(2, 15) +
- Math.random().toString(36).substring(2, 15)
- );
- }
+ // Fetch HMAC-signed CSRF state token from backend
+ fetchCsrfToken();
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
@@ -99,7 +115,7 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
}
}, [isOpen]);
- const handleAuthCodeSubmit = async (code: string) => {
+ const handleAuthCodeSubmit = async (code: string, returnedState?: string) => {
setLoading(true);
setError(null);
try {
@@ -108,6 +124,8 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
? localStorage.getItem('guest_session_id') || undefined
: undefined;
+ const stateToSend = returnedState || csrfToken;
+
const res = await fetch(`${API_BASE_URL}/api/v1/customer/auth/google`, {
method: 'POST',
headers: {
@@ -117,7 +135,7 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
credentials: 'include',
body: JSON.stringify({
code,
- state: csrfToken,
+ state: stateToSend,
guest_session_id: guestSessionId,
redirect_uri: 'postmessage',
}),
@@ -147,6 +165,7 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
onClose();
} catch (err: any) {
setError(err.message || 'Google authentication failed. Please try again.');
+ fetchCsrfToken();
} finally {
setLoading(false);
}
@@ -205,12 +224,26 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
}
};
+ const handleGoogleClick = async () => {
+ setError(null);
+ let token = csrfToken;
+ if (!token) {
+ token = await fetchCsrfToken();
+ }
+ if (token) {
+ googleLogin();
+ } else {
+ setError('Unable to establish secure authentication session. Please retry.');
+ }
+ };
+
const googleLogin = useGoogleLogin({
onSuccess: (codeResponse) => {
- if (codeResponse.code) handleAuthCodeSubmit(codeResponse.code);
+ if (codeResponse.code) handleAuthCodeSubmit(codeResponse.code, codeResponse.state);
},
onError: () => {
setError('Google Login popup was closed or authentication failed.');
+ fetchCsrfToken();
},
flow: 'auth-code',
state: csrfToken,
@@ -305,12 +338,12 @@ function GoogleAuthInner({ isOpen, onClose, onSuccess }: GoogleAuthModalProps) {
googleLogin()}
- disabled={loading}
+ onClick={handleGoogleClick}
+ disabled={loading || fetchingCsrf}
className="w-full flex items-center justify-center gap-3 px-4 py-3.5 rounded-lg font-semibold text-[14px] text-[#1a1a1a] bg-white border border-gray-200 hover:border-primary/40 hover:bg-[#F8FBFF] shadow-sm transition-colors disabled:opacity-50 cursor-pointer"
>
- {loading ? 'Connecting Google...' : 'Continue with Google'}
+ {loading ? 'Connecting Google...' : fetchingCsrf ? 'Securing session...' : 'Continue with Google'}
>
) : (
diff --git a/components/catalog/ParentFeatureCatalog.tsx b/components/catalog/ParentFeatureCatalog.tsx
index 08f3c17..48b7ccc 100644
--- a/components/catalog/ParentFeatureCatalog.tsx
+++ b/components/catalog/ParentFeatureCatalog.tsx
@@ -368,16 +368,18 @@ export function ParentFeatureCatalog({ category }: ParentFeatureCatalogProps) {
return (
-
+
+
+
{p.badge && (
{p.badge}
@@ -411,7 +413,7 @@ export function ParentFeatureCatalog({ category }: ParentFeatureCatalogProps) {
-
+
{p.name}
diff --git a/components/catalog/StandardCatalog.tsx b/components/catalog/StandardCatalog.tsx
index 46be943..65dcece 100644
--- a/components/catalog/StandardCatalog.tsx
+++ b/components/catalog/StandardCatalog.tsx
@@ -81,12 +81,13 @@ function CatalogProductCard({
const compareList = useCartStore((s) => s.compareList) || [];
const variant = product.variants?.[0];
+ const productUrl = product.variant_url || `/products/${product.slug}`;
const { price, oldPrice, discount: mappedDiscount } = getCatalogPriceInfo(product);
const compare = oldPrice || 0;
const discount =
mappedDiscount ||
(compare > price ? Math.round(((compare - price) / compare) * 100) : 0);
- const image = getImageUrl(product.images[0]?.image_url);
+ const image = getImageUrl((product as any).thumbnail_url || product.images?.[0]?.image_url);
const rating = getDisplayStarCount(product);
const isWishlisted = wishlist.some((i) => i.product_id === product.product_id);
const isCompared = compareList.some((i) => i.product_id === product.product_id);
@@ -98,7 +99,7 @@ function CatalogProductCard({
e.stopPropagation();
if (!variant) return;
if (hasOptions) {
- window.location.href = `/products/${product.slug}`;
+ window.location.href = productUrl;
return;
}
void addToCart(product, variant, 1);
@@ -107,7 +108,7 @@ function CatalogProductCard({
if (viewMode === 'list') {
return (
-
+
{discount > 0 && (
-{discount}%
@@ -121,7 +122,7 @@ function CatalogProductCard({
{product.name}
@@ -215,7 +216,7 @@ function CatalogProductCard({
{image ? (
@@ -233,7 +234,7 @@ function CatalogProductCard({
{product.name}
@@ -400,7 +401,11 @@ export function StandardCatalog({
};
if (selectedCategory !== 'all') paramsBase.category = selectedCategory;
if (selectedBrand !== 'all') paramsBase.brand = selectedBrand;
- if (searchQuery) paramsBase.search = searchQuery;
+ if (searchQuery) {
+ paramsBase.search = searchQuery;
+ // Sunsky-style: keyword searches expand each active variant into its own card
+ paramsBase.expand_variants = 'true';
+ }
const accumulated: ProductResponse[] = [];
const seen = new Set
();
@@ -421,8 +426,10 @@ export function StandardCatalog({
let added = 0;
for (const product of mapped) {
- if (seen.has(product.product_id)) continue;
- seen.add(product.product_id);
+ // Variant-expanded cards share the same product_id — dedupe per variant
+ const dedupeKey = product.variant_url || product.product_id;
+ if (seen.has(dedupeKey)) continue;
+ seen.add(dedupeKey);
accumulated.push(product);
added += 1;
}
@@ -753,13 +760,13 @@ export function StandardCatalog({
) : viewMode === 'grid' ? (
{displayed.map((p) => (
-
+
))}
) : (
{displayed.map((p) => (
-
+
))}
)}
diff --git a/components/compare/CompareBar.tsx b/components/compare/CompareBar.tsx
index acd1108..f1779f8 100644
--- a/components/compare/CompareBar.tsx
+++ b/components/compare/CompareBar.tsx
@@ -18,7 +18,10 @@ export function CompareBar() {
if (!hydrated || pathname === '/compare' || compareList.length === 0) return null;
return (
-
+
diff --git a/components/pdp/ProductInteractiveGrid.tsx b/components/pdp/ProductInteractiveGrid.tsx
index c52d381..4da0414 100644
--- a/components/pdp/ProductInteractiveGrid.tsx
+++ b/components/pdp/ProductInteractiveGrid.tsx
@@ -33,6 +33,7 @@ interface ProductInteractiveGridProps {
product: ProductResponse;
initialReviewsCount: number;
relatedProducts?: ProductResponse[];
+ initialVariantSku?: string;
}
const FALLBACK_TECH_IMAGES: string[] = ['/images/placeholder-product.webp'];
@@ -84,13 +85,26 @@ export const ProductInteractiveGrid: React.FC
= ({
product,
initialReviewsCount,
relatedProducts = [],
+ initialVariantSku,
}) => {
const searchParams = useSearchParams();
const router = useRouter();
+ const getInitialIndex = () => {
+ const key = initialVariantSku || searchParams?.get('variant') || searchParams?.get('sku');
+ if (key && product?.variants?.length) {
+ const decoded = decodeURIComponent(key);
+ const idx = product.variants.findIndex(
+ (v: any) => v.sku === decoded || String(v.variant_id) === decoded
+ );
+ if (idx !== -1) return idx;
+ }
+ return 0;
+ };
+
const [failedImages, setFailedImages] = useState>(new Set());
- const [selectedImage, setSelectedImage] = useState(() => resolveInitialImage(product, 0));
- const [selectedVariantIndex, setSelectedVariantIndex] = useState(0);
+ const [selectedVariantIndex, setSelectedVariantIndex] = useState(getInitialIndex);
+ const [selectedImage, setSelectedImage] = useState(() => resolveInitialImage(product, getInitialIndex()));
const [quantity, setQuantity] = useState(1);
const [added, setAdded] = useState(false);
const [selections, setSelections] = useState>({});
@@ -113,6 +127,30 @@ export const ProductInteractiveGrid: React.FC = ({
variantAttrsMap: Map>;
validValuesByDimension: Map>;
} | null>(null);
+ // Tracks the last variant SKU written to the URL by this component so the
+ // URL-sync effect can skip re-applying selection after history.replaceState.
+ const urlWrittenByUs = useRef(null);
+
+ // SEO: silently sync the browser URL to the selected variant (no reload,
+ // no server round-trip) so every color/spec combination gets a shareable
+ // /products/[slug]?variant=[sku] URL.
+ const syncVariantUrl = (variant: any) => {
+ const sku = variant?.sku;
+ if (!sku || typeof window === 'undefined') return;
+ const slug = (product as any).slug || product.product_id;
+ if (!slug) return;
+ try {
+ const newUrl = `/products/${slug}?variant=${encodeURIComponent(sku)}`;
+ window.history.replaceState(
+ { ...(window.history.state || {}), as: newUrl, url: newUrl },
+ '',
+ newUrl
+ );
+ urlWrittenByUs.current = sku;
+ } catch {
+ // URL sync is best-effort; never block variant selection on it
+ }
+ };
// Initialize lookup maps and default state on mount/product change
useEffect(() => {
@@ -135,13 +173,30 @@ export const ProductInteractiveGrid: React.FC = ({
lookupIndex.current = { variantAttrsMap, validValuesByDimension };
- // Select variant based on URL params or default to first index
- const urlVariantId = searchParams.get('variant');
+ // Select variant based on URL params or default to first index.
+ // `?variant=` accepts either the SKU or the variant_id (SEO URLs use SKU);
+ // `?sku=` is kept for backwards compatibility.
+ const urlVariantKey = initialVariantSku || searchParams.get('variant');
const urlSku = searchParams.get('sku');
- let activeIdx = product.variants.findIndex((v: any) => v.variant_id === urlVariantId || v.sku === urlSku);
+ const decodedKey = urlVariantKey ? decodeURIComponent(urlVariantKey) : null;
+ let activeIdx = product.variants.findIndex(
+ (v: any) =>
+ (decodedKey && (v.sku === decodedKey || String(v.variant_id) === decodedKey)) ||
+ (urlSku && v.sku === urlSku)
+ );
if (activeIdx === -1) {
activeIdx = 0;
}
+
+ // If this URL value was written by our own history.replaceState and the
+ // user's selection already matches, don't reset image/zoom state.
+ if (
+ urlWrittenByUs.current &&
+ decodedKey === urlWrittenByUs.current &&
+ product.variants[selectedVariantIndex]?.sku === decodedKey
+ ) {
+ return;
+ }
setSelectedVariantIndex(activeIdx);
setSelectedImage(resolveInitialImage(product, activeIdx, failedImages));
@@ -154,7 +209,7 @@ export const ProductInteractiveGrid: React.FC = ({
});
}
setSelections(initial);
- }, [product, searchParams]);
+ }, [product, searchParams, initialVariantSku]);
useEffect(() => {
const named = (product as ProductResponse & { brand_name?: string }).brand_name;
@@ -625,6 +680,7 @@ export const ProductInteractiveGrid: React.FC = ({
if (varImg) {
setSelectedImage(getImageUrl(varImg));
}
+ syncVariantUrl(match);
}
}}
className={`px-3 py-1.5 rounded text-[12px] font-semibold transition border cursor-pointer ${
@@ -662,6 +718,7 @@ export const ProductInteractiveGrid: React.FC = ({
if (varImg) {
setSelectedImage(getImageUrl(varImg));
}
+ syncVariantUrl(v);
}}
className={`px-3 py-1.5 rounded text-[12px] font-semibold transition border cursor-pointer ${isSelected
? 'border-primary bg-primary/10 text-primary font-bold shadow-xs'
diff --git a/components/store/LiveSearch.tsx b/components/store/LiveSearch.tsx
index fb45996..b845679 100644
--- a/components/store/LiveSearch.tsx
+++ b/components/store/LiveSearch.tsx
@@ -12,12 +12,29 @@ import Image from 'next/image';
import { Loader2, X, ChevronDown, Check, LayoutGrid, Search } from 'lucide-react';
import { storefrontService, LiveSearchResult } from '@/services/api/storefrontService';
import { catalogService, CategoryResponse } from '@/services/api/catalogService';
-import { getImageUrl } from '@/lib/utils';
+import { formatCurrency, getImageUrl } from '@/lib/utils';
import {
getCategoryMenuItems,
menuItemCategoryParam,
} from '@/components/CategorySidebar';
+function SearchItemImage({ src, alt }: { src: string; alt: string }) {
+ const [imgSrc, setImgSrc] = useState(src);
+ useEffect(() => {
+ setImgSrc(src);
+ }, [src]);
+
+ return (
+ setImgSrc('/images/placeholder-product.webp')}
+ />
+ );
+}
+
export function LiveSearch() {
const router = useRouter();
const [query, setQuery] = useState('');
@@ -282,33 +299,35 @@ export function LiveSearch() {
{!loading && hasResults && (
- {results.products.slice(0, 5).map((product) => (
-
setIsOpen(false)}
- className="flex items-center gap-3 p-2 hover:bg-gray-50 rounded-md transition-colors"
- >
-
- {product.images[0]?.image_url ? (
-
- ) : (
-
- )}
-
-
-
{product.name}
-
- ₹{Number(product.variants[0]?.price || 0).toFixed(2)}
+ {results.products.slice(0, 8).map((product) => {
+ const imgUrl = (product as any).thumbnail_url || product.images?.[0]?.image_url;
+ const price = (product as any).price ?? product.variants?.[0]?.price ?? 0;
+ return (
+
setIsOpen(false)}
+ className="flex items-center gap-3 p-2 hover:bg-gray-50 rounded-md transition-colors"
+ >
+
+ {imgUrl ? (
+
+ ) : (
+
+ )}
-
-
- ))}
+
+
{product.name}
+
+ {formatCurrency(price)}
+
+
+
+ );
+ })}
)}
diff --git a/components/store/ProductCard.tsx b/components/store/ProductCard.tsx
index ad772ae..07d3ba2 100644
--- a/components/store/ProductCard.tsx
+++ b/components/store/ProductCard.tsx
@@ -34,6 +34,7 @@ export function ProductCard({ product }: ProductCardProps) {
const primaryVariant = product.variants[0];
const primaryImage = getImageUrl(product.images[0]?.image_url);
const secondaryImage = getImageUrl(product.images[1]?.image_url) || primaryImage;
+ const productUrl = (product as any).variant_url || `/products/${product.slug}`;
const price = Number(primaryVariant?.price || 0);
const comparePrice = primaryVariant?.compare_price != null ? Number(primaryVariant.compare_price) : null;
@@ -107,7 +108,7 @@ export function ProductCard({ product }: ProductCardProps) {
{/* Image Gallery Flip Container */}
-
+
{product.name}
diff --git a/layout/Header.tsx b/layout/Header.tsx
index 5cfd5ab..4304b4b 100644
--- a/layout/Header.tsx
+++ b/layout/Header.tsx
@@ -25,7 +25,7 @@ export const Header: React.FC = () => {
return (
{
href="/"
className="flex items-center select-none tracking-tighter hover:opacity-95 transition-opacity"
>
-
+
iFix
-
+
Kart
diff --git a/layout/HeaderActions.tsx b/layout/HeaderActions.tsx
index 6ec786d..c5d9eb2 100644
--- a/layout/HeaderActions.tsx
+++ b/layout/HeaderActions.tsx
@@ -45,7 +45,7 @@ export const HeaderActions: React.FC = () => {
@@ -53,7 +53,7 @@ export const HeaderActions: React.FC = () => {
{
initial={{ opacity: 0, height: 0 }}
animate={{ opacity: 1, height: 'auto' }}
exit={{ opacity: 0, height: 0 }}
- className="lg:hidden border-t border-gray-100 px-4 pt-3 pb-2 bg-white w-full absolute left-0 right-0 top-full z-[120] shadow-md"
+ className="lg:hidden mobile-search-overlay border-t border-gray-100 px-4 pt-3 pb-2 bg-white w-full absolute left-0 right-0 top-full z-[120] shadow-md"
>
diff --git a/next.config.ts b/next.config.ts
index 82b21ec..b612516 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -9,7 +9,7 @@ const nextConfig: NextConfig = {
},
async rewrites() {
const backendUrl = process.env.NEXT_PUBLIC_API_URL || 'https://ifixkartbe.trionixsolution.com';
- const mediaUrl = 'https://ifixkartbe.trionixsolution.com';
+ const mediaUrl = process.env.NEXT_PUBLIC_MEDIA_URL || process.env.NEXT_PUBLIC_API_URL || 'https://ifixkartbe.trionixsolution.com';
return [
{
source: '/api/v1/:path*',
diff --git a/services/api/catalogService.ts b/services/api/catalogService.ts
index e6ba0be..ee424bf 100644
--- a/services/api/catalogService.ts
+++ b/services/api/catalogService.ts
@@ -130,6 +130,9 @@ export interface ProductResponse {
device_type?: string | null;
mapped_service_category_id?: string | null;
is_service_booking?: boolean;
+ /** Variant-expanded search cards: deep link to this exact variant on the PDP */
+ variant_url?: string | null;
+ variant_sku?: string | null;
}
export interface DeviceModelResponse {
@@ -179,6 +182,10 @@ export interface ProductCardResponse {
brand_name: string | null;
color?: string | null;
colors?: string[];
+ /** Variant-expanded search cards (expand_variants=true) */
+ variant_sku?: string | null;
+ variant_name?: string | null;
+ variant_url?: string | null;
}
export interface ProductPaginatedResponse {
@@ -221,6 +228,9 @@ export const catalogService = {
async getProductsPaginated(params: Record
= {}): Promise {
const query = new URLSearchParams();
+ if (!('expand_variants' in params)) {
+ query.append('expand_variants', 'true');
+ }
Object.entries(params).forEach(([key, val]) => {
if (val !== undefined && val !== null && val !== '') {
query.append(key, String(val));
diff --git a/services/api/storefrontService.ts b/services/api/storefrontService.ts
index 50ce3c8..43ceea4 100644
--- a/services/api/storefrontService.ts
+++ b/services/api/storefrontService.ts
@@ -121,7 +121,11 @@ export const storefrontService = {
}
try {
- return await apiFetch(API_ENDPOINTS.STOREFRONT_LIVE_SEARCH(query.trim(), category));
+ const data = await apiFetch(API_ENDPOINTS.STOREFRONT_LIVE_SEARCH(query.trim(), category));
+ return {
+ ...data,
+ products: (data.products || []).map((p: any) => mapProductCardToProductResponse(p)),
+ };
} catch {
try {
const res = await catalogService.getProductsPaginated({
diff --git a/styles/mobile-overrides.css b/styles/mobile-overrides.css
index e05f51b..88ec63f 100644
--- a/styles/mobile-overrides.css
+++ b/styles/mobile-overrides.css
@@ -11,6 +11,17 @@ a,
}
/* 2. Responsive viewports & safe area overrides */
+
+/* iOS Safari auto-zooms the page when focusing any form field with
+ font-size < 16px and never zooms back. Force 16px on mobile. */
+@media (max-width: 767px) {
+ input,
+ select,
+ textarea {
+ font-size: 16px !important;
+ }
+}
+
@media (max-width: 767px) {
/* Selective backdrop-filter resets for slow scroll frame performance */
.mobile-sticky-header,
diff --git a/utils/productMapper.ts b/utils/productMapper.ts
index 4a4f182..fb79156 100644
--- a/utils/productMapper.ts
+++ b/utils/productMapper.ts
@@ -33,7 +33,9 @@ export function mapProductCardToProductResponse(
{
variant_id: p.first_variant_id || p.product_id,
product_id: p.product_id,
- sku: (p as any).sku || '',
+ // Variant-expanded cards carry their own SKU so add-to-cart and
+ // PDP deep links (/products/[slug]?variant=[sku]) resolve correctly
+ sku: (p as any).variant_sku || (p as any).sku || '',
barcode: null,
price,
compare_price: comparePrice && comparePrice > 0 ? comparePrice : null,
@@ -61,7 +63,9 @@ export function mapProductCardToProductResponse(
device_model_id: (p as any).device_model_id || null,
name: p.name,
slug: p.slug,
- full_path: (p as any).full_path || `/products/${p.slug}`,
+ full_path: (p as any).variant_url || (p as any).full_path || `/products/${p.slug}`,
+ variant_url: (p as any).variant_url || null,
+ variant_sku: (p as any).variant_sku || null,
description: (p as any).description ?? null,
status: (p as any).status || 'active',
created_at: (p as any).created_at || '',