AI Review Center
Commit Review Workspace ?
Select a commit on the left to inspect quality, security, business value, findings, and suggested code changes.
Project AI Score
?
63%
Quality Avg
?
68%
Security Avg
?
45%
Reviews
?
56
Review Result ?
jattin01/avriti · 31ad905b
This commit adds dynamic handling of cart and product detail page addresses including CRUD operations, form handling, and UI state management. The implementation covers address loading, selection, editing, saving, and deleting with basic validation. However, there is limited error handling for network/fetch errors and no validation for phone numbers or other inputs beyond required fields. Some error cases have empty catch blocks which reduces robustness and security. The commit adds meaningful business logic and enhances user experience by allowing dynamic address updates. Security-wise, bearer tokens are used but more thorough validation and error feedback would improve the security and reliability.
Quality
?
75%
Security
?
50%
Business Value
?
80%
Maintainability
?
68%
Issues & Suggested Fixes
?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Empty Catch Block During Loadaddresses
Where
app/checkout/page.tsx:110
Issue / Evidence
empty catch block during loadAddresses
Suggested Fix
add error logging or user feedback to improve bug risk and quality
Empty Catch Block During Deleteaddress
Where
app/checkout/page.tsx:260
Issue / Evidence
empty catch block during deleteAddress
Suggested Fix
add error handling and feedback to improve bug risk and quality
Missing Validation
Where
app/checkout/page.tsx:211
Issue / Evidence
limited input validation for modalForm in saveAddress
Suggested Fix
add phone number format validation and consider validation for other fields to reduce bug risk
Error Feedback Is Limited To Data.message...
Where
app/checkout/page.tsx:230
Issue / Evidence
error feedback is limited to data.message or generic message
Suggested Fix
enhance error handling to show more detailed messages where possible to improve quality and business value
Missing Validation
Where
app/checkout/page.tsx:271
Issue / Evidence
email validation regex is simple
Suggested Fix
consider using more robust validation or libraries to reduce bug risk
Vague And Minimal Description
Where
commit message
Issue / Evidence
vague and minimal description
Suggested Fix
improve commit message clarity and detail to improve team communication and business value
Code Change Preview · app/checkout/page.tsx
?
Removed / Before Commit
- import InnerBanner from "@/components/inner-banner"; - import { apiGetCart, getToken } from "@/lib/cart"; - - - type CheckoutItem = { - product_id: number; - title: string; - quantity: number; - }; - - export default function CheckoutPage() { - const [items, setItems] = useState<CheckoutItem[]>([]); - const [loading, setLoading] = useState(true); - - // form fields - const [fullName, setFullName] = useState(""); - const [email, setEmail] = useState(""); - const [phone, setPhone] = useState("");
Added / After Commit
+ import InnerBanner from "@/components/inner-banner"; + import { apiGetCart, getToken } from "@/lib/cart"; + + type CheckoutItem = { + product_id: number; + title: string; + quantity: number; + }; + + type Address = { + id: number; + full_name: string; + phone: string; + email?: string; + address_line1: string; + address_line2?: string; + landmark?: string; + city: string;
Removed / Before Commit
- import Image from "next/image"; - import { CreditCard, Home, MapPin, Phone, User } from "lucide-react"; - import InnerBanner from "@/components/inner-banner"; - - const orderItems = [ - { - id: 1, - name: "Avriti Shuddhi - Mopping Salt", - unitPrice: 70, - quantity: 1, - image: "/1.jpeg", - }, - { - id: 2, - name: "Avriti Jal Shuddhi - Bathroom Salt ", - unitPrice: 70, - quantity: 1, - image: "/product3.jpeg",
Added / After Commit
+ "use client"; + + import { useEffect, useState } from "react"; + import { useSearchParams } from "next/navigation"; + import Image from "next/image"; + import { CreditCard, Home, MapPin, Phone, User } from "lucide-react"; + import InnerBanner from "@/components/inner-banner"; + + interface OrderItem { + id: number; + product_name: string; + price: number; + quantity: number; + total: number; + product_image: string | null; + } + + interface OrderData {
Removed / Before Commit
- "use client"; - - import InnerBanner from "@/components/inner-banner"; - import { OrderCard } from "@/components/order-card"; - - // Mock data - replace with API call - const mockOrders = [ - { - id: "1", - orderNumber: "100259", - items: 2, - date: "5/1/2026, 7:13:50 PM", - status: "pending" as const, - paymentMethod: "Cash on Delivery", - paymentStatus: "unpaid" as const, - price: "147", - shopName: "Avriti", - },
Added / After Commit
+ "use client"; + + import { useEffect, useState } from "react"; + import InnerBanner from "@/components/inner-banner"; + import { OrderCard } from "@/components/order-card"; + + interface OrderItem { + id: number; + product_id: number; + product_name: string; + variant_name: string | null; + attribute_name: string | null; + attribute_value: string | null; + sku: string | null; + mrp: number; + price: number; + quantity: number; + total: number;
Removed / Before Commit
- "use client"; - - import { useState } from "react"; - import Link from "next/link"; - import type { ReactNode } from "react"; - import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; - import { - faUser, faBoxOpen, faMapMarkerAlt, faSignOutAlt, - faPen, faTrash, faPlus, faShieldAlt, - } from "@fortawesome/free-solid-svg-icons"; - - const user = { - name: "Varinder Kaur", - email: "vkaur20@gmail.com", - phone: "+919501711002", - daysSinceJoining: 26, - totalOrders: 1, - initials: "VK",
Added / After Commit
+ "use client"; + + import { useState, useEffect } from "react"; + import Link from "next/link"; + import type { ReactNode } from "react"; + import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + import { + faBoxOpen, faPen, faTrash, faPlus, + } from "@fortawesome/free-solid-svg-icons"; + + + interface Address { + id: number; + type: string; + full_name: string; + phone: string; + email?: string; + address_line1: string;
Removed / Before Commit
- "use client"; - - import { Card } from "@/components/ui/card"; - import { Button } from "@/components/ui/button"; - import Image from "next/image"; - import Link from "next/link"; - interface Order { - id: string; - price: string; - logo?: string; - shopName?: string; - } - - const statusColors = { - export function OrderCard({ order }: { order: Order }) { - return ( - <Card className="overflow-hidden p-6 mb-4 md:flex items-center justify-between gap-6"> - <div className="sm:flex-row flex-col flex items-start gap-6 flex-1">
Added / After Commit
+ "use client"; + + import { Card } from "@/components/ui/card"; + import Link from "next/link"; + interface Order { + id: string; + price: string; + logo?: string; + shopName?: string; + productImage?: string | null; + productName?: string; + } + + const statusColors = { + export function OrderCard({ order }: { order: Order }) { + return ( + <Card className="overflow-hidden p-6 mb-4 md:flex items-center justify-between gap-6"> + <Link href={`/my-order?id=${order.id}`} className="sm:flex-row flex-col flex items-start gap-6 flex-1 cursor-pointer">
Removed / Before Commit
- const [product, setProduct] = useState<Product | null>(null); - const [quantity, setQuantity] = useState(1); - const [selectedAttr, setSelectedAttr] = useState<Attribute | null>(null); - - const apiUrl = process.env.NEXT_PUBLIC_API_URL ?? ""; - - const found = data.data.find((p: any) => p.slug === slug); - if (found) { - setProduct(found); - setSelectedAttr(found.attributes?.[0] ?? null); - } - } - }) - ); - } - - const imageUrl = product.thumbnail?.[0] - ? `${apiUrl}/${product.thumbnail[0]}`
Added / After Commit
+ const [product, setProduct] = useState<Product | null>(null); + const [quantity, setQuantity] = useState(1); + const [selectedAttr, setSelectedAttr] = useState<Attribute | null>(null); + const [activeImg, setActiveImg] = useState<string | null>(null); + + const apiUrl = process.env.NEXT_PUBLIC_API_URL ?? ""; + + const found = data.data.find((p: any) => p.slug === slug); + if (found) { + setProduct(found); + // // Old: setSelectedAttr(found.attributes?.[0] ?? null); + const firstInStock = (found.attributes ?? []).find((a: Attribute) => a.in_stock) ?? found.attributes?.[0] ?? null; + setSelectedAttr(firstInStock); + setActiveImg(found.thumbnail?.[0] ? `${apiUrl}/${found.thumbnail[0]}` : null); + } + } + }) + );