Feat/product tags v2#313
Conversation
|
@Aharshi3614 is attempting to deploy a commit to the niharika-mente's projects Team on Vercel. A member of the Team first needs to authorize it. |
Aamod-Dev
left a comment
There was a problem hiding this comment.
The diff has severe code structure issues that will break the application:
- Duplicate function exports: updateProduct, deleteProduct, and searchProducts are exported twice with conflicting implementations.
- Corrupted code structure: Function bodies are split across sections. JS will throw SyntaxError for duplicate declarations.
- Model fields after export default: New tags field added to schema but existing fields appear after export default Product, making them unreachable.
Fix: Rebase on main, ensure only one copy of each exported function, verify with
ode --check.
d86ff19 to
c6232e2
Compare
Aamod-Dev
left a comment
There was a problem hiding this comment.
Request Changes
Corrupted merge — two updateProduct and two searchProducts declarations. First updateProduct references product before its definition. deleteProduct re-exported as hard-delete after soft-delete exists. product.model.js has mongoose.model(...) and export default inserted mid-schema before schema is complete. Needs a clean rebase.
|
Corrupted merge, needs clean rebase |
Aamod-Dev
left a comment
There was a problem hiding this comment.
I have reviewed the latest changes pushed to this PR.
Backend Issues
Corrupted Code Structure (BACKEND/models/product.model.js)
- Severity: Critical. The issue's severity is absolute as the server will fail to start in any environment.
- Issue: The schema definition is duplicated and structurally corrupted. The first model definition correctly ends and exports on line 53 (
export default Product;). Immediately following the export, schema fields (likedescription: { ... }) are written directly into the global scope. This results in an immediateSyntaxErrorupon compilation.
Corrupted Code Structure (BACKEND/controllers/product.controller.js)
- Severity: Critical. The issue's severity is absolute as the server will fail to start in any environment.
- Issue: The file contains severe structural corruption, likely from a broken merge. It includes:
- Duplicate declarations for
updateProductandsearchProducts. - Unclosed
tryblocks (e.g., at line 177) that lack closing braces orcatchblocks. exportstatements nested inside other function bodies (e.g.,getProductByIdis nested insidesearchProducts).- Missing function bodies (e.g.,
deleteProductis declared but immediately followed by another function declarationgetProductBundle).
- Duplicate declarations for
ReferenceError in updateProduct (BACKEND/controllers/product.controller.js)
- Severity: High. If the syntax errors are resolved, this bug will arise whenever a user attempts to update a product, leading to a crash on this endpoint.
- Issue: At line 162, the code references
product.name,product.price, andproduct.image, but theproductvariable is never defined or extracted fromreq.bodyor the database.new Product(product)is subsequently called with this undefined variable.
Frontend Issues
Tags Limit Ignored (FRONTEND/src/pages/CreatePage.jsx)
- Severity: Medium. When a user creates a product and inputs more than 5 tags, the frontend will fail to restrict the tag count. This may lead to unexpected backend validation errors if the backend correctly enforces the 5-tag limit.
- Issue: In the
tagsinputonChangehandler,setNewProductis called twice consecutively:The second call completely overwrites the first, rendering thesetNewProduct({ ...newProduct, tags: tagsArray.slice(0, 5) }); setNewProduct({ ...newProduct, tags: tagsArray });
tagsArray.slice(0, 5)truncation logic ineffective.
Aamod-Dev
left a comment
There was a problem hiding this comment.
Looks good, approved!
Aamod-Dev
left a comment
There was a problem hiding this comment.
Needs changes: There are merge conflicts. Please resolve them.
|
Closing in favor of clean replacement PR with only product-tags changes, extracted from corrupted merge. |
Added product tags feature:
Closes #258