enh #3
1 changed files with 18 additions and 1 deletions
|
|
@ -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<Product[]> => {
|
||||
// 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;
|
||||
}),
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue