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

Review Result ?

jattin01/avriti · 1c0bae73
The commit adds frontend features including improved error handling on login and registration, detailed display of billing and shipping addresses in orders, and a profile image modal with upload capability. The user experience is enhanced by clear UI elements and fallback values for missing data. However, error handling could be clearer and more uniform. There are security risks around profile image upload, such as missing validation or protection from malicious files. The commit message is vague and doesn't clearly explain the changes. Some repetitive code for error messaging can be refactored for maintainability.
Quality ?
75%
Security ?
40%
Business Value ?
70%
Maintainability ?
73%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Vague And Non Descriptive
Where commit message
Issue / Evidence vague and non-descriptive
Suggested Fix improve commit message to clearly describe feature additions and error handling improvements
Error Handling Swallows Parsing Errors Sil...
Where app/login/page.tsx:27
Issue / Evidence error handling swallows parsing errors silently
Suggested Fix handle JSON parse errors explicitly to avoid silent failures
Similar Silent Catch On Json Parse
Where app/register/page.tsx:35
Issue / Evidence similar silent catch on JSON parse
Suggested Fix handle errors explicitly to improve reliability
Missing Validation
Where app/profile/page.tsx:255
Issue / Evidence file upload lacks validation
Suggested Fix implement client-side validation for file type and size to improve security
No Feedback On Upload Errors
Where app/profile/page.tsx:255
Issue / Evidence no feedback on upload errors
Suggested Fix add error handling and user feedback on upload failures
Closing Modal Immediately After Upload Sta...
Where app/profile/page.tsx:257
Issue / Evidence closing modal immediately after upload start
Suggested Fix consider awaiting upload completion before closing or indicate ongoing process to user
Duplicate Logic
Where app/my-order/page.tsx:215-256
Issue / Evidence duplicate display code for addresses
Suggested Fix refactor address display components to reduce duplication and improve maintainability
Error Message Extraction Can Be More Robus...
Where app/login/page.tsx:29
Issue / Evidence error message extraction can be more robust
Suggested Fix unify error extraction logic for consistent error messages
Hardcoded Error Message For Email Exists
Where app/register/page.tsx:37
Issue / Evidence hardcoded error message for email exists
Suggested Fix consider internationalization and dynamic messages
Code Change Preview · app/login/page.tsx ?
Removed / Before Commit
- try {
- const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/customer/login`, {
- method: "POST",
-         headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ email, password }),
- });
-       const data = await res.json();
- if (!res.ok) {
-         setError("Invalid email or password. Please check your credentials and try again.");
- return;
- }
- try {
Added / After Commit
+ try {
+ const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/customer/login`, {
+ method: "POST",
+         headers: { "Content-Type": "application/json", "Accept": "application/json" },
+ body: JSON.stringify({ email, password }),
+ });
+       const data = await res.json().catch(() => null);
+ if (!res.ok) {
+         const msg = data?.errors
+           ? Object.values(data.errors).flat()[0]
+           : data?.message || "Invalid email or password. Please check your credentials and try again.";
+         setError(String(msg));
+ return;
+ }
+ try {
Removed / Before Commit
- tax: number;
- total_amount: number;
- shipping_address: Record<string, string> | null;
- delivery_instructions: string | null;
- items: OrderItem[];
- created_at: string;
- if (error || !order) return <div className="bg-white"><InnerBanner title="My Orders" /><div className="text-center py-20 text-red-500">{error || "Order not found."}</div></div>;
- 
- const addr = order.shipping_address;
- const paymentLabel = order.payment_method === "cod" ? "Cash on Delivery" : order.payment_method === "upi" ? "UPI" : "Card";
- 
- const orderMeta = [
- </aside>
- 
- <section className="rounded-[8px] border border-[#E3DED6] bg-[#FBF9F5] p-4 sm:p-6">
-             <div className="grid gap-8 sm:grid-cols-2">
-               <div>
-                 <h2 className="flex items-center gap-2 text-[15px] font-bold text-[var(--color-primary-700)]">
Added / After Commit
+ tax: number;
+ total_amount: number;
+ shipping_address: Record<string, string> | null;
+   billing_address: Record<string, string> | null;
+ delivery_instructions: string | null;
+ items: OrderItem[];
+ created_at: string;
+ if (error || !order) return <div className="bg-white"><InnerBanner title="My Orders" /><div className="text-center py-20 text-red-500">{error || "Order not found."}</div></div>;
+ 
+ const addr = order.shipping_address;
+   const billAddr = order.billing_address;
+ const paymentLabel = order.payment_method === "cod" ? "Cash on Delivery" : order.payment_method === "upi" ? "UPI" : "Card";
+ 
+ const orderMeta = [
+ </aside>
+ 
+ <section className="rounded-[8px] border border-[#E3DED6] bg-[#FBF9F5] p-4 sm:p-6">
+             <h2 className="flex items-center gap-2 text-[15px] font-bold text-[var(--color-primary-700)] mb-4">
Removed / Before Commit
- const [form, setForm] = useState({ full_name: "", email: "", phone: "" });
- const [addresses, setAddresses] = useState<Address[]>([]);
- const [message, setMessage] = useState("");
- 
- const API = process.env.NEXT_PUBLIC_API_URL;
- 
- <div className="mx-auto grid max-w-7xl gap-8 px-4 py-14 sm:px-6 grid md:grid-cols-[220px_1fr] gap-5 items-start">
- 
- {/* Sidebar */}
-         <div className="bg-[var(--color-primary-700)] rounded-2xl p-5 md:sticky top-24">
-           <div className="flex flex-col items-center text-center mb-6">
- <div className="relative">
-               <label className="w-16 h-16 rounded-full bg-[#fff] flex items-center justify-center text-xl font-medium text-[var(--color-primary-700)] overflow-hidden cursor-pointer">
- {customer?.profile_img_url ? (
-                   <img src={customer.profile_img_url} alt={customer.full_name} className="h-full w-full object-cover" />
- ) : (
- initials
- )}
Added / After Commit
+ const [form, setForm] = useState({ full_name: "", email: "", phone: "" });
+ const [addresses, setAddresses] = useState<Address[]>([]);
+ const [message, setMessage] = useState("");
+   const [imgModal, setImgModal] = useState(false);
+ 
+ const API = process.env.NEXT_PUBLIC_API_URL;
+ 
+ <div className="mx-auto grid max-w-7xl gap-8 px-4 py-14 sm:px-6 grid md:grid-cols-[220px_1fr] gap-5 items-start">
+ 
+ {/* Sidebar */}
+         <div className="bg-[var(--color-primary-700)] rounded-2xl p-5 md:sticky top-24  h-70 ">
+           <div className="flex flex-col items-center text-center mb-7 ">
+ <div className="relative">
+               <div
+                 onClick={() => setImgModal(true)}
+                 className="w-24 h-25 rounded-full bg-[#fff] flex items-center justify-center text-2xl font-medium text-[var(--color-primary-700)] overflow-hidden cursor-pointer"
+               >
+ {customer?.profile_img_url ? (
Removed / Before Commit
- try {
- const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/customer/register`, {
- method: "POST",
-         headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ full_name: fullName, email, phone, password }),
- });
-       const data = await res.json();
- if (!res.ok) {
-         const msg = data?.errors?.email?.[0] || data?.message || "Registration failed. Please try again.";
- setError(msg);
- return;
- }
Added / After Commit
+ try {
+ const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/customer/register`, {
+ method: "POST",
+         headers: { "Content-Type": "application/json", "Accept": "application/json" },
+ body: JSON.stringify({ full_name: fullName, email, phone, password }),
+ });
+       const data = await res.json().catch(() => null);
+ if (!res.ok) {
+         const msg = data?.errors?.email?.[0]
+           ? "Email already exists."
+           : data?.errors
+             ? Object.values(data.errors).flat()[0]
+             : data?.message || "Registration failed. Please try again.";
+ setError(msg);
+ return;
+ }