From defa0db0239e266c8b5fef654582ab4aeaa12296 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Wed, 15 Jul 2026 14:09:49 +0330 Subject: [PATCH] feat: group thousands in inventory item price input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show the قیمت (تومان) field with thousand separators as the user types (e.g. 1200000 → 1,200,000). Stored value stays digit-only, so the Toman→Rial conversion on submit is unaffected. Co-Authored-By: Claude Opus 4.8 --- assets/admin/components/inventory/AddItemModal.tsx | 4 +++- assets/admin/pages/InventoryPage.test.tsx | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/admin/components/inventory/AddItemModal.tsx b/assets/admin/components/inventory/AddItemModal.tsx index cb0a591e..a707ffcc 100644 --- a/assets/admin/components/inventory/AddItemModal.tsx +++ b/assets/admin/components/inventory/AddItemModal.tsx @@ -23,6 +23,8 @@ interface FormState { const BLANK: FormState = { name: '', consumable: '', unit: '', price: '', stock: '', alertThreshold: '' }; const digits = (v: string) => toEnglishDigits(v).replace(/\D/g, ''); +// group thousands: "1200000" → "1,200,000" +const group = (v: string) => v.replace(/\B(?=(\d{3})+(?!\d))/g, ','); /** «افزودن/ویرایش کالای جدید» — mirrors tauri ModalAddInventory field-for-field. */ export default function AddItemModal({ open, editing, saving, onClose, onSave }: Props) { @@ -79,7 +81,7 @@ export default function AddItemModal({ open, editing, saving, onClose, onSave }:
{ expect(await screen.findByText('افزودن کالای جدید')).toBeInTheDocument(); // the source's distinctive "هشدار اتمام" field is present expect(screen.getByText('هشدار اتمام')).toBeInTheDocument(); + + // price input groups thousands as the user types + const price = screen.getByPlaceholderText('قیمت') as HTMLInputElement; + fireEvent.change(price, { target: { value: '1200000' } }); + expect(price.value).toBe('1,200,000'); }); it('switches to the packages tab and lists a package with its price', async () => {