Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/EditContactDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,16 @@ export default function EditContactDialog({ contact, isOpen, onClose, onSave, on
body: JSON.stringify({
...formData,
datetime: formData.datetime ? new Date(formData.datetime).toISOString() : undefined,
// Blank power clears the field (null), not an empty string a numeric
// column would reject.
// Blank/absent power clears the field (null), not an empty string a
// numeric column would reject. `== null` catches both a cleared input
// (undefined/'') and a contact loaded with no power (JSON null) — the
// latter must stay null, not become Number(null) === 0, which would
// otherwise overwrite NULL with 0 and defeat the export's
// COALESCE(c.tx_pwr, s.power_watts) station-power fallback.
tx_pwr:
formData.tx_pwr === undefined || (formData.tx_pwr as unknown) === ''
formData.tx_pwr == null ||
(formData.tx_pwr as unknown) === '' ||
Number.isNaN(Number(formData.tx_pwr))
? null
: Number(formData.tx_pwr),
}),
Expand Down
Loading