diff --git a/apps/backend/src/trpc/apis/user-apis/apis/product.ts b/apps/backend/src/trpc/apis/user-apis/apis/product.ts index 5abbfb3..0fc86ee 100644 --- a/apps/backend/src/trpc/apis/user-apis/apis/product.ts +++ b/apps/backend/src/trpc/apis/user-apis/apis/product.ts @@ -5,7 +5,7 @@ import { productInfo, units, productSlots, deliverySlotInfo, specialDeals, store import { claimUploadUrl, extractKeyFromPresignedUrl, scaffoldAssetUrl } from '@/src/lib/s3-client'; import { ApiError } from '@/src/lib/api-error'; import { eq, and, gt, sql, inArray, desc } from 'drizzle-orm'; -import { getProductById as getProductByIdFromCache } from '@/src/stores/product-store'; +import { getProductById as getProductByIdFromCache, getAllProducts as getAllProductsFromCache } from '@/src/stores/product-store'; import dayjs from 'dayjs'; // Uniform Product Type @@ -246,4 +246,21 @@ export const productRouter = router({ return { success: true, review: newReview }; }), + + getAllProductsSummary: publicProcedure + .query(async (): Promise => { + // Get all products from cache + const allCachedProducts = await getAllProductsFromCache(); + + // Transform the cached products to match the expected summary format + // (with empty deliverySlots and specialDeals arrays for summary view) + const transformedProducts = allCachedProducts.map(product => ({ + ...product, + deliverySlots: [], // Empty for summary view + specialDeals: [], // Empty for summary view + })); + + return transformedProducts; + }), + });