/* eslint-disable @typescript-eslint/no-explicit-any */ /** * Backend-shaped fixtures used across the user-ui suite. * * Field names mirror the real cache/scaffold payloads: * - products.json -> scaffoldProducts ({ products, count, tags }) * - availability -> scaffoldAvailability ({ availability, count }) * - slots.json -> scaffoldSlotsWithProducts ({ slots, productAvailability, count }) * - stores.json -> scaffoldStores ({ stores }) * - stores/.json -> scaffoldStoreWithProducts ({ store, products, tags }) */ import { buildEssentialUrls } from '@packages/shared' export const REGION_1 = { id: 1, name: 'Mahabubnagar', description: 'Region one', effectiveBoundId: 7, } export const REGION_2 = { id: 2, name: 'Hyderabad', description: 'Region two', effectiveBoundId: 8, } export const REGIONS = [REGION_1, REGION_2] export const BOUND_1 = { id: 7, regionId: 1, priority: 1, name: 'Bound 1' } export const BOUND_2 = { id: 8, regionId: 1, priority: 10, name: 'Bound 2' } export const CACHE_BASE = 'https://assets.test/freshyo-cache/' export const API_CACHE_KEY = 'cache-key' export const PRODUCTS_VERSION_NUM = 12 export const AVAILABILITY_VERSION_NUM = 34 export const SLOTS_VERSION_NUM = 56 /** Flat essential-consts payload returned by `common.essentialConsts`. */ export const CONSTS = { boundId: 7, regionId: 1, assetsDomain: CACHE_BASE, apiCacheKey: API_CACHE_KEY, // What the backend now publishes; the hooks prefer these and only fall back // to constructing the same URLs from the version fields below. essentialUrls: buildEssentialUrls({ assetsDomain: CACHE_BASE, apiCacheKey: API_CACHE_KEY, regionId: 1, versions: { products: PRODUCTS_VERSION_NUM, availability: AVAILABILITY_VERSION_NUM, slots: SLOTS_VERSION_NUM, }, }), products_version_num: PRODUCTS_VERSION_NUM, availability_version_num: AVAILABILITY_VERSION_NUM, slots_version_num: SLOTS_VERSION_NUM, freeDeliveryThreshold: 249, deliveryCharge: 15, flashFreeDeliveryThreshold: 199, flashDeliveryCharge: 25, isFlashDeliveryEnabled: true, platformFeePercent: 0, supportMobile: '8688182552', supportEmail: 'support@freshyo.in', welcomeMessage: 'Welcome to Freshyo', versionNum: '1.2.0', internalAppVersion: 2, updatePrompt: { isEnabled: true, isClosable: false }, appStoreUrl: 'https://apps.apple.com/app/freshyo/id123456', playStoreUrl: 'https://play.google.com/store/apps/details?id=com.freshyotrial.app', webviewHtml: null, isWebviewClosable: true, tagsOrder: [1, 2, 3], } export const CONSTS_FLASH_OFF = { ...CONSTS, isFlashDeliveryEnabled: false } export function productsCacheUrl(regionId = 1, version = PRODUCTS_VERSION_NUM) { return `${CACHE_BASE}${API_CACHE_KEY}/regions/${regionId}/v-${version}/products.json` } export function availabilityCacheUrl(regionId = 1, version = AVAILABILITY_VERSION_NUM) { return `${CACHE_BASE}regions/${regionId}/av-${version}/availability.json` } export function slotsCacheUrl(regionId = 1, version = SLOTS_VERSION_NUM) { return `${CACHE_BASE}regions/${regionId}/slots/v-${version}/slots.json` } export function storesCacheUrl(regionId = 1, version = PRODUCTS_VERSION_NUM) { return `${CACHE_BASE}${API_CACHE_KEY}/regions/${regionId}/v-${version}/stores.json` } export function storeDetailCacheUrl(storeId: number, regionId = 1, version = PRODUCTS_VERSION_NUM) { return `${CACHE_BASE}${API_CACHE_KEY}/regions/${regionId}/v-${version}/stores/${storeId}.json` } /* -------------------------------------------------------------------------- */ /* Products */ /* -------------------------------------------------------------------------- */ export const P_CHICKEN = { id: 2, name: 'Chicken Breast', shortDescription: 'Tender boneless breast', unit: '500g', unitNotation: '500g', incrementStep: 1, productQuantity: 500, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: ['chicken.jpg'], productType: 'item', isComboOnly: false, price: 215, marketPrice: 220, flashPrice: null, isFlashAvailable: false, } export const P_CUCUMBER = { id: 5, name: 'Cucumber', shortDescription: 'Farm fresh cucumbers', unit: '500g', unitNotation: '500g', incrementStep: 1, productQuantity: 500, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: ['cucumber.jpg'], productType: 'item', isComboOnly: false, price: 15, marketPrice: 20, flashPrice: null, isFlashAvailable: false, } export const P_OUT = { id: 6, name: 'Mutton', shortDescription: 'Fresh mutton', unit: '500g', unitNotation: '500g', incrementStep: 1, productQuantity: 500, storeId: 1, isOutOfStock: true, nextDeliveryDate: null, images: ['mutton.jpg'], productType: 'item', isComboOnly: false, price: 400, marketPrice: 450, flashPrice: null, isFlashAvailable: false, } export const P_OFFER = { id: 7, name: 'Offer Chicken', shortDescription: 'Special offer pack', unit: '1kg', unitNotation: '1kg', incrementStep: 1, productQuantity: 1000, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: ['offer.jpg'], productType: 'item', isComboOnly: false, price: 199, marketPrice: 260, flashPrice: null, isFlashAvailable: false, } export const P_FLASH = { id: 8, name: 'Paneer', shortDescription: 'Soft paneer cubes', unit: '200g', unitNotation: '200g', incrementStep: 1, productQuantity: 200, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: ['paneer.jpg'], productType: 'item', isComboOnly: false, price: 90, marketPrice: 100, flashPrice: 75, isFlashAvailable: true, } export const P_NO_IMAGE = { id: 9, name: 'No Image Item', shortDescription: '', unit: '1pc', unitNotation: '1pc', incrementStep: 1, productQuantity: 1, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: [], productType: 'item', isComboOnly: false, price: 10, marketPrice: null, flashPrice: null, isFlashAvailable: false, } export const P_NO_SLOT = { id: 10, name: 'No Slot Item', shortDescription: '', unit: '1pc', unitNotation: '1pc', incrementStep: 1, productQuantity: 1, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: ['noslot.jpg'], productType: 'item', isComboOnly: false, price: 50, marketPrice: 60, flashPrice: null, isFlashAvailable: false, } export const P_COMBO_ONLY = { id: 149, name: 'Combo Only SKU', shortDescription: '', unit: '1pc', unitNotation: '1pc', incrementStep: 1, productQuantity: 1, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: [], productType: 'item', isComboOnly: true, price: 99, marketPrice: 120, flashPrice: null, isFlashAvailable: false, } export const P_COMBO = { id: 150, name: 'Family Combo', shortDescription: 'Chicken + cucumber combo', longDescription: 'A family pack with chicken and cucumber.', unit: '1 combo', unitNotation: '1 combo', incrementStep: 1, productQuantity: 1, storeId: 1, isOutOfStock: false, nextDeliveryDate: null, images: ['combo.jpg'], productType: 'combo', isComboOnly: false, price: 599, marketPrice: 700, flashPrice: null, isFlashAvailable: false, comboItems: [P_CHICKEN, P_CUCUMBER], } export const PRODUCTS = [ P_CHICKEN, P_CUCUMBER, P_OUT, P_OFFER, P_FLASH, P_NO_IMAGE, P_NO_SLOT, P_COMBO, P_COMBO_ONLY, ] export const TAGS = [ { id: 1, tagName: 'Chicken', tagDescription: null, imageUrl: null, isDashboardTag: true, relatedStores: [1], productIds: [2, 6, 9] }, { id: 2, tagName: 'Vegetables', tagDescription: null, imageUrl: null, isDashboardTag: false, relatedStores: [1], productIds: [5] }, { id: 3, tagName: 'Empty', tagDescription: null, imageUrl: null, isDashboardTag: false, relatedStores: [], productIds: [] }, ] export const PRODUCTS_RESPONSE = { products: PRODUCTS, count: PRODUCTS.length, tags: TAGS } export const AVAILABILITY = [ { id: 2, price: 215, marketPrice: 220, flashPrice: null, isFlashAvailable: false, isOutOfStock: false, isSuspended: false, isOffer: false }, { id: 5, price: 15, marketPrice: 20, flashPrice: null, isFlashAvailable: false, isOutOfStock: false, isSuspended: false, isOffer: false }, { id: 6, price: 400, marketPrice: 450, flashPrice: null, isFlashAvailable: false, isOutOfStock: true, isSuspended: false, isOffer: false }, { id: 7, price: 199, marketPrice: 260, flashPrice: null, isFlashAvailable: false, isOutOfStock: false, isSuspended: false, isOffer: true }, { id: 8, price: 90, marketPrice: 100, flashPrice: 75, isFlashAvailable: true, isOutOfStock: false, isSuspended: false, isOffer: false }, { id: 9, price: 10, marketPrice: null, flashPrice: null, isFlashAvailable: false, isOutOfStock: false, isSuspended: false, isOffer: false }, { id: 10, price: 50, marketPrice: 60, flashPrice: null, isFlashAvailable: false, isOutOfStock: false, isSuspended: false, isOffer: false }, { id: 150, price: 599, marketPrice: 700, flashPrice: null, isFlashAvailable: false, isOutOfStock: false, isSuspended: false, isOffer: false }, ] export const AVAILABILITY_RESPONSE = { availability: AVAILABILITY, count: AVAILABILITY.length } /** `useAllProducts` merges availability into products; the cart store expects this shape. */ export const MERGED_PRODUCTS = PRODUCTS.map((product) => { const availability = AVAILABILITY.find((entry) => entry.id === product.id) return { ...product, price: availability ? Number(availability.price) : 0, marketPrice: availability?.marketPrice ?? null, flashPrice: availability?.flashPrice ?? null, isFlashAvailable: availability?.isFlashAvailable ?? false, isOutOfStock: availability?.isOutOfStock ?? false, isSuspended: availability?.isSuspended ?? false, isOffer: availability?.isOffer ?? false, } }).filter((product) => !product.isComboOnly) /* -------------------------------------------------------------------------- */ /* Slots */ /* -------------------------------------------------------------------------- */ const HOUR = 60 * 60 * 1000 export function makeSlots(now: number = Date.now()) { const iso = (offsetMs: number) => new Date(now + offsetMs).toISOString() return [ { id: 1849, deliveryTime: iso(2 * HOUR), freezeTime: iso(1 * HOUR), products: [{ id: 2, images: ['chicken.jpg'] }, { id: 5, images: ['cucumber.jpg'] }] }, { id: 1850, deliveryTime: iso(4 * HOUR), freezeTime: iso(3 * HOUR), products: [{ id: 2, images: ['chicken.jpg'] }, { id: 8, images: ['paneer.jpg'] }] }, { id: 1851, deliveryTime: iso(-2 * HOUR), freezeTime: iso(-3 * HOUR), products: [{ id: 2, images: ['chicken.jpg'] }] }, { id: 1852, deliveryTime: iso(6 * HOUR), freezeTime: iso(5 * HOUR), products: [{ id: 2, images: ['chicken.jpg'] }, { id: 5, images: ['cucumber.jpg'] }, { id: 8, images: ['paneer.jpg'] }] }, ] } export const SLOTS = makeSlots() export const PRODUCT_AVAILABILITY = PRODUCTS.map((product) => ({ id: product.id })) export function slotsResponse(slots = SLOTS) { return { slots, productAvailability: PRODUCT_AVAILABILITY, count: slots.length } } export const SLOTS_RESPONSE = slotsResponse() /* -------------------------------------------------------------------------- */ /* Stores */ /* -------------------------------------------------------------------------- */ export const STORES = [ { id: 1, name: 'The Freshyo Meat House', description: 'Fresh meat and produce', signedImageUrl: 'https://assets.test/store1.jpg', productCount: 12, sampleProducts: [ { id: 2, name: 'Chicken Breast', signedImageUrl: 'https://assets.test/chicken.jpg' }, { id: 5, name: 'Cucumber', signedImageUrl: 'https://assets.test/cucumber.jpg' }, ], }, { id: 2, name: 'Freshyo Greens', description: 'Vegetables only', signedImageUrl: null, productCount: 2, sampleProducts: [{ id: 5, name: 'Cucumber', signedImageUrl: 'https://assets.test/cucumber.jpg' }], }, ] export const STORES_RESPONSE = { stores: STORES } export const STORE_DETAIL_1 = { store: { id: 1, name: 'The Freshyo Meat House', description: 'Fresh meat and produce', signedImageUrl: 'https://assets.test/store1.jpg' }, products: [P_CHICKEN, P_CUCUMBER], tags: [ { id: 1, tagName: 'Chicken', tagDescription: null, productIds: [2] }, { id: 2, tagName: 'Veg', tagDescription: null, productIds: [5] }, ], } /* -------------------------------------------------------------------------- */ /* Cart */ /* -------------------------------------------------------------------------- */ export const CART_REG = JSON.stringify([ { id: 1, skuId: 2, quantity: 2, slotId: 1849, addedAt: new Date().toISOString() }, ]) export const CART_FLASH = JSON.stringify([ { id: 1, skuId: 8, quantity: 1, slotId: 0, addedAt: new Date().toISOString() }, ]) /* -------------------------------------------------------------------------- */ /* Addresses */ /* -------------------------------------------------------------------------- */ export const A1 = { id: 11, name: 'Home', mobile: '9876543210', line1: '12 Main Road', line2: 'Near Temple', city: 'Mahabubnagar', state: 'Telangana', pincode: '509001', regionId: 1, boundId: 7, isDefault: true, latitude: 17.0, longitude: 78.0, googleMapsUrl: null, } export const A2 = { id: 12, name: 'Work', mobile: '9876543211', line1: '45 Office Street', line2: null, city: 'Hyderabad', state: 'Telangana', pincode: '500001', regionId: 2, boundId: 8, isDefault: false, latitude: 18.0, longitude: 79.0, googleMapsUrl: null, } export const A3 = { id: 13, name: 'NoRegion', mobile: '9876543212', line1: 'Somewhere', line2: null, city: 'Nowhere', state: 'Telangana', pincode: '500002', regionId: null, boundId: null, isDefault: false, latitude: null, longitude: null, googleMapsUrl: null, } export const ADDRESSES = [A1, A2, A3] export const ADDRESSES_RESPONSE = { data: ADDRESSES } /* -------------------------------------------------------------------------- */ /* Coupons */ /* -------------------------------------------------------------------------- */ export const C1 = { id: 21, couponCode: 'SAVE10', discountPercent: '10', maxValue: 50, minOrder: null, flatDiscount: null, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [], applicableUsers: [], isExclusive: false, firstOrderOnly: false, regionId: 1 } export const C2 = { id: 22, couponCode: 'FLAT100', discountPercent: null, maxValue: null, minOrder: null, flatDiscount: 100, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [], applicableUsers: [], isExclusive: false, firstOrderOnly: false, regionId: 1 } export const C3 = { id: 23, couponCode: 'MIN1000', discountPercent: null, maxValue: null, minOrder: 1000, flatDiscount: 50, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [], applicableUsers: [], isExclusive: false, firstOrderOnly: false, regionId: 1 } export const C4 = { id: 24, couponCode: 'TARGET10', discountPercent: '10', maxValue: 40, minOrder: null, flatDiscount: null, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [2], applicableUsers: [], isExclusive: false, firstOrderOnly: false, regionId: 1 } export const C5 = { id: 25, couponCode: 'EXCLUSIVE', discountPercent: null, maxValue: null, minOrder: null, flatDiscount: 20, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [], applicableUsers: [], isExclusive: true, firstOrderOnly: false, regionId: 1 } export const C6 = { id: 26, couponCode: 'USED', discountPercent: '10', maxValue: 30, minOrder: null, flatDiscount: null, validTill: null, isApplyForAll: true, isInvalidated: false, maxLimitForUser: 1, usedCount: 1, skuIds: [], applicableUsers: [], isExclusive: false, firstOrderOnly: false, regionId: 1 } export const C7 = { id: 27, couponCode: 'OTHERREGION', discountPercent: '10', maxValue: 30, minOrder: null, flatDiscount: null, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [], applicableUsers: [], isExclusive: false, firstOrderOnly: false, regionId: 2 } export const C8 = { id: 28, couponCode: 'FIRST', discountPercent: null, maxValue: null, minOrder: null, flatDiscount: 40, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [], applicableUsers: [], isExclusive: false, firstOrderOnly: true, regionId: 1 } /* * Product-specific coupons for the catalogue (card + product detail). Kept out of * `COUPONS` on purpose: that array is the default `getEligible` payload and the * cart/checkout suites count and price against it. */ /** 10% capped ₹40 on Chicken Breast (sku 2): ₹215 -> ₹194. */ export const C_SKU2_PERCENT = C4 /** Flat ₹100 on the same sku — beats the percentage above. */ export const C_SKU2_FLAT = { id: 29, couponCode: 'SKU2FLAT', discountPercent: null, maxValue: null, minOrder: null, flatDiscount: 100, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [2], applicableUsers: [], exclusiveApply: false, isFirstOrderOnly: false, regionId: 1 } /** Targeted coupon that also carries a cart minimum: the catalogue ignores minOrder. */ export const C_SKU2_MIN = { id: 30, couponCode: 'SKU2MIN1000', discountPercent: null, maxValue: null, minOrder: 1000, flatDiscount: 20, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [2], applicableUsers: [], exclusiveApply: false, isFirstOrderOnly: false, regionId: 1 } /** 10% capped ₹20 on Paneer (sku 8): price 90 -> 81, flashPrice 75 -> 68. */ export const C_SKU8_FLASH = { id: 31, couponCode: 'FLASH10', discountPercent: '10', maxValue: 20, minOrder: null, flatDiscount: null, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [8], applicableUsers: [], exclusiveApply: false, isFirstOrderOnly: false, regionId: 1 } /** First-order-only, product-specific. */ export const C_SKU2_FIRST = { id: 32, couponCode: 'SKU2FIRST', discountPercent: null, maxValue: null, minOrder: null, flatDiscount: 30, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [2], applicableUsers: [], exclusiveApply: false, isFirstOrderOnly: true, regionId: 1 } export const COUPONS = [C1, C2, C3, C4, C5, C6, C7, C8] export const ELIGIBLE_COUPONS_RESPONSE = { data: COUPONS, isFirstOrder: true } export const MY_COUPONS_RESPONSE = { data: { personal: [{ ...C4, status: 'available', maxLimitForUser: 3, usedCount: 1 }], general: [C1, { ...C6, status: 'used' }], }, } /* -------------------------------------------------------------------------- */ /* Orders */ /* -------------------------------------------------------------------------- */ const ORDER_ITEMS = [ { id: 1, skuId: 2, name: 'Chicken Breast', quantity: 2, unit: '500g', price: 215, image: 'chicken.jpg', isPackaged: false, isVerified: false }, { id: 2, skuId: 5, name: 'Cucumber', quantity: 1, unit: '500g', price: 15, image: 'cucumber.jpg', isPackaged: true, isVerified: false }, ] export const O1 = { orderId: 'ORD-1001', id: 1001, readableId: 101, orderStatus: 'pending', deliveryStatus: 'pending', deliveryType: 'regular', orderAmount: 445, totalAmount: 445, subtotal: 445, discountAmount: 0, deliveryCharge: 15, couponCode: null, orderDate: new Date().toISOString(), createdAt: new Date().toISOString(), deliveryDate: new Date(Date.now() + 7200000).toISOString(), regionId: 1, regionName: 'Mahabubnagar', userNotes: null, adminNotes: null, items: ORDER_ITEMS, user: { id: 5, name: 'Test User', mobile: '9876543210' }, address: { line1: '12 Main Road', city: 'Mahabubnagar', state: 'Telangana', pincode: '509001' }, } export const O2 = { ...O1, orderId: 'ORD-1002', id: 1002, readableId: 102, deliveryType: 'flash', orderStatus: 'pending', orderAmount: 90, totalAmount: 90, deliveryCharge: 0, } export const O3 = { ...O1, orderId: 'ORD-1003', id: 1003, readableId: 103, orderStatus: 'cancelled', deliveryStatus: 'cancelled', cancellationReason: 'Customer requested', } export const O4 = { ...O1, orderId: 'ORD-1004', id: 1004, readableId: 104, orderStatus: 'success', deliveryStatus: 'success', } export const O5 = { ...O1, orderId: 'ORD-1005', id: 1005, readableId: 105, items: [...ORDER_ITEMS, { id: 3, skuId: 8, name: 'Paneer', quantity: 1, unit: '200g', price: 90, image: 'paneer.jpg', isPackaged: false, isVerified: false }], } export const O6 = { ...O1, orderId: 'ORD-1006', id: 1006, readableId: 106, userNotes: 'Leave at the door', couponCode: 'SAVE10', discountAmount: 43, deliveryCharge: 15, } export const ORDERS = [O1, O2, O3, O4, O5, O6] export const ORDERS_RESPONSE = { data: ORDERS, pagination: { totalPages: 1, total: ORDERS.length, page: 1, pageSize: 10 } } /* -------------------------------------------------------------------------- */ /* Complaints / reviews / user */ /* -------------------------------------------------------------------------- */ export const AUTH_USER = { id: 5, name: 'Test User', email: 'test@example.com', mobile: '9876543210' } /** A decodable (unverified) JWT whose payload carries `id: 5`. */ export const TEST_JWT = `header.${Buffer.from(JSON.stringify({ id: 5, userId: 5 })).toString('base64url')}.signature` export const AUTH_USER_FULL = { ...AUTH_USER, profileImage: 'https://assets.test/profile.jpg', createdAt: new Date().toISOString(), bio: null, dateOfBirth: null, gender: null, occupation: null, } export const SELF_DATA_RESPONSE = { data: { user: AUTH_USER_FULL } } export const COMPLAINTS = [ { id: 1, orderId: 'ORD-1001', complaintBody: 'Late delivery', complaintImages: [], complaintStatus: 'pending', complaintResponse: null, createdAt: new Date().toISOString(), user: AUTH_USER }, { id: 2, orderId: null, complaintBody: 'App issue', complaintImages: ['issue.jpg'], complaintStatus: 'resolved', complaintResponse: 'We fixed it', createdAt: new Date().toISOString(), user: AUTH_USER }, ] export const COMPLAINTS_RESPONSE = { complaints: COMPLAINTS } export const REVIEWS = [ { id: 1, rating: 5, review: 'Great', reviewImages: [], adminResponse: null, user: { name: 'A' }, createdAt: new Date().toISOString() }, { id: 2, rating: 3, review: 'Okay', reviewImages: [], adminResponse: 'Thanks', user: { name: 'B' }, createdAt: new Date().toISOString() }, ] export const REVIEWS_RESPONSE = { reviews: REVIEWS, hasMore: false, count: REVIEWS.length } export const PRODUCT_DETAILS = { ...P_CHICKEN, productId: 2, longDescription: 'Tender boneless chicken breast.', store: { id: 1, name: 'The Freshyo Meat House' }, reviews: REVIEWS, averageRating: 4, totalReviews: REVIEWS.length, } export const CART_SLOTS_RESPONSE: Record = { 2: [SLOTS[0], SLOTS[1], SLOTS[3]], 5: [SLOTS[0], SLOTS[3]], 8: [SLOTS[1], SLOTS[3]], }