ec27228a8e
Em dashes (—) and en dashes (–) had spread across comments, docs, tests, and a few UI strings, reading as AI-generated boilerplate rather than house style. Replaced each with punctuation matching its context: colon for explanatory clauses, comma for asides, plain hyphen for numeric/legal ranges (e.g. "21-23§"), "to"/"till" for date ranges, parentheses for paired-dash asides. messages/en.json and messages/sv.json were fixed by hand together to keep sv/en in sync. Left untouched where the dash is the functional subject rather than decorative punctuation: date-range-parser.ts's separator regex, charset-repair.ts's CP1252 byte-mapping table (and its test), the SIE encoding mojibake docs, generic-csv.ts's minus-sign normalizer, the agent system-prompt files that already instruct against em dashes, and a golden iXBRL test fixture compared byte-for-byte. Also fixes two bugs surfaced along the way: an off-by-one in ApiKeysPanel's scope-label split (a leftover from an earlier partial pass), and a charset-repair test that had lost the literal en-dash it exists to verify. Regenerated the agent atom seed migration (skills:generate) since 27 SKILL.md files changed. Added a CLAUDE.md rule against em/en dashes, with an explicit carve-out for the functional-dash cases above. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
71 lines
2.5 KiB
TypeScript
71 lines
2.5 KiB
TypeScript
'use client'
|
|
|
|
import { useTranslations } from 'next-intl'
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from '@/components/ui/dialog'
|
|
import JournalEntryForm, { type FormLine } from '@/components/bookkeeping/JournalEntryForm'
|
|
import type { JournalEntry, JournalEntryLine } from '@/types'
|
|
|
|
interface Props {
|
|
entry: JournalEntry
|
|
open: boolean
|
|
onOpenChange: (open: boolean) => void
|
|
/** Fired after the draft is successfully updated. */
|
|
onUpdated: () => void
|
|
}
|
|
|
|
/**
|
|
* Edit a DRAFT verifikat. Wraps JournalEntryForm in edit mode, pre-filled from
|
|
* the draft's header + lines; the form PATCHes the entry in place and it stays
|
|
* a draft (the user posts it separately). Only ever opened for status==='draft'
|
|
* entries: the engine + DB triggers reject edits on committed entries anyway.
|
|
*/
|
|
export default function EditDraftEntryDialog({ entry, open, onOpenChange, onUpdated }: Props) {
|
|
const t = useTranslations('bookkeeping')
|
|
|
|
const initialLines: FormLine[] = ((entry.lines || []) as JournalEntryLine[])
|
|
.slice()
|
|
.sort((a, b) => a.sort_order - b.sort_order)
|
|
.map((l) => ({
|
|
account_number: l.account_number,
|
|
debit_amount: Number(l.debit_amount) > 0 ? String(l.debit_amount) : '',
|
|
credit_amount: Number(l.credit_amount) > 0 ? String(l.credit_amount) : '',
|
|
line_description: l.line_description || '',
|
|
// Carry the line's dimensions into the form: the PATCH replaces all
|
|
// lines, so omitting this would silently strip existing tags.
|
|
dimensions:
|
|
l.dimensions && Object.keys(l.dimensions).length > 0 ? { ...l.dimensions } : undefined,
|
|
}))
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent
|
|
className="sm:max-w-3xl max-h-[95dvh] sm:max-h-[90vh] overflow-y-auto"
|
|
// Same guard as Ny verifikat: an accidental outside-click must not
|
|
// discard in-progress edits.
|
|
onPointerDownOutside={(e) => e.preventDefault()}
|
|
onInteractOutside={(e) => e.preventDefault()}
|
|
>
|
|
<DialogHeader>
|
|
<DialogTitle>{t('edit_draft_dialog_title')}</DialogTitle>
|
|
</DialogHeader>
|
|
<JournalEntryForm
|
|
key={entry.id}
|
|
bare
|
|
editEntryId={entry.id}
|
|
initialLines={initialLines}
|
|
initialDate={entry.entry_date}
|
|
initialDescription={entry.description}
|
|
initialNotes={entry.notes ?? undefined}
|
|
initialVoucherSeries={entry.voucher_series}
|
|
onUpdated={onUpdated}
|
|
/>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|