fix(refactor): исправление React Hooks warnings в отрефакторенных компонентах
- Исправлен missing dependency в useSupplyCart.ts - Исправлен missing dependency в useWildberriesProducts.ts - Добавлен useCallback для getProductTotalWithRecipe для стабильности - Оптимизированы зависимости в useMemo и useCallback хуках - Обновлена система правил для разделенных файлов rules-complete1/2 - Созда��а система проактивного мониторинга контекста - Добавлен детальный план безопасного рефакторинга больших компонентов 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -109,26 +109,29 @@ export function useSupplyCart({ selectedSupplier, allCounterparties, productReci
|
||||
}
|
||||
|
||||
// Функция расчета полной стоимости товара с рецептурой
|
||||
const getProductTotalWithRecipe = (productId: string, quantity: number) => {
|
||||
const product = selectedGoods.find((p) => p.id === productId)
|
||||
if (!product) return 0
|
||||
const getProductTotalWithRecipe = useCallback(
|
||||
(productId: string, quantity: number) => {
|
||||
const product = selectedGoods.find((p) => p.id === productId)
|
||||
if (!product) return 0
|
||||
|
||||
const baseTotal = product.price * quantity
|
||||
const recipe = productRecipes[productId]
|
||||
const baseTotal = product.price * quantity
|
||||
const recipe = productRecipes[productId]
|
||||
|
||||
if (!recipe) return baseTotal
|
||||
if (!recipe) return baseTotal
|
||||
|
||||
// Здесь будет логика расчета стоимости услуг и расходников
|
||||
// Пока возвращаем базовую стоимость
|
||||
return baseTotal
|
||||
}
|
||||
// Здесь будет логика расчета стоимости услуг и расходников
|
||||
// Пока возвращаем базовую стоимость
|
||||
return baseTotal
|
||||
},
|
||||
[selectedGoods, productRecipes],
|
||||
)
|
||||
|
||||
// Расчеты для корзины
|
||||
const totalGoodsAmount = useMemo(() => {
|
||||
return selectedGoods.reduce((sum, item) => {
|
||||
return sum + getProductTotalWithRecipe(item.id, item.selectedQuantity)
|
||||
}, 0)
|
||||
}, [selectedGoods, productRecipes])
|
||||
}, [selectedGoods, getProductTotalWithRecipe])
|
||||
|
||||
const totalQuantity = useMemo(() => {
|
||||
return selectedGoods.reduce((sum, item) => sum + item.selectedQuantity, 0)
|
||||
|
@ -292,7 +292,7 @@ export function useWildberriesProducts(): UseWildberriesProductsReturn {
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [searchTerm, user])
|
||||
}, [searchTerm, user, loadCards])
|
||||
|
||||
// Автозагрузка при инициализации
|
||||
useEffect(() => {
|
||||
|
Reference in New Issue
Block a user