diff --git a/nuxt4/app/composables/useLotes.ts b/nuxt4/app/composables/useLotes.ts index fd2753e..3d2bcfd 100644 --- a/nuxt4/app/composables/useLotes.ts +++ b/nuxt4/app/composables/useLotes.ts @@ -31,7 +31,7 @@ export interface TrazabilidadRow { } export const useLotes = () => { - const toast = useToast() + const toast = import.meta.client ? useToast() : null // ===================================================== // FUNCIONES PARA LOTES @@ -67,7 +67,7 @@ export const useLotes = () => { return data.value?.data || [] } catch (err: any) { console.error('Error fetching lotes:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error obteniendo lotes', color: 'red', @@ -93,7 +93,7 @@ export const useLotes = () => { return data.value?.data || null } catch (err: any) { console.error('Error fetching lote:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error obteniendo lote', color: 'red', @@ -125,7 +125,7 @@ export const useLotes = () => { throw new Error(error.value.message || 'Error creando lote') } - toast.add({ + toast?.add({ title: 'Éxito', description: 'Lote creado correctamente', color: 'green', @@ -134,7 +134,7 @@ export const useLotes = () => { return data.value?.data || null } catch (err: any) { console.error('Error creating lote:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error creando lote', color: 'red', @@ -169,7 +169,7 @@ export const useLotes = () => { throw new Error(error.value.message || 'Error actualizando lote') } - toast.add({ + toast?.add({ title: 'Éxito', description: 'Lote actualizado correctamente', color: 'green', @@ -178,7 +178,7 @@ export const useLotes = () => { return data.value?.data || null } catch (err: any) { console.error('Error updating lote:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error actualizando lote', color: 'red', @@ -200,7 +200,7 @@ export const useLotes = () => { throw new Error(error.value.message || 'Error eliminando lote') } - toast.add({ + toast?.add({ title: 'Éxito', description: 'Lote eliminado correctamente', color: 'green', @@ -209,7 +209,7 @@ export const useLotes = () => { return true } catch (err: any) { console.error('Error deleting lote:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error eliminando lote', color: 'red', @@ -242,7 +242,7 @@ export const useLotes = () => { return data.value?.data || null } catch (err: any) { console.error('Error fetching trazabilidad:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error obteniendo trazabilidad', color: 'red', @@ -285,7 +285,7 @@ export const useLotes = () => { return data.value?.data || [] } catch (err: any) { console.error('Error fetching operaciones:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error obteniendo operaciones', color: 'red', @@ -326,7 +326,7 @@ export const useLotes = () => { throw new Error(error.value.message || 'Error creando operación') } - toast.add({ + toast?.add({ title: 'Éxito', description: 'Operación creada correctamente', color: 'green', @@ -335,7 +335,7 @@ export const useLotes = () => { return data.value?.data || null } catch (err: any) { console.error('Error creating operacion:', err) - toast.add({ + toast?.add({ title: 'Error', description: err.message || 'Error creando operación', color: 'red',