update ai commerce section

This commit is contained in:
2026-07-23 10:26:49 +05:30
parent 4e0facc9af
commit a4328a791a
135 changed files with 4081 additions and 391 deletions

View File

@@ -0,0 +1,59 @@
// The ONLY module the store-journey UI imports for data.
//
// Everything here is powered by local dummy JSON today. To go live, swap each
// function body for a real API call and keep these exported signatures
// unchanged — the UI never needs to change.
import storesData from "@/data/experience/stores.json";
import categoriesData from "@/data/experience/categories.json";
import productsData from "@/data/experience/products.json";
import intentsData from "@/data/experience/intents.json";
import type { Category, Intent, Product, Recommendation, Store } from "@/types/experience";
const stores = storesData as Store[];
const categories = categoriesData as Category[];
const products = productsData as Product[];
const intents = intentsData as Intent[];
/** The stores a customer has already added — their "My Stores" list. */
export function getMyStores(): Store[] {
return stores;
}
export function getStore(id: string): Store | undefined {
return stores.find((s) => s.id === id);
}
/** The in-store shelves shown after entering a store. */
export function getCategories(): Category[] {
return categories;
}
/** The natural-language shopping intents offered as search chips. */
export function getIntents(): Intent[] {
return intents;
}
/**
* Resolve a shopping intent into a store-scoped bundle — the products Nearle AI
* recommends, joined with their store, plus the cart totals.
*/
export function getRecommendation(intentId: string): Recommendation | null {
const intent = intents.find((i) => i.id === intentId);
if (!intent) return null;
const store = getStore(intent.storeId);
if (!store) return null;
const items = intent.productIds
.map((pid) => products.find((p) => p.id === pid))
.filter((p): p is Product => Boolean(p));
return {
intent,
store,
products: items,
itemCount: items.length,
total: items.reduce((sum, p) => sum + p.price, 0),
};
}

View File

@@ -0,0 +1,19 @@
// The ONLY module the hero voice demo imports for data.
//
// Same contract as ./search.ts: everything is local dummy JSON today. To go
// live, swap the function bodies for real API calls and keep these exported
// signatures unchanged — the hero never needs to change.
import voiceData from "@/data/experience/voice-requests.json";
import type { VoiceRequest } from "@/types/experience";
const requests = voiceData as VoiceRequest[];
/**
* The spoken requests the hero demo cycles through — deliberately spread across
* shopping, services and healthcare so the hero shows Nearle covers products
* *and* local services, not only grocery.
*/
export function getVoiceRequests(): VoiceRequest[] {
return requests;
}