enh
This commit is contained in:
parent
0cbd24341f
commit
db2ee44a5f
16 changed files with 35 additions and 131 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -51,9 +51,7 @@ export type {
|
|||
AdminProductListResponse,
|
||||
AdminProductResponse,
|
||||
AdminDeleteProductResult,
|
||||
AdminToggleOutOfStockResult,
|
||||
AdminUpdateSlotProductsResult,
|
||||
AdminSlotProductIdsResult,
|
||||
AdminSlotsProductIdsResult,
|
||||
AdminProductReview,
|
||||
AdminProductReviewWithSignedUrls,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@
|
|||
// replaceProductTags,
|
||||
// toggleProductOutOfStock,
|
||||
// updateSlotProducts,
|
||||
// getSlotProductIds,
|
||||
// getSlotsProductIds,
|
||||
// getAllUnits,
|
||||
// getAllProductTags,
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ export {
|
|||
replaceProductTags,
|
||||
mergeSkus,
|
||||
updateSlotProducts,
|
||||
getSlotProductIds,
|
||||
getSlotsProductIds,
|
||||
getAllUnits,
|
||||
getAllProductTags,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ async function transformSlotToStoreSlot(slot: SlotWithProductsData): Promise<Slo
|
|||
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[]) || []
|
||||
),
|
||||
|
|
@ -125,7 +125,7 @@ export async function initializeSlotStore(): Promise<void> {
|
|||
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[]) || []
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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<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
|
||||
.input(z.object({
|
||||
slotIds: z.array(z.number()),
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ export {
|
|||
replaceProductTags,
|
||||
toggleProductOutOfStock,
|
||||
updateSlotProducts,
|
||||
getSlotProductIds,
|
||||
getSlotsProductIds,
|
||||
getAllUnits,
|
||||
getAllProductTags,
|
||||
|
|
|
|||
|
|
@ -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[]> {
|
||||
const allUnits = await db.query.units.findMany({
|
||||
orderBy: units.shortNotation,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ export {
|
|||
replaceProductTags,
|
||||
mergeSkus,
|
||||
updateSlotProducts,
|
||||
getSlotProductIds,
|
||||
getSlotsProductIds,
|
||||
getAllUnits,
|
||||
getAllProductTags,
|
||||
|
|
|
|||
|
|
@ -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[]> {
|
||||
const allUnits = await db.query.units.findMany({
|
||||
orderBy: units.shortNotation,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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<number, number[]>;
|
||||
|
||||
export interface AdminProductReview {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue