feat: dynamic units table with localized names via GET /units

- Add units + unit_translations tables with FK constraints on products and ingredient_mappings
- Normalize products.unit from Russian strings (г, кг) to English codes (g, kg)
- Load units at startup (in-memory registry) and serve via GET /units (language-aware)
- Replace hardcoded _units lists and _mapUnit() functions in Flutter with unitsProvider FutureProvider
- Re-fetches automatically when language changes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
dbastrikin
2026-03-15 16:15:33 +02:00
parent e1fbe7b1a2
commit 55d01400b0
13 changed files with 259 additions and 86 deletions

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/locale/unit_provider.dart';
import '../../shared/models/shopping_item.dart';
import 'menu_provider.dart';
@@ -191,14 +192,14 @@ class _ShoppingTile extends ConsumerWidget {
),
subtitle: item.inStock > 0
? Text(
'${item.inStock.toStringAsFixed(0)} ${item.unit} есть дома',
'${item.inStock.toStringAsFixed(0)} ${ref.watch(unitsProvider).valueOrNull?[item.unit] ?? item.unit} есть дома',
style: theme.textTheme.bodySmall?.copyWith(
color: Colors.green,
),
)
: null,
trailing: Text(
'$amountStr ${item.unit}',
'$amountStr ${ref.watch(unitsProvider).valueOrNull?[item.unit] ?? item.unit}',
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w600,
),