first commit
3
.eslintrc.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "next/core-web-vitals"
|
||||
}
|
||||
36
.gitignore
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
.yarn/install-state.gz
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
63
GUEST_CART_FIX.txt
Normal file
@ -0,0 +1,63 @@
|
||||
// GUEST CART FIX - Copy this handleAddToCart function
|
||||
// Replace lines 49-88 in src/components/Product/Product.tsx
|
||||
|
||||
const handleAddToCart = async () => {
|
||||
const token = localStorage.getItem("token"); // check login
|
||||
const productId = data._id || data.id; // Handle both _id and id
|
||||
|
||||
const payload = {
|
||||
productId: data._id,
|
||||
quantity: data.quantityPurchase || 1,
|
||||
color: activeColor ? activeColor : data?.variation[0]?.color,
|
||||
size: activeSize ? activeSize : data?.sizes[0],
|
||||
};
|
||||
|
||||
// Create cart item with proper structure
|
||||
const cartItem = {
|
||||
...data,
|
||||
id: productId, // Ensure ID is set for localStorage
|
||||
quantity: payload.quantity,
|
||||
selectedColor: payload.color,
|
||||
selectedSize: payload.size
|
||||
};
|
||||
|
||||
console.log("🛒 Adding to cart:", cartItem);
|
||||
console.log("📦 Current cart:", cartState.cartArray);
|
||||
|
||||
// ✅ Always update Redux (works for both guest + logged-in users)
|
||||
const existingItem = cartState.cartArray.find((item) =>
|
||||
(item.id === productId || item._id === productId)
|
||||
);
|
||||
|
||||
if (!existingItem) {
|
||||
console.log("➕ Adding new item to cart");
|
||||
addToCart(cartItem);
|
||||
} else {
|
||||
console.log("🔄 Updating existing item");
|
||||
updateCart(productId, payload.quantity, payload.size, payload.color);
|
||||
}
|
||||
|
||||
// ✅ If logged in → also sync with API
|
||||
if (token) {
|
||||
try {
|
||||
const response = await axios.post(`${BaseURL}/cart`, payload, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
console.log("✅ Cart synced with API");
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(
|
||||
"❌ Error syncing cart:",
|
||||
error.response?.data?.message || error.message
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.log("🛒 Guest mode: cart stored in localStorage via Redux");
|
||||
}
|
||||
|
||||
openModalCart();
|
||||
};
|
||||
36
README.md
Normal file
@ -0,0 +1,36 @@
|
||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||
31
fix_quantity_change.ps1
Normal file
@ -0,0 +1,31 @@
|
||||
$filePath = "d:\Metatron cube\falcon fashion\anvogue-multipurpose-ecommerce-react-nextjs\Main\anvogue\src\app\cart\page.tsx"
|
||||
$content = Get-Content $filePath -Raw
|
||||
|
||||
# Find and replace - add the updateCart logic before the token line
|
||||
$oldLine = " const token = localStorage.getItem(`"token`")"
|
||||
$newLines = @"
|
||||
// ✅ Immediately update CartContext for instant subtotal update
|
||||
const cartItem = cartState.cartArray.find(
|
||||
(cartItem) => (cartItem.id === item.product._id || cartItem.id === item.product.id)
|
||||
);
|
||||
if (cartItem) {
|
||||
updateCart(cartItem.id, newQuantity, item.size, item.color);
|
||||
}
|
||||
|
||||
// ✅ Then sync with API
|
||||
const token = localStorage.getItem("token")
|
||||
"@
|
||||
|
||||
$content = $content.Replace($oldLine, $newLines)
|
||||
|
||||
# Also update the comment after getCartData
|
||||
$content = $content.Replace(
|
||||
" getCartData()",
|
||||
" getCartData() // Refresh local cart state"
|
||||
)
|
||||
|
||||
# Remove the old commented code
|
||||
$content = $content -replace " // const itemToUpdate = cart\.find\(\(item\) => item\._id === cart\._id\);[\r\n]+[\r\n]+[\r\n]+ // // Kiểm tra xem sản phẩm có tồn tại không[\r\n]+ // if \(itemToUpdate\) \{[\r\n]+ // // Truyền giá trị hiện tại của selectedSize và selectedColor[\r\n]+ // updateCart\(cart\._id, newQuantity, itemToUpdate\.selectedSize, itemToUpdate\.selectedColor\);[\r\n]+ // \}[\r\n]+", ""
|
||||
|
||||
Set-Content -Path $filePath -Value $content -NoNewline
|
||||
Write-Host "✅ Updated handleQuantityChange function successfully"
|
||||
13
next.config.js
Normal file
@ -0,0 +1,13 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
images: {
|
||||
domains: [
|
||||
'media.craiyon.com',
|
||||
'pics.craiyon.com',
|
||||
'example.com', // add any other domains you use for images
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
6304
package-lock.json
generated
Normal file
44
package.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "anvogue",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@phosphor-icons/react": "^2.0.14",
|
||||
"axios": "^1.9.0",
|
||||
"fabric": "^4.6.0",
|
||||
"framer-motion": "^10.17.4",
|
||||
"next": "14.0.3",
|
||||
"nprogress": "^0.2.0",
|
||||
"rc-slider": "^10.5.0",
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
"react-fast-marquee": "^1.6.2",
|
||||
"react-loading": "^2.0.3",
|
||||
"react-paginate": "^8.2.0",
|
||||
"react-slick": "^0.29.0",
|
||||
"react-slider": "^2.0.6",
|
||||
"sass": "^1.69.5",
|
||||
"slick-carousel": "^1.8.1",
|
||||
"swiper": "^11.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"@types/react-slick": "^0.23.12",
|
||||
"@types/react-slider": "^1.3.6",
|
||||
"autoprefixer": "^10.0.1",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.0.3",
|
||||
"postcss": "^8",
|
||||
"react-image-zoom": "^1.3.1",
|
||||
"tailwindcss": "^3.3.0",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
6
postcss.config.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
BIN
public/images/avatar/1.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/avatar/2.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/avatar/3.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/avatar/4.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/avatar/5.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/avatar/6.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/avatar/7.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/avatar/8.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/banner/1.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
public/images/banner/10.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
public/images/banner/11.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
public/images/banner/12.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
public/images/banner/13.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
public/images/banner/14.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
public/images/banner/15.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
public/images/banner/16.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
public/images/banner/17.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
public/images/banner/18.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
public/images/banner/19.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
public/images/banner/2.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
public/images/banner/20.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
public/images/banner/21.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/banner/22.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/banner/23.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/banner/24.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/images/banner/25.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/images/banner/26.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/images/banner/3.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/images/banner/4.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/images/banner/5.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/images/banner/6.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
public/images/banner/7.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
public/images/banner/8.png
Normal file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
public/images/banner/9.png
Normal file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
public/images/banner/after.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
public/images/banner/banner-furniture1.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/images/banner/banner-furniture2.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/images/banner/banner-furniture3.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/images/banner/banner-shop-breadcrumb-img.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
public/images/banner/before.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
public/images/banner/bg-banner-organic1.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/images/banner/bg-banner-organic2.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/images/banner/bg-banner-organic3.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/images/banner/bg-banner-pet.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
public/images/banner/bg-banner-toys.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/banner/bg-banner-watch1.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/banner/bg-banner-watch2.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/banner/bg-banner-watch3.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/banner/bg-banner-yoga1.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
public/images/banner/bg-banner-yoga2.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
public/images/banner/bg-benefit-yoga.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
public/images/banner/bg-buy-pack-organic.png
Normal file
|
After Width: | Height: | Size: 178 KiB |
BIN
public/images/banner/bg-choose-us-pet.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
public/images/banner/bg-feature-pet1.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
public/images/banner/bg-flash-sale-furniture.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
public/images/banner/bg-flash-sale-organic.png
Normal file
|
After Width: | Height: | Size: 155 KiB |
BIN
public/images/banner/bg-flash-sale-yoga.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/images/banner/bg-pack-organic.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/banner/bg-testi-cos.png
Normal file
|
After Width: | Height: | Size: 727 KiB |
BIN
public/images/banner/community1.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
public/images/banner/community2.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
public/images/banner/community3.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
public/images/banner/community4.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
public/images/banner/flash-sale-cos2.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
public/images/banner/image-flash-sale-organic.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
public/images/banner/lookbook-jewelry1.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
public/images/banner/lookbook-jewelry2.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
public/images/banner/marketplace1.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
public/images/banner/marketplace2.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
public/images/banner/marketplace3.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
public/images/banner/marketplace4.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
public/images/banner/marketplace5.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
public/images/banner/popular-watch.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
public/images/banner/video-cos2.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/banner/video-cos3.png
Normal file
|
After Width: | Height: | Size: 189 KiB |
BIN
public/images/blog/1.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/2.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/3.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/4.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/blog/5.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/blog/6.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/images/blog/7.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/8.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/9.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/marketplace1.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/marketplace2.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/marketplace3.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/organic1.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/organic2.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/organic3.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
public/images/blog/toys1.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |