|
@@ -1,4 +1,4 @@
|
|
|
-import { useState } from "react"
|
|
|
|
|
|
|
+import { useState, useCallback } from "react"
|
|
|
import type { InfoTributaria, InfoFactura, DetalleItem } from "@/types/factura"
|
|
import type { InfoTributaria, InfoFactura, DetalleItem } from "@/types/factura"
|
|
|
|
|
|
|
|
export function useFacturaState() {
|
|
export function useFacturaState() {
|
|
@@ -95,6 +95,11 @@ export function useFacturaState() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Función estable para actualizar infoFactura
|
|
|
|
|
+ const updateInfoFactura = useCallback((data: Partial<{totalSinImpuestos: string, totalDescuento: string, importeTotal: string}>) => {
|
|
|
|
|
+ setInfoFactura(prev => ({ ...prev, ...data }))
|
|
|
|
|
+ }, [])
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
infoTributaria,
|
|
infoTributaria,
|
|
|
infoFactura,
|
|
infoFactura,
|
|
@@ -106,8 +111,6 @@ export function useFacturaState() {
|
|
|
agregarDetalle,
|
|
agregarDetalle,
|
|
|
actualizarDetalle,
|
|
actualizarDetalle,
|
|
|
eliminarDetalle,
|
|
eliminarDetalle,
|
|
|
- updateInfoFactura: (data: Partial<{totalSinImpuestos: string, totalDescuento: string, importeTotal: string}>) => {
|
|
|
|
|
- setInfoFactura(prev => ({ ...prev, ...data }))
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ updateInfoFactura
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|