diff --git a/backend/alembic/versions/005_capitalize_product_names.py b/backend/alembic/versions/005_capitalize_product_names.py new file mode 100644 index 0000000..d2ee7ba --- /dev/null +++ b/backend/alembic/versions/005_capitalize_product_names.py @@ -0,0 +1,34 @@ +"""005 - capitaliser la première lettre des noms produits et articles libres + +Revision ID: 005 +Revises: 004 +Create Date: 2026-05-25 +""" + +from alembic import op + +revision = '005' +down_revision = '004' +branch_labels = None +depends_on = None + + +def upgrade(): + op.execute(""" + UPDATE shopping.products + SET name = UPPER(SUBSTRING(name, 1, 1)) || SUBSTRING(name, 2) + WHERE name IS NOT NULL + AND name != '' + AND UPPER(SUBSTRING(name, 1, 1)) || SUBSTRING(name, 2) != name + """) + op.execute(""" + UPDATE shopping.list_items + SET custom_name = UPPER(SUBSTRING(custom_name, 1, 1)) || SUBSTRING(custom_name, 2) + WHERE custom_name IS NOT NULL + AND custom_name != '' + AND UPPER(SUBSTRING(custom_name, 1, 1)) || SUBSTRING(custom_name, 2) != custom_name + """) + + +def downgrade(): + pass diff --git a/frontend/src/components/shopping/CatalogueModal.tsx b/frontend/src/components/shopping/CatalogueModal.tsx index a118766..8131383 100644 --- a/frontend/src/components/shopping/CatalogueModal.tsx +++ b/frontend/src/components/shopping/CatalogueModal.tsx @@ -85,9 +85,14 @@ export default function CatalogueModal({ stores, onClose }: CatalogueModalProps) setError(null) } + function capitalize(s: string): string { + const t = s.trim() + return t.charAt(0).toUpperCase() + t.slice(1) + } + function cleanForm(f: ProductCreate): ProductCreate { return { - name: f.name.trim(), + name: capitalize(f.name), brand: f.brand?.trim() || undefined, category: f.category?.trim() || undefined, description: f.description?.trim() || undefined,