Showing AI reviews for avriti
Project AI Score ?
63%
Quality Avg ?
68%
Security Avg ?
45%
Reviews ?
56

Review Result ?

jattin01/avriti · 91656aee
This commit adds multiple UI fixes by including new properties such as selling_price and mrp across many components and files. It improves the display and pricing logic on product-related components by handling null values and adding fallbacks. However, there is noticeable code repetition especially in accessing nested attributes, and potential for minor bugs due to many optional chaining without strict typing or validation. The commit message is vague, lacking detailed description of changes and their impact.
Quality ?
75%
Security ?
80%
Business Value ?
70%
Maintainability ?
73%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Vague And Not Descriptive
Where commit message
Issue / Evidence vague and not descriptive
Suggested Fix provide detailed explanation of the UI fixes and affected components to improve business value score and clarity
Duplicate Logic
Where app/cart/page.tsx:88
Issue / Evidence repeated optional chaining to fetch attribute data
Suggested Fix create a utility function to fetch attribute by sr_no to reduce code duplication and improve quality
Setting Sellingprice To Null When Missing
Where app/cart/page.tsx:90
Issue / Evidence setting sellingPrice to null when missing
Suggested Fix consider using 0 or a defined fallback to prevent UI inconsistencies and bugs
Conditional Rendering Of Mrp
Where app/shop/page.tsx:151
Issue / Evidence conditional rendering of MRP
Suggested Fix add checks to ensure sellingPrice is defined before comparing to avoid unexpected behavior
Duplicate Logic
Where components/ProductDetailSection.tsx:144
Issue / Evidence similar repeated logic for pricing display
Suggested Fix refactor to reusable component or helper function to reduce repetition and potential errors
Conditional Display Of Prices
Where components/product-card.tsx:38
Issue / Evidence conditional display of prices
Suggested Fix ensure consistent formatting and handling for edge cases like zero or null prices
Missing Validation
Where lib/cart.ts:8
Issue / Evidence added selling_price and mrp without validation
Suggested Fix incorporate type checks or validation logic when using these values downstream to prevent bugs
Code Change Preview · app/cart/page.tsx ?
Removed / Before Commit
- thumbnail: string;
- attribute_name: string;
- attribute_value: string;
- quantity: number;
- };
- 
- thumbnail: d.thumbnail ?? "/product2.jpeg",
- attribute_name: d.attribute_name ?? "",
- attribute_value: d.attribute_value ?? "",
- quantity: d.quantity,
- }))
- );
- thumbnail: c.thumbnail,
- attribute_name: c.attribute_name,
- attribute_value: c.attribute_value,
- quantity: c.quantity,
- }))
- );
Added / After Commit
+ thumbnail: string;
+ attribute_name: string;
+ attribute_value: string;
+   selling_price: number;
+   mrp: number;
+ quantity: number;
+ };
+ 
+ thumbnail: d.thumbnail ?? "/product2.jpeg",
+ attribute_name: d.attribute_name ?? "",
+ attribute_value: d.attribute_value ?? "",
+           selling_price: d.selling_price ?? 0,
+           mrp: d.mrp ?? 0,
+ quantity: d.quantity,
+ }))
+ );
+ thumbnail: c.thumbnail,
+ attribute_name: c.attribute_name,
Removed / Before Commit
- type FeaturedProduct = {
- slug: string;
- name: string;
-   attrName: string;
-   price: string;
- image: string;
- tone: string;
- category: string;
- const mapped: FeaturedProduct[] = data.data.map((p: any, i: number) => ({
- slug: p.slug,
- name: p.title,
-             attrName: p.attributes?.find((a: any) => a.sr_no === 1)?.name ?? "",
-             price: p.attributes?.find((a: any) => a.sr_no === 1)?.value ?? "N/A",
- image: p.thumbnail?.[0]
- ? `${process.env.NEXT_PUBLIC_API_URL}/${p.thumbnail[0]}`
- : "/product2.jpeg",
Added / After Commit
+ type FeaturedProduct = {
+ slug: string;
+ name: string;
+   attrValue: string;
+   variantName: string;
+   sellingPrice: number | null;
+   mrp: number | null;
+ image: string;
+ tone: string;
+ category: string;
+ const mapped: FeaturedProduct[] = data.data.map((p: any, i: number) => ({
+ slug: p.slug,
+ name: p.title,
+             attrValue: p.attributes?.find((a: any) => a.sr_no === 1)?.value ?? "",
+             variantName: p.variant?.name ?? "",
+             sellingPrice: p.attributes?.find((a: any) => a.sr_no === 1)?.selling_price ?? null,
+             mrp: p.attributes?.find((a: any) => a.sr_no === 1)?.mrp ?? null,
+ image: p.thumbnail?.[0]
Removed / Before Commit
- type FeaturedProduct = {
- slug: string;
- name: string;
-   attrName: string;
-   price: string;
- image: string;
- tone: string;
- category: string;
- const mapped: FeaturedProduct[] = data.data.map((p: any, i: number) => ({
- slug: p.slug,
- name: p.title,
-             attrName: p.attributes?.find((a: any) => a.sr_no === 1)?.name ?? "",
-             price: p.attributes?.find((a: any) => a.sr_no === 1)?.value ?? "N/A",
- image: p.thumbnail?.[0]
- ? `${process.env.NEXT_PUBLIC_API_URL}/${p.thumbnail[0]}`
- : "/product2.jpeg",
Added / After Commit
+ type FeaturedProduct = {
+ slug: string;
+ name: string;
+   attrValue: string;
+   variantName: string;
+   sellingPrice: number | null;
+   mrp: number | null;
+ image: string;
+ tone: string;
+ category: string;
+ const mapped: FeaturedProduct[] = data.data.map((p: any, i: number) => ({
+ slug: p.slug,
+ name: p.title,
+             attrValue: p.attributes?.find((a: any) => a.sr_no === 1)?.value ?? "",
+             variantName: p.variant?.name ?? "",
+             sellingPrice: p.attributes?.find((a: any) => a.sr_no === 1)?.selling_price ?? null,
+             mrp: p.attributes?.find((a: any) => a.sr_no === 1)?.mrp ?? null,
+ image: p.thumbnail?.[0]
Removed / Before Commit
- title: string;
- slug: string;
- thumbnail: string[];
- attributes: {
- sr_no: number;
- name: string;
- value: string;
- }[];
- }
- 
- ? `${process.env.NEXT_PUBLIC_API_URL}/${product.thumbnail[0]}`
- : '/product2.jpeg';
- 
-                   // attributes me sr_no 1 ki value aur name
- const attr1 = product.attributes?.find((attr) => attr.sr_no === 1);
-                   const price = attr1?.value ?? 'N/A';
-                   const attrName = attr1?.name ?? '';
- 
Added / After Commit
+ title: string;
+ slug: string;
+ thumbnail: string[];
+   variant?: { name: string };
+ attributes: {
+ sr_no: number;
+ name: string;
+ value: string;
+     mrp: number;
+     selling_price: number;
+     in_stock: boolean;
+ }[];
+ }
+ 
+ ? `${process.env.NEXT_PUBLIC_API_URL}/${product.thumbnail[0]}`
+ : '/product2.jpeg';
+ 
+ const attr1 = product.attributes?.find((attr) => attr.sr_no === 1);
Removed / Before Commit
- type ProductCardProps = {
- slug: string;
- name: string;
-   attrName?: string;
-   price: string;
- image: string;
- tone: string;
- category?: string;
- <Card className="overflow-hidden">
- <Link href={`/shop/${product.slug}`} className="block h-full flex flex-col justify-between">
- <h3 className="mt-2 text-lg mb-[20px] text-[var(--textcolor)] font-normal">
-           {product.name}{product.attrName ? ` - ${product.attrName}` : ""}
- </h3>
- <div className={`relative h-[400px] ${product.tone}`}>
- <img
- </div>
- 
- <div className="mt-[20px]">
Added / After Commit
+ type ProductCardProps = {
+ slug: string;
+ name: string;
+   attrValue?: string;
+   variantName?: string;
+   sellingPrice?: number | null;
+   mrp?: number | null;
+ image: string;
+ tone: string;
+ category?: string;
+ <Card className="overflow-hidden">
+ <Link href={`/shop/${product.slug}`} className="block h-full flex flex-col justify-between">
+ <h3 className="mt-2 text-lg mb-[20px] text-[var(--textcolor)] font-normal">
+           {product.name}
+           {product.attrValue ? ` - ${product.attrValue}${product.variantName ? ` ${product.variantName}` : ''}` : ''}
+ </h3>
+ <div className={`relative h-[400px] ${product.tone}`}>
+ <img
Removed / Before Commit
- type FeaturedProduct = {
- slug: string;
- name: string;
-   attrName: string;
-   price: string;
- image: string;
- tone: string;
- category: string;
Added / After Commit
+ type FeaturedProduct = {
+ slug: string;
+ name: string;
+   attrValue: string;
+   variantName: string;
+   sellingPrice: number | null;
+   mrp: number | null;
+ image: string;
+ tone: string;
+ category: string;
Removed / Before Commit
- import { isLoggedIn, addToLocalCart, apiAddToCart } from "@/lib/cart";
- 
- type Attribute = {
- name: string;
- value: string;
- };
- 
- type Product = {
- attributes?: Attribute[];
- thumbnail?: string[];
- category?: { name: string };
- };
- 
- export default function ProductDetailSection({ slug }: { slug: string }) {
- thumbnail: imageUrl,
- attribute_name: selectedAttr.name,
- attribute_value: selectedAttr.value,
- quantity,
Added / After Commit
+ import { isLoggedIn, addToLocalCart, apiAddToCart } from "@/lib/cart";
+ 
+ type Attribute = {
+   sr_no: number;
+ name: string;
+ value: string;
+   mrp: number;
+   selling_price: number;
+   stock_qty: number;
+   critical_qty: number;
+   sku: string;
+   in_stock: boolean;
+ };
+ 
+ type Product = {
+ attributes?: Attribute[];
+ thumbnail?: string[];
+ category?: { name: string };
Removed / Before Commit
- thumbnail: string;
- attribute_name: string;
- attribute_value: string;
- quantity: number;
- };
Added / After Commit
+ thumbnail: string;
+ attribute_name: string;
+ attribute_value: string;
+   selling_price: number;
+   mrp: number;
+ quantity: number;
+ };