refactor(ui): unify selects via SearchableSelect (session form + contracts)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-23 21:00:19 +03:30
co-authored by Claude Opus 4.8
parent c556f3a53d
commit 0bc1b4a2e9
2 changed files with 18 additions and 17 deletions
+8 -11
View File
@@ -159,17 +159,11 @@ export default function NewSessionPage() {
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12, marginBottom: 12 }}>
<div>
<label style={fieldLabel}>بیمه پایه</label>
<select className="input" value={baseId} onChange={e => applyBase(e.target.value)}>
<option value="">بدون بیمه پایه</option>
{baseOpts.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
</select>
<SearchableSelect options={baseOpts} value={baseId} onChange={v => applyBase(v ? String(v) : '')} placeholder="بدون بیمه پایه" isClearable />
</div>
<div>
<label style={fieldLabel}>بیمه تکمیلی</label>
<select className="input" value={suppId} onChange={e => applySupp(e.target.value)}>
<option value="">بدون بیمه تکمیلی</option>
{suppOpts.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
</select>
<SearchableSelect options={suppOpts} value={suppId} onChange={v => applySupp(v ? String(v) : '')} placeholder="بدون بیمه تکمیلی" isClearable />
</div>
</div>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 12 }}>
@@ -221,9 +215,12 @@ export default function NewSessionPage() {
<h3 style={sectionTitle}>پرداخت و یادداشت</h3>
<div style={{ marginBottom: 12 }}>
<label style={fieldLabel}>روش پرداخت</label>
<select className="input" {...form.register('payment_method')}>
{Object.entries(PAYMENT_LABELS).map(([v, l]) => <option key={v} value={v}>{l}</option>)}
</select>
<SearchableSelect
options={Object.entries(PAYMENT_LABELS).map(([v, l]) => ({ value: v, label: l }))}
value={form.watch('payment_method')}
onChange={v => form.setValue('payment_method', (v as FormData['payment_method']) || 'cash')}
placeholder="روش پرداخت"
/>
</div>
<div>
<label style={fieldLabel}>یادداشت</label>