/* eslint-disable @typescript-eslint/no-explicit-any */ /** * Backend-shaped fixtures used across the admin-ui suite. * * Shapes mirror `@packages/shared` (AdminProductWithRelations, AdminSku, * AdminOrderListItem, AdminSlotWithProducts, Coupon, …) so the API mock can feed * the pages the same payloads the real procedures return. */ /* -------------------------------------------------------------------------- */ /* Regions, staff, bounds, settings */ /* -------------------------------------------------------------------------- */ export const REGION = { id: 1, name: 'Mahabubnagar', description: 'Region one', effectiveBoundId: 7, } export const REGION_2 = { id: 2, name: 'Hyderabad', description: 'Region two', effectiveBoundId: 8, } export const STAFF = { id: 3, name: 'Admin One', regionId: 1, regionName: 'Mahabubnagar' } export const STAFF_NO_REGION = { id: 4, name: 'Unassigned', regionId: 0 } /** A decodable (unverified) JWT used for the staff session. */ export const TEST_JWT = `header.${Buffer.from(JSON.stringify({ id: 3, name: 'Admin One' })).toString('base64url')}.signature` export const B1 = { id: 7, regionId: 1, priority: 1, name: 'Bound 1' } export const B2 = { id: 8, regionId: 1, priority: 10, name: 'Bound 2' } export const BOUNDS = [B1, B2] export const BOUND_SETTINGS = { freeDeliveryThreshold: '249', deliveryCharge: '15', flashFreeDeliveryThreshold: '199', flashDeliveryCharge: '25', isFlashDeliveryEnabled: 'true', } export const REGION_CONSTANTS = { popularItems: '[2,5]', allItemsOrder: '[2,5,7]', supportMobile: '8688182552', supportEmail: 'support@freshyo.in', welcomeMessage: 'Welcome', tagsOrder: '[1,2]', } /* -------------------------------------------------------------------------- */ /* Stores */ /* -------------------------------------------------------------------------- */ export const STORE_1 = { id: 1, name: 'The Freshyo Meat House', description: 'Fresh meat and produce', imageUrl: 'https://assets.test/store1.jpg', isGlobal: false, productCount: 12, createdAt: new Date().toISOString(), } export const STORE_GLOBAL = { id: 2, name: 'Freshyo Central', description: 'Shared across regions', imageUrl: null, isGlobal: true, productCount: 4, createdAt: new Date().toISOString(), } export const STORES = [STORE_1, STORE_GLOBAL] /* -------------------------------------------------------------------------- */ /* Products */ /* -------------------------------------------------------------------------- */ const sku = (over: Partial = {}) => ({ id: 11, productId: 2, name: null, price: '215', marketPrice: '220', images: ['chicken.jpg'], imageKeys: ['product-images/chicken.jpg'], isOutOfStock: false, isSuspended: false, isSuspendedInRegion: false, isFlashAvailable: false, flashPrice: null, isOffer: false, isComboOnly: false, isDeleted: false, createdAt: new Date().toISOString(), features: [{ id: 1, skuId: 11, featureName: 'quantity', featureValue: '500g' }], comboItems: [], ...over, }) /** Product 2 — 2 SKUs, both in stock. */ export const P_CHICKEN = { id: 2, name: 'Chicken Breast', shortDescription: 'Tender boneless breast', longDescription: 'Tender boneless chicken breast.', storeId: 1, incrementStep: 1, createdAt: new Date().toISOString(), productType: 'item', isGlobal: false, store: STORE_1, skus: [ sku({ id: 11, productId: 2, features: [{ id: 1, skuId: 11, featureName: 'quantity', featureValue: '500g' }] }), sku({ id: 12, productId: 2, name: 'Chicken Breast 1kg', price: '410', features: [{ id: 2, skuId: 12, featureName: 'quantity', featureValue: '1kg' }] }), ], } /** Product 5 — 1 SKU, in stock. */ export const P_CUCUMBER = { id: 5, name: 'Cucumber', shortDescription: 'Farm fresh cucumbers', longDescription: 'Farm fresh cucumbers.', storeId: 1, incrementStep: 1, createdAt: new Date().toISOString(), productType: 'item', isGlobal: false, store: STORE_1, skus: [ sku({ id: 13, productId: 5, price: '15', marketPrice: '20', images: ['cucumber.jpg'], features: [{ id: 3, skuId: 13, featureName: 'quantity', featureValue: '500g' }] }), ], } /** Product 9 — global, single SKU 91. */ export const P_GLOBAL = { id: 9, name: 'Global Paneer', shortDescription: 'Shared paneer', longDescription: 'Shared paneer.', storeId: 2, incrementStep: 1, createdAt: new Date().toISOString(), productType: 'item', isGlobal: true, store: STORE_GLOBAL, skus: [ sku({ id: 91, productId: 9, price: '90', marketPrice: '100', images: ['paneer.jpg'], features: [{ id: 4, skuId: 91, featureName: 'quantity', featureValue: '200g' }] }), ], } /** Product 6 — all SKUs out of stock. */ export const P_OUT = { id: 6, name: 'Mutton', shortDescription: 'Fresh mutton', longDescription: 'Fresh mutton.', storeId: 1, incrementStep: 1, createdAt: new Date().toISOString(), productType: 'item', isGlobal: false, store: STORE_1, skus: [sku({ id: 61, productId: 6, price: '400', isOutOfStock: true, features: [{ id: 5, skuId: 61, featureName: 'quantity', featureValue: '500g' }] })], } /** Product 7 — no images. */ export const P_NO_IMAGE = { id: 7, name: 'No Image Item', shortDescription: '', longDescription: '', storeId: 1, incrementStep: 1, createdAt: new Date().toISOString(), productType: 'item', isGlobal: false, store: STORE_1, skus: [sku({ id: 71, productId: 7, price: '10', marketPrice: null, images: [], imageKeys: [], features: [{ id: 6, skuId: 71, featureName: 'quantity', featureValue: '1pc' }] })], } export const P_PARTIAL = { id: 8, name: 'Mixed Stock', shortDescription: 'One in, one out', longDescription: '', storeId: 1, incrementStep: 1, createdAt: new Date().toISOString(), productType: 'item', isGlobal: false, store: STORE_1, skus: [ sku({ id: 81, productId: 8, isOutOfStock: false, features: [{ id: 7, skuId: 81, featureName: 'quantity', featureValue: '250g' }] }), sku({ id: 82, productId: 8, isOutOfStock: true, features: [{ id: 8, skuId: 82, featureName: 'quantity', featureValue: '500g' }] }), ], } export const PRODUCTS = [P_CHICKEN, P_CUCUMBER, P_GLOBAL, P_OUT, P_NO_IMAGE, P_PARTIAL] export const PRODUCTS_RESPONSE = { products: PRODUCTS, count: PRODUCTS.length } /** SKU summaries for ProductsSelector / getAllSkusSummary. */ export const SKUS_SUMMARY = [ { id: 11, productId: 2, productName: 'Chicken Breast', label: 'Chicken Breast - 500g', images: ['chicken.jpg'], storeId: 1, price: '215' }, { id: 12, productId: 2, productName: 'Chicken Breast', label: 'Chicken Breast - 1kg', images: ['chicken.jpg'], storeId: 1, price: '410' }, { id: 13, productId: 5, productName: 'Cucumber', label: 'Cucumber - 500g', images: ['cucumber.jpg'], storeId: 1, price: '15' }, { id: 91, productId: 9, productName: 'Global Paneer', label: 'Global Paneer - 200g', images: ['paneer.jpg'], storeId: 2, price: '90' }, ] export const PRODUCTS_SUMMARY = { products: PRODUCTS.map((p) => ({ id: p.id, name: p.name, shortDescription: p.shortDescription, images: p.skus?.[0]?.images ?? [], })), } export const STORES_SUMMARY = { stores: STORES } /* -------------------------------------------------------------------------- */ /* Slots */ /* -------------------------------------------------------------------------- */ const HOUR = 60 * 60 * 1000 const iso = (offsetMs: number) => new Date(Date.now() + offsetMs).toISOString() export const SLOT_1 = { id: 1849, deliveryTime: iso(2 * HOUR), freezeTime: iso(1 * HOUR), isActive: true, isFlash: false, isCapacityFull: false, deliverySequence: [], groupIds: [], products: [P_CHICKEN.skus[0] ? { id: 2, name: 'Chicken Breast', images: ['chicken.jpg'] } : null, { id: 5, name: 'Cucumber', images: ['cucumber.jpg'] }], } export const SLOT_FULL = { ...SLOT_1, id: 1850, isCapacityFull: true, deliveryTime: iso(4 * HOUR), freezeTime: iso(3 * HOUR) } export const SLOT_INACTIVE = { ...SLOT_1, id: 1851, isActive: false, deliveryTime: iso(6 * HOUR), freezeTime: iso(5 * HOUR) } export const SLOTS = [SLOT_1, SLOT_FULL, SLOT_INACTIVE] export const SLOTS_RESPONSE = { slots: SLOTS, count: SLOTS.length } export const SLOT_DETAIL = { ...SLOT_1, deliverySequence: [101, 102], groupIds: [1], } /* -------------------------------------------------------------------------- */ /* Orders */ /* -------------------------------------------------------------------------- */ const ORDER_ITEMS = [ { id: 1, productId: 2, name: 'Chicken Breast', amount: 430, quantity: 2, price: 215, unit: '500g', productSize: 500, isPackaged: false, isPackageVerified: false, is_packaged: false, is_package_verified: false, skuName: 'Chicken Breast - 500g', features: [{ featureName: 'quantity', featureValue: '500g' }] }, { id: 2, productId: 5, name: 'Cucumber', amount: 15, quantity: 1, price: 15, unit: '500g', productSize: 500, isPackaged: true, isPackageVerified: false, is_packaged: true, is_package_verified: false, skuName: 'Cucumber - 500g', features: [{ featureName: 'quantity', featureValue: '500g' }] }, ] export const ORDER_1 = { id: 11, orderId: 'ORD-1011', readableId: 101, userId: 5, customerName: 'Test User', customerMobile: '9876543210', address: '12 Main Road, Mahabubnagar', addressId: 11, latitude: 17, longitude: 78, totalAmount: 445, deliveryCharge: 15, items: ORDER_ITEMS, createdAt: new Date().toISOString(), deliveryTime: iso(2 * HOUR), status: 'pending', isPackaged: false, isDelivered: false, isFlashDelivery: false, userNotes: null, adminNotes: null, userNegativityScore: 0, } export const ORDER_FLASH = { ...ORDER_1, id: 12, orderId: 'ORD-1012', readableId: 102, isFlashDelivery: true, deliveryCharge: 0 } export const ORDER_DELIVERED = { ...ORDER_1, id: 13, orderId: 'ORD-1013', readableId: 103, status: 'delivered', isDelivered: true, isPackaged: true } export const ORDER_CANCELLED = { ...ORDER_1, id: 14, orderId: 'ORD-1014', readableId: 104, status: 'cancelled' } export const ORDER_NEGATIVE = { ...ORDER_1, id: 15, orderId: 'ORD-1015', readableId: 105, userNegativityScore: 5 } export const ORDERS = [ORDER_1, ORDER_FLASH, ORDER_DELIVERED, ORDER_CANCELLED, ORDER_NEGATIVE] export const ORDERS_RESPONSE = { orders: ORDERS } export const ORDER_DETAILS = { id: 11, readableId: 101, userId: 5, customerName: 'Test User', customerEmail: 'test@example.com', customerMobile: '9876543210', address: { name: 'Home', line1: '12 Main Road', line2: null, city: 'Mahabubnagar', state: 'Telangana', phone: '9876543210' }, slotInfo: { time: iso(2 * HOUR), sequence: 1 }, totalAmount: 445, deliveryCharge: 15, adminNotes: null, userNotes: null, createdAt: new Date().toISOString(), status: 'pending', isPackaged: false, isDelivered: false, items: ORDER_ITEMS.map((i) => ({ ...i, quantity: String(i.quantity), price: String(i.price) })), cancelReason: null, cancellationReviewed: false, couponData: null, couponCode: null, couponDescription: null, discountAmount: null, orderStatus: { id: 1, orderTime: new Date().toISOString(), userId: 5, orderId: 11, isPackaged: false, isDelivered: false, isCancelled: false, cancelReason: null, isCancelledByAdmin: null, cancellationUserNotes: null, cancellationAdminNotes: null, cancellationReviewed: false, cancellationReviewedAt: null, }, isFlashDelivery: false, } export const SLOT_ORDERS = [ { ...ORDER_1, address: '12 Main Road, Mahabubnagar', items: ORDER_ITEMS, slotId: 1849, deliveryTime: iso(2 * HOUR) }, ] /* -------------------------------------------------------------------------- */ /* Users */ /* -------------------------------------------------------------------------- */ export const USER_1 = { id: 5, name: 'Test User', mobile: '9876543210', isSuspended: false, totalOrders: 3, createdAt: new Date().toISOString(), lastOrderDate: new Date().toISOString(), } export const USER_SUSPENDED = { ...USER_1, id: 6, name: 'Suspended', mobile: '9876543211', isSuspended: true, totalOrders: 0, lastOrderDate: null } export const USER_NO_NAME = { ...USER_1, id: 7, name: null, mobile: null, totalOrders: 0, lastOrderDate: null } export const USERS = [USER_1, USER_SUSPENDED, USER_NO_NAME] export const USERS_RESPONSE = { users: USERS, nextCursor: undefined } export const USER_DETAILS = { ...USER_1, email: 'test@example.com', orders: [ORDER_1, ORDER_DELIVERED], } export const USER_INCIDENTS = [ { id: 1, userId: 5, orderId: 11, dateAdded: new Date().toISOString(), adminComment: 'Late delivery', addedBy: { name: 'Admin One' }, negativityScore: 2, order: { orderStatus: [{ isCancelled: false }] } }, ] export const NOTIFICATION_USERS = [ { id: 5, name: 'Test User', mobile: '9876543210' }, { id: 6, name: 'Second User', mobile: '9876543211' }, ] /* -------------------------------------------------------------------------- */ /* Coupons */ /* -------------------------------------------------------------------------- */ export const COUPON_1 = { id: 21, couponCode: 'SAVE10', discountPercent: '10', maxValue: 50, minOrder: null, flatDiscount: null, validTill: null, isApplyForAll: true, isInvalidated: false, skuIds: [], applicableUsers: [], isExclusive: false, firstOrderOnly: false, exclusiveApply: false, isFirstOrderOnly: false, regionId: 1, maxLimitForUser: null, usedCount: 0, createdAt: '2026-01-01T00:00:00.000Z', creator: { id: 1, name: 'Admin One', mobile: '9999999999' }, } export const COUPON_GLOBAL = { ...COUPON_1, id: 22, couponCode: 'GLOBAL10', isApplyForAll: true, regionId: null } export const COUPON_EXPIRED = { ...COUPON_1, id: 23, couponCode: 'OLD', validTill: iso(-24 * HOUR) } export const COUPON_INVALIDATED = { ...COUPON_1, id: 24, couponCode: 'DEAD', isInvalidated: true } export const COUPON_RESERVED = { ...COUPON_1, id: 25, couponCode: 'RES10' } export const COUPONS = [COUPON_1, COUPON_GLOBAL, COUPON_EXPIRED, COUPON_INVALIDATED] export const COUPONS_RESPONSE = { coupons: COUPONS, count: COUPONS.length, nextCursor: undefined } export const RESERVED_COUPONS = [ { ...COUPON_RESERVED, secretCode: 'SECRET123', isRedeemed: false, redeemedBy: null, createdBy: 'Admin One' }, ] export const RESERVED_COUPONS_RESPONSE = { coupons: RESERVED_COUPONS, count: 1, nextCursor: undefined } /* -------------------------------------------------------------------------- */ /* Product tags / groups */ /* -------------------------------------------------------------------------- */ export const TAG_1 = { id: 1, tagName: 'Chicken', tagDescription: 'All chicken items', imageUrl: 'https://assets.test/tag1.jpg', isDashboardTag: true, relatedStores: [1], sortOrder: [], createdAt: new Date().toISOString(), products: [], productIds: [2], } export const TAG_2 = { id: 2, tagName: 'Veg', tagDescription: null, imageUrl: null, isDashboardTag: false, relatedStores: [1], sortOrder: [], createdAt: new Date().toISOString(), products: [], productIds: [5], } export const TAGS = [TAG_1, TAG_2] export const TAGS_RESPONSE = { tags: TAGS } export const GROUP_1 = { id: 1, groupName: 'Breakfast', description: 'Morning items', createdAt: new Date().toISOString(), products: [P_CHICKEN.skus[0], P_CUCUMBER.skus[0]], productCount: 2, } export const GROUPS = [GROUP_1] export const GROUPS_RESPONSE = { groups: GROUPS } /* -------------------------------------------------------------------------- */ /* Banners */ /* -------------------------------------------------------------------------- */ export const BANNER_1 = { id: 1, name: 'Dash Banner', description: 'Top banner', imageUrl: 'https://assets.test/banner1.jpg', skuIds: [11], redirectUrl: null, serialNumber: 1, isActive: true, } export const BANNERS = [BANNER_1] export const BANNERS_RESPONSE = { banners: BANNERS, count: BANNERS.length } /* -------------------------------------------------------------------------- */ /* Complaints */ /* -------------------------------------------------------------------------- */ export const COMPLAINT_1 = { id: 1, userId: 5, orderId: 11, complaintBody: 'Late delivery', complaintImages: [], complaintStatus: 'pending', complaintResponse: null, createdAt: new Date().toISOString(), regionId: 1, user: { id: 5, name: 'Test User', mobile: '9876543210' }, } export const COMPLAINT_2 = { ...COMPLAINT_1, id: 2, orderId: null, complaintBody: 'App issue', complaintImages: ['issue.jpg'], complaintStatus: 'resolved', complaintResponse: 'We fixed it', } export const COMPLAINTS = [COMPLAINT_1, COMPLAINT_2] export const COMPLAINTS_RESPONSE = { complaints: COMPLAINTS, count: COMPLAINTS.length } /* -------------------------------------------------------------------------- */ /* Uploads */ /* -------------------------------------------------------------------------- */ export const UPLOAD_URLS_RESPONSE = { uploadUrls: ['https://upload.test/meatfarmer/product-images/img-1.jpg'], } export const PRODUCT_REVIEWS = { reviews: [ { id: 1, reviewBody: 'Great', ratings: 5, reviewTime: iso(0), userName: 'A', imageUrls: [], adminResponse: null, adminResponseImages: [], signedImageUrls: [], signedAdminImageUrls: [] }, { id: 2, reviewBody: 'Okay', ratings: 3, reviewTime: iso(0), userName: 'B', imageUrls: [], adminResponse: 'Thanks', adminResponseImages: [], signedImageUrls: [], signedAdminImageUrls: [] }, ], hasMore: false, }