Skip to content

Commit a255aee

Browse files
authored
fix: bug with formatting numbers instead of dates (#1047)
* fix: bug with formatting numbers instead of dates
1 parent 8f9cd6a commit a255aee

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

backoffice/src/utils/writingStyle.test.tsx

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import {
88
Placeholders,
99
titleCase,
1010
formatForClipboardWithNotes,
11+
parseNotesData,
1112
} from "./writingStyle";
12-
import { INote } from "../entities/INote";
13+
import { INote, NoteType } from "../entities/INote";
1314
import { formatDateTime } from "./dateTime";
1415

1516
describe("titleCase()", () => {
@@ -367,4 +368,49 @@ describe("formatForClipboard", () => {
367368
"Versioning: 0\n",
368369
);
369370
});
371+
372+
it("export notes is in the correct format", () => {
373+
const notes: INote[] = [
374+
{
375+
id: "id",
376+
beaconId: "beaconId",
377+
text: "Label Generated",
378+
type: NoteType.RECORD_HISTORY,
379+
createdDate: "2020-02-06T00:00:00Z",
380+
userId: "userId",
381+
fullName: "SYSTEM",
382+
email: "",
383+
},
384+
{
385+
id: "id",
386+
beaconId: "beaconId",
387+
text: "Beacon MMSI coded, assuming COSPAS SARSAT Type Approval 1351. Generate labels",
388+
type: NoteType.GENERAL,
389+
createdDate: "2026-02-06T00:00:00Z",
390+
userId: "userId",
391+
fullName: "Full Name",
392+
email: "example@emailaddress.com",
393+
},
394+
];
395+
396+
expect(formatForClipboard(parseNotesData(notes))).toEqual(
397+
"\n" +
398+
"=====NOTES=====\n" +
399+
"\n" +
400+
"-----NOTES (1)-----\n" +
401+
"Type Of Note: RECORD_HISTORY\n" +
402+
"Note: Label Generated\n" +
403+
"Noted By: SYSTEM\n" +
404+
"Noted By Email Address: N/A\n" +
405+
"Date: 06/02/2020\n" +
406+
",\n" +
407+
"-----NOTES (2)-----\n" +
408+
"Type Of Note: GENERAL\n" +
409+
"Note: Beacon MMSI coded, assuming COSPAS SARSAT Type Approval 1351. Generate labels\n" +
410+
"Noted By: Full Name\n" +
411+
"Noted By Email Address: example@emailaddress.com\n" +
412+
"Date: 06/02/2026" +
413+
"\n",
414+
);
415+
});
370416
});

backoffice/src/utils/writingStyle.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FieldValueTypes } from "../components/dataPanel/FieldValue";
55
import { IEmergencyContact } from "../entities/IEmergencyContact";
66
import { IOwner } from "../entities/IOwner";
77
import { Activities, IUse } from "../entities/IUse";
8+
import { formatDateTime } from "./dateTime";
89

910
export enum WritingStyle {
1011
KeyValueSeparator = ":",
@@ -116,7 +117,7 @@ export function parseNotesData(notes: INote[]): Record<string, any> {
116117
note: note.text,
117118
notedBy: note.fullName,
118119
notedByEmailAddress: note.email,
119-
date: note.createdDate,
120+
date: formatDateTime(note.createdDate),
120121
})),
121122
};
122123
}

0 commit comments

Comments
 (0)