This commit is contained in:
shafi54 2026-08-01 21:31:29 +05:30
parent 0cbd24341f
commit db2ee44a5f
16 changed files with 35 additions and 131 deletions

View file

@ -1,4 +1,9 @@
# Taste (Continuously Learned by [CommandCode][cmd]) # Taste
[cmd]: https://commandcode.ai/ - Prefers that the agent not run typechecks; instead, read the project's AGENTS.md for instructions on what to do/not do before finalizing work. Confidence: 0.9
- Prefers detailed analysis and explicit error/mistake checking before executing git operations (e.g., merges), rather than just performing the action. Confidence: 0.6
- When removing unused code (e.g., an unused tRPC procedure), prefers a complete cleanup: also remove internal helper methods used only by it, associated types, re-exports, orphaned hook/API files and their shared types, and even commented-out imports, leaving zero remaining references. Confidence: 0.9
- Before removing or deciding on code, likes to first verify where it is actually used across the codebase (asks questions like "where is X used"), rather than removing based on assumption. Confidence: 0.4

View file

@ -1,4 +0,0 @@
- trpc.user.tags.getTagsByStore — apps/backend/src/trpc/apis/user-apis/apis/tags.ts
- trpc.common.product.getAllProductsSummary — apps/backend/src/trpc/apis/common-apis/common.ts
- remove slots from products cache
- remove redundant product details like name, description etc from the slots api

View file

@ -51,9 +51,7 @@ export type {
AdminProductListResponse, AdminProductListResponse,
AdminProductResponse, AdminProductResponse,
AdminDeleteProductResult, AdminDeleteProductResult,
AdminToggleOutOfStockResult,
AdminUpdateSlotProductsResult, AdminUpdateSlotProductsResult,
AdminSlotProductIdsResult,
AdminSlotsProductIdsResult, AdminSlotsProductIdsResult,
AdminProductReview, AdminProductReview,
AdminProductReviewWithSignedUrls, AdminProductReviewWithSignedUrls,

View file

@ -64,7 +64,6 @@
// replaceProductTags, // replaceProductTags,
// toggleProductOutOfStock, // toggleProductOutOfStock,
// updateSlotProducts, // updateSlotProducts,
// getSlotProductIds,
// getSlotsProductIds, // getSlotsProductIds,
// getAllUnits, // getAllUnits,
// getAllProductTags, // getAllProductTags,

View file

@ -74,7 +74,6 @@ export {
replaceProductTags, replaceProductTags,
mergeSkus, mergeSkus,
updateSlotProducts, updateSlotProducts,
getSlotProductIds,
getSlotsProductIds, getSlotsProductIds,
getAllUnits, getAllUnits,
getAllProductTags, getAllProductTags,

View file

@ -49,7 +49,7 @@ async function transformSlotToStoreSlot(slot: SlotWithProductsData): Promise<Slo
shortDescription: product.shortDescription, shortDescription: product.shortDescription,
price: product.price.toString(), price: product.price.toString(),
marketPrice: product.marketPrice?.toString() || null, marketPrice: product.marketPrice?.toString() || null,
unit: product.unit?.shortNotation || null, unit: product.unitNotation || null,
images: scaffoldAssetUrl( images: scaffoldAssetUrl(
(product.images as string[]) || [] (product.images as string[]) || []
), ),
@ -125,7 +125,7 @@ export async function initializeSlotStore(): Promise<void> {
shortDescription: product.shortDescription, shortDescription: product.shortDescription,
price: product.price.toString(), price: product.price.toString(),
marketPrice: product.marketPrice?.toString() || null, marketPrice: product.marketPrice?.toString() || null,
unit: product.unit?.shortNotation || null, unit: product.unitNotation || null,
images: scaffoldAssetUrl( images: scaffoldAssetUrl(
(product.images as string[]) || [] (product.images as string[]) || []
), ),

View file

@ -8,7 +8,6 @@ import {
getProductById as getProductByIdInDb, getProductById as getProductByIdInDb,
deleteProduct as deleteProductInDb, deleteProduct as deleteProductInDb,
updateSlotProducts as updateSlotProductsInDb, updateSlotProducts as updateSlotProductsInDb,
getSlotProductIds as getSlotProductIdsInDb,
getSlotsProductIds as getSlotsProductIdsInDb, getSlotsProductIds as getSlotsProductIdsInDb,
getProductReviews as getProductReviewsInDb, getProductReviews as getProductReviewsInDb,
respondToReview as respondToReviewInDb, respondToReview as respondToReviewInDb,
@ -42,7 +41,6 @@ import type {
AdminProductResponse, AdminProductResponse,
AdminDeleteProductResult, AdminDeleteProductResult,
AdminUpdateSlotProductsResult, AdminUpdateSlotProductsResult,
AdminSlotProductIdsResult,
AdminSlotsProductIdsResult, AdminSlotsProductIdsResult,
AdminUpdateProductPricesResult, AdminUpdateProductPricesResult,
} from '@packages/shared' } from '@packages/shared'
@ -421,31 +419,6 @@ export const productRouter = router({
} }
}), }),
getSlotProductIds: protectedProcedure
.input(z.object({
slotId: z.string(),
}))
.query(async ({ input }): Promise<AdminSlotProductIdsResult> => {
const { slotId } = input;
const skuIds = await getSlotProductIdsInDb(slotId)
/*
// Old implementation - direct DB queries:
const associations = await db.query.productSlots.findMany({
where: eq(productSlots.slotId, parseInt(slotId)),
columns: {
productId: true,
},
});
const productIds = associations.map(assoc => assoc.productId);
return {
skuIds,
}
}),
getSlotsProductIds: protectedProcedure getSlotsProductIds: protectedProcedure
.input(z.object({ .input(z.object({
slotIds: z.array(z.number()), slotIds: z.array(z.number()),

View file

@ -85,7 +85,6 @@ export {
replaceProductTags, replaceProductTags,
toggleProductOutOfStock, toggleProductOutOfStock,
updateSlotProducts, updateSlotProducts,
getSlotProductIds,
getSlotsProductIds, getSlotsProductIds,
getAllUnits, getAllUnits,
getAllProductTags, getAllProductTags,

View file

@ -229,14 +229,6 @@ export async function updateSlotProducts(slotId: string, productIds: string[]):
} }
} }
export async function getSlotProductIds(slotId: string): Promise<number[]> {
const slot = await db.query.deliverySlotInfo.findFirst({
where: eq(deliverySlotInfo.id, parseInt(slotId)),
})
return slot?.productIds || []
}
export async function getAllUnits(): Promise<AdminUnit[]> { export async function getAllUnits(): Promise<AdminUnit[]> {
const allUnits = await db.query.units.findMany({ const allUnits = await db.query.units.findMany({
orderBy: units.shortNotation, orderBy: units.shortNotation,

View file

@ -84,7 +84,6 @@ export {
replaceProductTags, replaceProductTags,
mergeSkus, mergeSkus,
updateSlotProducts, updateSlotProducts,
getSlotProductIds,
getSlotsProductIds, getSlotsProductIds,
getAllUnits, getAllUnits,
getAllProductTags, getAllProductTags,

View file

@ -453,14 +453,6 @@ export async function updateSlotProducts(slotId: string, productIds: string[]):
} }
} }
export async function getSlotProductIds(slotId: string): Promise<number[]> {
const slot = await db.query.deliverySlotInfo.findFirst({
where: eq(deliverySlotInfo.id, parseInt(slotId)),
})
return slot?.skuIds || []
}
export async function getAllUnits(): Promise<AdminUnit[]> { export async function getAllUnits(): Promise<AdminUnit[]> {
const allUnits = await db.query.units.findMany({ const allUnits = await db.query.units.findMany({
orderBy: units.shortNotation, orderBy: units.shortNotation,

View file

@ -82,16 +82,19 @@ export interface OrderWithRelations {
createdAt: Date createdAt: Date
orderItems: Array<{ orderItems: Array<{
id: number id: number
productId: number skuId: number
quantity: string quantity: string
price: string price: string
discountedPrice: string | null discountedPrice: string | null
is_packaged: boolean is_packaged: boolean
product: { sku: {
id: number id: number
name: string name: string | null
images: unknown images: unknown
} product: {
name: string
} | null
} | null
}> }>
slot: { slot: {
deliveryTime: Date deliveryTime: Date
@ -127,16 +130,19 @@ export interface OrderDetailWithRelations {
createdAt: Date createdAt: Date
orderItems: Array<{ orderItems: Array<{
id: number id: number
productId: number skuId: number
quantity: string quantity: string
price: string price: string
discountedPrice: string | null discountedPrice: string | null
is_packaged: boolean is_packaged: boolean
product: { sku: {
id: number id: number
name: string name: string | null
images: unknown images: unknown
} product: {
name: string
} | null
} | null
}> }>
slot: { slot: {
deliveryTime: Date deliveryTime: Date
@ -387,6 +393,7 @@ export async function getOrdersWithRelations(
}, },
columns: { columns: {
id: true, id: true,
name: true,
images: true, images: true,
}, },
}, },
@ -469,6 +476,7 @@ export async function getOrderByIdWithRelations(
}, },
columns: { columns: {
id: true, id: true,
name: true,
images: true, images: true,
}, },
}, },

View file

@ -360,6 +360,13 @@ export interface AdminUnit {
fullName: string; fullName: string;
} }
export interface AdminSkuFeature {
id: number;
skuId: number;
featureName: string;
featureValue: string;
}
export interface AdminProductComboItem { export interface AdminProductComboItem {
skuId: number; skuId: number;
skuName: string | null; skuName: string | null;
@ -492,10 +499,6 @@ export interface AdminUpdateSlotProductsResult {
removed: number; removed: number;
} }
export interface AdminSlotProductIdsResult {
skuIds: number[];
}
export type AdminSlotsProductIdsResult = Record<number, number[]>; export type AdminSlotsProductIdsResult = Record<number, number[]>;
export interface AdminProductReview { export interface AdminProductReview {

View file

@ -145,7 +145,7 @@ export interface UserCartProduct {
export interface UserCartItem { export interface UserCartItem {
id: number; id: number;
productId: number; skuId: number;
quantity: number; quantity: number;
addedAt: Date; addedAt: Date;
product: UserCartProduct; product: UserCartProduct;
@ -496,7 +496,7 @@ export interface UserCouponApplicableUser {
export interface UserCouponApplicableProduct { export interface UserCouponApplicableProduct {
id: number; id: number;
couponId: number; couponId: number;
productId: number; skuId: number;
} }
export interface UserCoupon { export interface UserCoupon {
@ -506,7 +506,7 @@ export interface UserCoupon {
discountPercent: string | null; discountPercent: string | null;
flatDiscount: string | null; flatDiscount: string | null;
minOrder: string | null; minOrder: string | null;
productIds: unknown; skuIds: unknown;
maxValue: string | null; maxValue: string | null;
isApplyForAll: boolean; isApplyForAll: boolean;
validTill: Date | null; validTill: Date | null;

View file

@ -210,25 +210,6 @@ export interface token_user {
gender: string; gender: string;
} }
export interface ProductSummary {
id: number;
name: string;
shortDescription?: string;
price: number;
unit: string;
isOutOfStock: boolean;
nextDeliveryDate: string | null;
images: string[];
}
export interface GetSlotsProductIdsPayload {
slotIds: number[];
}
export interface GetSlotsProductIdsResponse {
[slotId: number]: number[];
}
export interface Order { export interface Order {
id: string; id: string;
orderId: string; orderId: string;

View file

@ -1,40 +0,0 @@
import { useQuery } from "@tanstack/react-query";
import axios from "../services/axios";
import type { ProductSummary, GetSlotsProductIdsPayload, GetSlotsProductIdsResponse } from '../../shared-types';
export interface GetProductsSummaryResponse {
products: ProductSummary[];
count: number;
}
const getAllProductsSummaryApi = async (): Promise<GetProductsSummaryResponse> => {
const response = await axios.get('/cm/products/summary');
return response.data;
};
export const useGetAllProductsSummary = () => {
return useQuery({
queryKey: ['products-summary'],
// queryFn: getAllProductsSummaryApi,
queryFn: async () => {
const response = await axios.get('/cm/products/summary');
return response.data;
}
});
};
const getSlotsProductIdsApi = async (payload: GetSlotsProductIdsPayload): Promise<GetSlotsProductIdsResponse> => {
const response = await axios.post('/av/products/slots/product-ids', payload);
return response.data;
};
export const useGetSlotsProductIds = (slotIds: number[]) => {
return useQuery({
queryKey: ['slots-product-ids', slotIds],
queryFn: () => getSlotsProductIdsApi({ slotIds }),
enabled: slotIds.length > 0,
});
};