x
This commit is contained in:
1 parent
c449de2482
commit
7e4e89e33c
50 files changed
+306
-140
No files matched your search
@@ -136,7 +136,7 @@ export default function CategoryPage() {
|
||||
<span>/</span>
|
||||
<Link to="/shop" className="hover:text-white transition-colors">Shop</Link>
|
||||
<span>/</span>
|
||||
<span className="text-white">{typeof category?.name === 'string' ? category.name : (category?.name as any)?.[localStorage.getItem('homaroma_lang') || 'en'] || (category?.name as any)?.en || '...'}</span>
|
||||
<span className="text-white">{typeof category?.name === 'string' ? category.name : (category?.name as any)?.[localStorage.getItem('app_lang') || 'en'] || (category?.name as any)?.en || '...'}</span>
|
||||
</div>
|
||||
<h1 className="text-4xl md:text-5xl font-bold text-white">
|
||||
{loading ? (
|
||||
@@ -169,7 +169,7 @@ export default function CategoryPage() {
|
||||
: 'bg-white text-spa-stone border-spa-stone/20 hover:border-spa-forest hover:text-spa-forest shadow-sm'
|
||||
}`}
|
||||
>
|
||||
{typeof cat.name === 'string' ? cat.name : (cat.name as any)?.[localStorage.getItem('homaroma_lang') || 'en'] || (cat.name as any)?.en || ''}
|
||||
{typeof cat.name === 'string' ? cat.name : (cat.name as any)?.[localStorage.getItem('app_lang') || 'en'] || (cat.name as any)?.en || ''}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -127,7 +127,7 @@ export default function CheckoutPage() {
|
||||
.catch(console.error)
|
||||
|
||||
// Check if there's an active coupon saved in localStorage
|
||||
const savedCoupon = localStorage.getItem('homaroma_active_coupon')
|
||||
const savedCoupon = localStorage.getItem('app_active_coupon')
|
||||
if (savedCoupon) {
|
||||
setCouponCode(savedCoupon)
|
||||
// We will trigger handleApplyCoupon but we need to wait for items/subtotal to be ready.
|
||||
@@ -174,7 +174,7 @@ export default function CheckoutPage() {
|
||||
|
||||
// Auto-apply saved coupon if subtotal is ready
|
||||
useEffect(() => {
|
||||
const savedCoupon = localStorage.getItem('homaroma_active_coupon')
|
||||
const savedCoupon = localStorage.getItem('app_active_coupon')
|
||||
if (savedCoupon && subtotal > 0 && !appliedCoupon && !couponError && !couponLoading) {
|
||||
setCouponCode(savedCoupon)
|
||||
// trigger fetch to validate
|
||||
@@ -190,7 +190,7 @@ export default function CheckoutPage() {
|
||||
setDiscountAmount(data.discountAmount)
|
||||
setIsFreeShipping(data.isFreeShipping)
|
||||
} else {
|
||||
localStorage.removeItem('homaroma_active_coupon') // Remove invalid
|
||||
localStorage.removeItem('app_active_coupon') // Remove invalid
|
||||
}
|
||||
})
|
||||
.catch(console.error)
|
||||
@@ -254,7 +254,7 @@ export default function CheckoutPage() {
|
||||
setDiscountAmount(0)
|
||||
setIsFreeShipping(false)
|
||||
setCouponError('')
|
||||
localStorage.removeItem('homaroma_active_coupon')
|
||||
localStorage.removeItem('app_active_coupon')
|
||||
}
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
@@ -309,10 +309,10 @@ export default function CheckoutPage() {
|
||||
if (res.ok) {
|
||||
clearCart()
|
||||
|
||||
const existingStr = localStorage.getItem('homaroma_local_orders')
|
||||
const existingStr = localStorage.getItem('app_local_orders')
|
||||
const existing = existingStr ? JSON.parse(existingStr) : []
|
||||
if (!existing.includes(responseData.id)) {
|
||||
localStorage.setItem('homaroma_local_orders', JSON.stringify([responseData.id, ...existing]))
|
||||
localStorage.setItem('app_local_orders', JSON.stringify([responseData.id, ...existing]))
|
||||
}
|
||||
|
||||
navigate(`/order/${responseData.id}`)
|
||||
|
||||
@@ -82,7 +82,7 @@ export default function CouponsPage() {
|
||||
}
|
||||
|
||||
const handleUseNow = (code: string) => {
|
||||
localStorage.setItem('homaroma_active_coupon', code)
|
||||
localStorage.setItem('app_active_coupon', code)
|
||||
navigate('/shop')
|
||||
}
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ export default function OrderSuccessPage() {
|
||||
{order.items.map(item => (
|
||||
<div key={item.id} className="flex items-center gap-4 text-sm">
|
||||
<div className="w-12 h-12 rounded-lg bg-spa-stone/10 flex-shrink-0 overflow-hidden border border-spa-stone/10">
|
||||
<img src={item.productImage || `${import.meta.env.VITE_API_URL.replace('/api', '')}/assets/oil_ozone.png`} alt="Product" className="w-full h-full object-cover" />
|
||||
<img src={item.productImage || '/images/fallback-product.svg'} alt="Product" className="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="font-bold text-pop-black">{item.productName}</p>
|
||||
|
||||
@@ -504,7 +504,7 @@ export default function ProfilePage() {
|
||||
{order.items.map(item => (
|
||||
<div key={item.id} className="flex items-center gap-3 text-xs">
|
||||
<div className="w-10 h-10 rounded-md bg-spa-stone/10 overflow-hidden border border-spa-stone/15 flex-shrink-0">
|
||||
<img src={item.productImage || `${import.meta.env.VITE_API_URL.replace('/api', '')}/assets/oil_ozone.png`} alt="Product" className="w-full h-full object-cover" />
|
||||
<img src={item.productImage || '/images/fallback-product.svg'} alt="Product" className="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="font-bold text-pop-black truncate">{item.productName}</p>
|
||||
|
||||
@@ -32,7 +32,7 @@ export default function ShopPage() {
|
||||
const params = new URLSearchParams(location.search)
|
||||
const coupon = params.get('coupon')
|
||||
if (coupon) {
|
||||
localStorage.setItem('homaroma_active_coupon', coupon)
|
||||
localStorage.setItem('app_active_coupon', coupon)
|
||||
// Optionally clean URL
|
||||
window.history.replaceState({}, document.title, window.location.pathname)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export default function TrackOrderPage() {
|
||||
.finally(() => setHistoryLoading(false))
|
||||
} else {
|
||||
// Load local orders if not logged in
|
||||
const storedStr = localStorage.getItem('homaroma_local_orders')
|
||||
const storedStr = localStorage.getItem('app_local_orders')
|
||||
if (storedStr) {
|
||||
setLocalOrders(JSON.parse(storedStr))
|
||||
}
|
||||
@@ -92,7 +92,7 @@ export default function TrackOrderPage() {
|
||||
if (!localOrders.includes(data.orderId)) {
|
||||
const newOrders = [data.orderId, ...localOrders]
|
||||
setLocalOrders(newOrders)
|
||||
localStorage.setItem('homaroma_local_orders', JSON.stringify(newOrders))
|
||||
localStorage.setItem('app_local_orders', JSON.stringify(newOrders))
|
||||
}
|
||||
navigate(`/order/${data.orderId}`)
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user