diff --git a/.commandcode/taste/taste.md b/.commandcode/taste/taste.md index f562cac..eb6348c 100644 --- a/.commandcode/taste/taste.md +++ b/.commandcode/taste/taste.md @@ -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 diff --git a/APIS_TO_REMOVE.md b/APIS_TO_REMOVE.md deleted file mode 100644 index b0a1f25..0000000 --- a/APIS_TO_REMOVE.md +++ /dev/null @@ -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 diff --git a/apps/backend/src/dbService.ts b/apps/backend/src/dbService.ts index 46aeed8..ccf32ee 100644 --- a/apps/backend/src/dbService.ts +++ b/apps/backend/src/dbService.ts @@ -51,9 +51,7 @@ export type { AdminProductListResponse, AdminProductResponse, AdminDeleteProductResult, - AdminToggleOutOfStockResult, AdminUpdateSlotProductsResult, - AdminSlotProductIdsResult, AdminSlotsProductIdsResult, AdminProductReview, AdminProductReviewWithSignedUrls, diff --git a/apps/backend/src/postgresImporter.ts b/apps/backend/src/postgresImporter.ts index 2cd2cd7..7296535 100644 --- a/apps/backend/src/postgresImporter.ts +++ b/apps/backend/src/postgresImporter.ts @@ -64,7 +64,6 @@ // replaceProductTags, // toggleProductOutOfStock, // updateSlotProducts, -// getSlotProductIds, // getSlotsProductIds, // getAllUnits, // getAllProductTags, diff --git a/apps/backend/src/sqliteImporter.ts b/apps/backend/src/sqliteImporter.ts index c4bec49..b813fb7 100644 --- a/apps/backend/src/sqliteImporter.ts +++ b/apps/backend/src/sqliteImporter.ts @@ -74,7 +74,6 @@ export { replaceProductTags, mergeSkus, updateSlotProducts, - getSlotProductIds, getSlotsProductIds, getAllUnits, getAllProductTags, diff --git a/apps/backend/src/stores/slot-store.ts b/apps/backend/src/stores/slot-store.ts index 02c6bb5..80c1590 100644 --- a/apps/backend/src/stores/slot-store.ts +++ b/apps/backend/src/stores/slot-store.ts @@ -49,7 +49,7 @@ async function transformSlotToStoreSlot(slot: SlotWithProductsData): Promise { shortDescription: product.shortDescription, price: product.price.toString(), marketPrice: product.marketPrice?.toString() || null, - unit: product.unit?.shortNotation || null, + unit: product.unitNotation || null, images: scaffoldAssetUrl( (product.images as string[]) || [] ), diff --git a/apps/backend/src/trpc/apis/admin-apis/apis/product.ts b/apps/backend/src/trpc/apis/admin-apis/apis/product.ts index de15fd7..309fce9 100644 --- a/apps/backend/src/trpc/apis/admin-apis/apis/product.ts +++ b/apps/backend/src/trpc/apis/admin-apis/apis/product.ts @@ -8,7 +8,6 @@ import { getProductById as getProductByIdInDb, deleteProduct as deleteProductInDb, updateSlotProducts as updateSlotProductsInDb, - getSlotProductIds as getSlotProductIdsInDb, getSlotsProductIds as getSlotsProductIdsInDb, getProductReviews as getProductReviewsInDb, respondToReview as respondToReviewInDb, @@ -42,7 +41,6 @@ import type { AdminProductResponse, AdminDeleteProductResult, AdminUpdateSlotProductsResult, - AdminSlotProductIdsResult, AdminSlotsProductIdsResult, AdminUpdateProductPricesResult, } from '@packages/shared' @@ -421,31 +419,6 @@ export const productRouter = router({ } }), - getSlotProductIds: protectedProcedure - .input(z.object({ - slotId: z.string(), - })) - .query(async ({ input }): Promise => { - 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 .input(z.object({ slotIds: z.array(z.number()), diff --git a/packages/db_helper_postgres/index.ts b/packages/db_helper_postgres/index.ts index f51bba1..fe62a34 100644 --- a/packages/db_helper_postgres/index.ts +++ b/packages/db_helper_postgres/index.ts @@ -85,7 +85,6 @@ export { replaceProductTags, toggleProductOutOfStock, updateSlotProducts, - getSlotProductIds, getSlotsProductIds, getAllUnits, getAllProductTags, diff --git a/packages/db_helper_postgres/src/admin-apis/product.ts b/packages/db_helper_postgres/src/admin-apis/product.ts index 9a9bf6f..7f6f61f 100644 --- a/packages/db_helper_postgres/src/admin-apis/product.ts +++ b/packages/db_helper_postgres/src/admin-apis/product.ts @@ -229,14 +229,6 @@ export async function updateSlotProducts(slotId: string, productIds: string[]): } } -export async function getSlotProductIds(slotId: string): Promise { - const slot = await db.query.deliverySlotInfo.findFirst({ - where: eq(deliverySlotInfo.id, parseInt(slotId)), - }) - - return slot?.productIds || [] -} - export async function getAllUnits(): Promise { const allUnits = await db.query.units.findMany({ orderBy: units.shortNotation, diff --git a/packages/db_helper_sqlite/index.ts b/packages/db_helper_sqlite/index.ts index fce2a2b..ce79c6a 100644 --- a/packages/db_helper_sqlite/index.ts +++ b/packages/db_helper_sqlite/index.ts @@ -84,7 +84,6 @@ export { replaceProductTags, mergeSkus, updateSlotProducts, - getSlotProductIds, getSlotsProductIds, getAllUnits, getAllProductTags, diff --git a/packages/db_helper_sqlite/src/admin-apis/product.ts b/packages/db_helper_sqlite/src/admin-apis/product.ts index 89b2800..f29b117 100644 --- a/packages/db_helper_sqlite/src/admin-apis/product.ts +++ b/packages/db_helper_sqlite/src/admin-apis/product.ts @@ -453,14 +453,6 @@ export async function updateSlotProducts(slotId: string, productIds: string[]): } } -export async function getSlotProductIds(slotId: string): Promise { - const slot = await db.query.deliverySlotInfo.findFirst({ - where: eq(deliverySlotInfo.id, parseInt(slotId)), - }) - - return slot?.skuIds || [] -} - export async function getAllUnits(): Promise { const allUnits = await db.query.units.findMany({ orderBy: units.shortNotation, diff --git a/packages/db_helper_sqlite/src/user-apis/order.ts b/packages/db_helper_sqlite/src/user-apis/order.ts index 2e1ff77..cd88f08 100644 --- a/packages/db_helper_sqlite/src/user-apis/order.ts +++ b/packages/db_helper_sqlite/src/user-apis/order.ts @@ -82,16 +82,19 @@ export interface OrderWithRelations { createdAt: Date orderItems: Array<{ id: number - productId: number + skuId: number quantity: string price: string discountedPrice: string | null is_packaged: boolean - product: { + sku: { id: number - name: string + name: string | null images: unknown - } + product: { + name: string + } | null + } | null }> slot: { deliveryTime: Date @@ -127,16 +130,19 @@ export interface OrderDetailWithRelations { createdAt: Date orderItems: Array<{ id: number - productId: number + skuId: number quantity: string price: string discountedPrice: string | null is_packaged: boolean - product: { + sku: { id: number - name: string + name: string | null images: unknown - } + product: { + name: string + } | null + } | null }> slot: { deliveryTime: Date @@ -387,6 +393,7 @@ export async function getOrdersWithRelations( }, columns: { id: true, + name: true, images: true, }, }, @@ -469,6 +476,7 @@ export async function getOrderByIdWithRelations( }, columns: { id: true, + name: true, images: true, }, }, diff --git a/packages/shared/types/admin.ts b/packages/shared/types/admin.ts index dea702f..3607c58 100644 --- a/packages/shared/types/admin.ts +++ b/packages/shared/types/admin.ts @@ -360,6 +360,13 @@ export interface AdminUnit { fullName: string; } +export interface AdminSkuFeature { + id: number; + skuId: number; + featureName: string; + featureValue: string; +} + export interface AdminProductComboItem { skuId: number; skuName: string | null; @@ -492,10 +499,6 @@ export interface AdminUpdateSlotProductsResult { removed: number; } -export interface AdminSlotProductIdsResult { - skuIds: number[]; -} - export type AdminSlotsProductIdsResult = Record; export interface AdminProductReview { diff --git a/packages/shared/types/user.ts b/packages/shared/types/user.ts index 43506bb..e835cd9 100644 --- a/packages/shared/types/user.ts +++ b/packages/shared/types/user.ts @@ -145,7 +145,7 @@ export interface UserCartProduct { export interface UserCartItem { id: number; - productId: number; + skuId: number; quantity: number; addedAt: Date; product: UserCartProduct; @@ -496,7 +496,7 @@ export interface UserCouponApplicableUser { export interface UserCouponApplicableProduct { id: number; couponId: number; - productId: number; + skuId: number; } export interface UserCoupon { @@ -506,7 +506,7 @@ export interface UserCoupon { discountPercent: string | null; flatDiscount: string | null; minOrder: string | null; - productIds: unknown; + skuIds: unknown; maxValue: string | null; isApplyForAll: boolean; validTill: Date | null; diff --git a/packages/ui/shared-types.ts b/packages/ui/shared-types.ts index 04dd4f0..6716c9b 100755 --- a/packages/ui/shared-types.ts +++ b/packages/ui/shared-types.ts @@ -210,25 +210,6 @@ export interface token_user { 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 { id: string; orderId: string; diff --git a/packages/ui/src/common-api-hooks/product.api.tsx b/packages/ui/src/common-api-hooks/product.api.tsx deleted file mode 100644 index 4c684c6..0000000 --- a/packages/ui/src/common-api-hooks/product.api.tsx +++ /dev/null @@ -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 => { - - 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 => { - 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, - }); -}; \ No newline at end of file