fix: SearchableSelect matches value across string/number types
Insurance option values are strings (String(insurance_id)) while the patient profile prefill is a number, so strict === matching left بیمه پایه/تکمیلی showing the placeholder on load — the saved insurance was invisible and looked unsaved even though PATCH persisted it. Match with String(o.value) === String(value) so numeric prefills bind to string-valued options (and vice versa); null/'' still selects nothing. Verified live: selects now display the saved insurance after reload. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,8 +34,12 @@ export default function SearchableSelect({
|
||||
}: Props) {
|
||||
const darkMode = useUiStore((s) => s.darkMode);
|
||||
|
||||
// مقایسهٔ نرم (string↔number): مقدار پیشفرض ممکن است number باشد ولی value گزینه String
|
||||
// (مثلاً id بیمه). تطبیق سختگیرانه در این حالت گزینه را خالی نشان میداد.
|
||||
const selected = useMemo(
|
||||
() => options.find((o) => o.value === value) ?? null,
|
||||
() => (value == null || value === ''
|
||||
? null
|
||||
: options.find((o) => String(o.value) === String(value)) ?? null),
|
||||
[options, value],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user