+ )
+}
diff --git a/app/store/components/product-management/sections/ai-generate-button.tsx b/app/store/components/product-management/product-sections/ai-generate-button.tsx
similarity index 98%
rename from app/store/components/product-management/sections/ai-generate-button.tsx
rename to app/store/components/product-management/product-sections/ai-generate-button.tsx
index 2d170881..6e0ea44a 100644
--- a/app/store/components/product-management/sections/ai-generate-button.tsx
+++ b/app/store/components/product-management/product-sections/ai-generate-button.tsx
@@ -5,7 +5,7 @@ import { motion } from 'framer-motion'
import { Sparkles } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
-import { TextShimmer } from '@/app/store/components/product-management/sections/text-shimmer'
+import { TextShimmer } from '@/app/store/components/product-management/product-sections/text-shimmer'
interface AIGenerateButtonProps {
onClick: () => Promise
diff --git a/app/store/components/product-management/sections/attributes-section.tsx b/app/store/components/product-management/product-sections/attributes-section.tsx
similarity index 100%
rename from app/store/components/product-management/sections/attributes-section.tsx
rename to app/store/components/product-management/product-sections/attributes-section.tsx
diff --git a/app/store/components/product-management/sections/basic-info-section.tsx b/app/store/components/product-management/product-sections/basic-info-section.tsx
similarity index 99%
rename from app/store/components/product-management/sections/basic-info-section.tsx
rename to app/store/components/product-management/product-sections/basic-info-section.tsx
index 27a3c3c0..ad9a6b18 100644
--- a/app/store/components/product-management/sections/basic-info-section.tsx
+++ b/app/store/components/product-management/product-sections/basic-info-section.tsx
@@ -28,7 +28,7 @@ import { toast } from 'sonner'
import type { ProductFormValues } from '@/lib/zod-schemas/product-schema'
import { useProductDescription } from '@/app/store/components/product-management/hooks/useProductDescription'
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
-import { AIGenerateButton } from '@/app/store/components/product-management/sections/ai-generate-button'
+import { AIGenerateButton } from '@/app/store/components/product-management/product-sections/ai-generate-button'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
interface BasicInfoSectionProps {
diff --git a/app/store/components/product-management/sections/images-section.tsx b/app/store/components/product-management/product-sections/images-section.tsx
similarity index 100%
rename from app/store/components/product-management/sections/images-section.tsx
rename to app/store/components/product-management/product-sections/images-section.tsx
diff --git a/app/store/components/product-management/sections/price-suggestion-panel.tsx b/app/store/components/product-management/product-sections/price-suggestion-panel.tsx
similarity index 98%
rename from app/store/components/product-management/sections/price-suggestion-panel.tsx
rename to app/store/components/product-management/product-sections/price-suggestion-panel.tsx
index 3e366b63..a4e6b8a8 100644
--- a/app/store/components/product-management/sections/price-suggestion-panel.tsx
+++ b/app/store/components/product-management/product-sections/price-suggestion-panel.tsx
@@ -1,6 +1,6 @@
import { HelpCircle } from 'lucide-react'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
-import { AIGenerateButton } from '../sections/ai-generate-button'
+import { AIGenerateButton } from './ai-generate-button'
import type { PriceSuggestionResult } from '../hooks/usePriceSuggestion'
import type { UseFormReturn } from 'react-hook-form'
import type { ProductFormValues } from '@/lib/zod-schemas/product-schema'
diff --git a/app/store/components/product-management/sections/pricing-inventory-section.tsx b/app/store/components/product-management/product-sections/pricing-inventory-section.tsx
similarity index 96%
rename from app/store/components/product-management/sections/pricing-inventory-section.tsx
rename to app/store/components/product-management/product-sections/pricing-inventory-section.tsx
index a669599a..5dda701b 100644
--- a/app/store/components/product-management/sections/pricing-inventory-section.tsx
+++ b/app/store/components/product-management/product-sections/pricing-inventory-section.tsx
@@ -16,7 +16,7 @@ import {
usePriceSuggestion,
type PriceSuggestionResult,
} from '@/app/store/components/product-management/hooks/usePriceSuggestion'
-import { PriceSuggestionPanel } from '@/app/store/components/product-management/sections/price-suggestion-panel'
+import { PriceSuggestionPanel } from '@/app/store/components/product-management/product-sections/price-suggestion-panel'
import { cn } from '@/lib/utils'
import CurrencyInput from 'react-currency-input-field'
@@ -60,8 +60,8 @@ export function PricingInventorySection({ form }: PricingInventorySectionProps)
setLocalPriceResult(parsedResult)
} catch (parseError) {
- console.error('Error al parsear el resultado:', parseError)
- throw new Error('El formato de respuesta es inválido')
+ console.error('Error parsing result:', parseError)
+ throw new Error('The response format is invalid')
}
} else {
parsedResult = rawResult
@@ -88,10 +88,10 @@ export function PricingInventorySection({ form }: PricingInventorySectionProps)
}
}
} else {
- console.warn('No se recibió un resultado válido de la API')
+ console.warn('No valid result was received from the API')
}
} catch (error) {
- console.error('Error al generar sugerencia de precio:', error)
+ console.error('Error generating price suggestion:', error)
toast.error('Error', {
description: 'No se pudo generar la sugerencia de precio. Inténtelo de nuevo más tarde.',
})
diff --git a/app/store/components/product-management/sections/pricing-section.tsx b/app/store/components/product-management/product-sections/pricing-section.tsx
similarity index 100%
rename from app/store/components/product-management/sections/pricing-section.tsx
rename to app/store/components/product-management/product-sections/pricing-section.tsx
diff --git a/app/store/components/product-management/sections/publication-section.tsx b/app/store/components/product-management/product-sections/publication-section.tsx
similarity index 100%
rename from app/store/components/product-management/sections/publication-section.tsx
rename to app/store/components/product-management/product-sections/publication-section.tsx
diff --git a/app/store/components/product-management/sections/text-shimmer.tsx b/app/store/components/product-management/product-sections/text-shimmer.tsx
similarity index 100%
rename from app/store/components/product-management/sections/text-shimmer.tsx
rename to app/store/components/product-management/product-sections/text-shimmer.tsx
diff --git a/app/store/components/product-management/product-table/product-pagination.tsx b/app/store/components/product-management/product-table/product-pagination.tsx
index cb3af62b..752b5124 100644
--- a/app/store/components/product-management/product-table/product-pagination.tsx
+++ b/app/store/components/product-management/product-table/product-pagination.tsx
@@ -47,7 +47,6 @@ export function ProductPagination({
51020
- 50
diff --git a/app/store/components/product-management/product-table/product-table-desktop.tsx b/app/store/components/product-management/product-table/product-table-desktop.tsx
index 03213b57..dc9a24ce 100644
--- a/app/store/components/product-management/product-table/product-table-desktop.tsx
+++ b/app/store/components/product-management/product-table/product-table-desktop.tsx
@@ -16,6 +16,10 @@ import type {
SortField,
VisibleColumns,
} from '@/app/store/components/product-management/types/product-types'
+import { getStoreId } from '@/utils/store-utils'
+import { useParams, usePathname } from 'next/navigation'
+import { routes } from '@/utils/routes'
+import Link from 'next/link'
interface ProductTableDesktopProps {
products: IProduct[]
@@ -40,6 +44,10 @@ export function ProductTableDesktop({
toggleSort,
renderSortIndicator,
}: ProductTableDesktopProps) {
+ const pathname = usePathname()
+ const params = useParams()
+ const storeId = getStoreId(params, pathname)
+
return (
@@ -135,7 +143,11 @@ export function ProductTableDesktop({
)}
- {product.name}
+
+
+
{visibleColumns.status && (
diff --git a/app/store/components/product-management/utils/collection-form-utils.ts b/app/store/components/product-management/utils/collection-form-utils.ts
index 5933914e..9585dfb5 100644
--- a/app/store/components/product-management/utils/collection-form-utils.ts
+++ b/app/store/components/product-management/utils/collection-form-utils.ts
@@ -285,7 +285,7 @@ export const useCollectionForm = ({
router.push(routes.store.collections(storeId))
// No desactivamos isSubmitting para mantener el botón deshabilitado hasta la redirección
} catch (error) {
- console.error('Error al eliminar la colección:', error)
+ console.error('Error deleting collection:', error)
toast.error('Ocurrió un error al eliminar la colección')
setIsSubmitting(false) // Solo desactivamos en caso de error
}
@@ -323,7 +323,7 @@ export const useCollectionForm = ({
isSubmitting,
hasUnsavedChanges,
selectedProducts,
- isDataLoaded, // Add this to the returned object
+ isDataLoaded,
// Acciones
setTitle,
diff --git a/app/store/components/product-management/utils/exportUtils.ts b/app/store/components/product-management/utils/exportUtils.ts
index 26473e74..12a279ab 100644
--- a/app/store/components/product-management/utils/exportUtils.ts
+++ b/app/store/components/product-management/utils/exportUtils.ts
@@ -8,7 +8,7 @@ import { IProduct } from '@/app/store/hooks/useProducts'
*/
export const exportProductsToCSV = (products: IProduct[], fileName: string): boolean => {
if (!products || products.length === 0) {
- console.error('No hay productos para exportar')
+ console.error('There are no products to export')
return false
}
@@ -126,7 +126,7 @@ export const exportProductsToCSV = (products: IProduct[], fileName: string): boo
return true
} catch (error) {
- console.error('Error al exportar productos a CSV:', error)
+ console.error('Error exporting products to CSV:', error)
return false
}
}
diff --git a/app/store/components/product-management/utils/productUtils.ts b/app/store/components/product-management/utils/productUtils.ts
index 40239cb6..1cd93169 100644
--- a/app/store/components/product-management/utils/productUtils.ts
+++ b/app/store/components/product-management/utils/productUtils.ts
@@ -123,7 +123,7 @@ export async function handleProductCreate(
return result
}
- throw new Error('No se pudo crear el producto')
+ throw new Error('The product could not be created')
} catch (error) {
console.error('Error in handleProductCreate:', error)
toast.error('Error', {
diff --git a/app/store/components/sidebar/app-sidebar.tsx b/app/store/components/sidebar/app-sidebar.tsx
index c6621188..90a1d393 100644
--- a/app/store/components/sidebar/app-sidebar.tsx
+++ b/app/store/components/sidebar/app-sidebar.tsx
@@ -55,11 +55,11 @@ export function AppSidebar({ ...props }: React.ComponentProps) {
items: [
{
title: 'Colecciones',
- url: routes.store.collections(storeId),
+ url: routes.store.products.collections(storeId),
},
{
title: 'Inventario',
- url: routes.store.inventory(storeId),
+ url: routes.store.products.inventory(storeId),
},
{
title: 'Categorías',
diff --git a/app/store/components/sidebar/nav-main.tsx b/app/store/components/sidebar/nav-main.tsx
index 5643ab8e..8d4f1795 100644
--- a/app/store/components/sidebar/nav-main.tsx
+++ b/app/store/components/sidebar/nav-main.tsx
@@ -1,3 +1,5 @@
+'use client'
+
import { ChevronRight, type LucideIcon } from 'lucide-react'
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
import {
@@ -6,13 +8,12 @@ import {
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
- SidebarMenuSub,
- SidebarMenuSubButton,
- SidebarMenuSubItem,
+ useSidebar,
} from '@/components/ui/sidebar'
import Link from 'next/link'
import { useState, useEffect } from 'react'
import { usePathname } from 'next/navigation'
+import { Skeleton } from '@/components/ui/skeleton'
import useStoreDataStore from '@/context/core/storeDataStore'
interface NavMainProps {
@@ -32,8 +33,10 @@ interface NavMainProps {
export function NavMain({ items }: NavMainProps) {
const pathname = usePathname()
- const { currentStore, isLoading, clearStore } = useStoreDataStore()
+ const { currentStore, isLoading } = useStoreDataStore()
const [openItem, setOpenItem] = useState(null)
+ const { state } = useSidebar()
+ const isExpanded = state === 'expanded'
useEffect(() => {
const activeItem = items.find(item => {
@@ -54,53 +57,81 @@ export function NavMain({ items }: NavMainProps) {
return (
- Mi tienda - {isLoading ? 'Cargando...' : currentStore?.storeName}
+ {isLoading ? : <> {currentStore?.storeName}>}
- {items.map(item => (
- {
- if (isOpen) {
- setOpenItem(item.title)
- } else if (openItem === item.title) {
- setOpenItem(null)
- }
- }}
- className="group/collapsible"
- >
-
-
- handleItemClick(item.title)}>
- {item.icon && }
- {item.url ? (
- {}}>
+ {items.map(item => {
+ // Check if this item is active based on the current path
+ const isItemActive = item.url && pathname.startsWith(item.url)
+ const hasActiveChild = item.items?.some(subItem => pathname === subItem.url)
+
+ return (
+ {
+ if (isOpen) {
+ setOpenItem(item.title)
+ } else if (openItem === item.title) {
+ setOpenItem(null)
+ }
+ }}
+ className="group/collapsible"
+ >
+
+
+ handleItemClick(item.title)}
+ isActive={isItemActive || hasActiveChild}
+ >
+ {item.icon && }
+ {item.url ? (
+ {}}>
+ {item.title}
+
+ ) : (
{item.title}
-
- ) : (
- {item.title}
- )}
-
-
-
-
-
- {item.items?.map(subItem => (
-
-
-
- {subItem.title}
-
-
-
- ))}
-
-
-
-
- ))}
+ )}
+ {isExpanded && (
+
+ )}
+
+
+ {isExpanded && (
+
+ {/* Custom styled submenu with line indicators */}
+
+ {item.items?.map(subItem => {
+ // Check if this sub-item is active based on the exact path match
+ const isSubItemActive = pathname === subItem.url
+
+ return (
+