Skip to content

Commit 5dc4d62

Browse files
committed
export update
1 parent 3976cc7 commit 5dc4d62

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

src/components/ExportDailyBriefingDialog.tsx

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ export function ExportDailyBriefingDialog({ open, onOpenChange }: ExportDialogPr
205205
return 0;
206206
});
207207

208+
// Group entries by region and sort regions alphabetically
209+
const entriesByRegion = sortedEntries.reduce((acc, entry) => {
210+
if (!acc[entry.region]) {
211+
acc[entry.region] = [];
212+
}
213+
acc[entry.region].push(entry);
214+
return acc;
215+
}, {} as Record<string, typeof sortedEntries>);
216+
217+
const sortedRegions = Object.keys(entriesByRegion).sort();
218+
208219
// Build document children
209220
const children: any[] = [
210221
// Title
@@ -239,53 +250,54 @@ export function ExportDailyBriefingDialog({ open, onOpenChange }: ExportDialogPr
239250
],
240251
}),
241252
// Summary count
242-
new Paragraph({
243-
children: [
244-
new TextRun({
245-
text: `Total Entries: ${entriesForDate.length}`,
246-
bold: true,
247-
font: 'Roboto',
248-
}),
249-
],
250-
spacing: { after: 400 },
251-
}),
253+
252254
// Separator
253255
createSeparator(),
254256
];
255257

256-
// Add entries
257-
sortedEntries.forEach((entry, index) => {
258-
// Entry number and region/country
258+
// Add entries grouped by region
259+
sortedRegions.forEach((region) => {
260+
// Add region header
259261
children.push(
260262
new Paragraph({
263+
heading: HeadingLevel.HEADING_2,
264+
alignment: AlignmentType.CENTER,
265+
spacing: { before: 300, after: 200 },
261266
children: [
262267
new TextRun({
263-
text: `${index + 1}. `,
264-
bold: true,
265-
size: 24,
266-
font: 'Roboto',
267-
}),
268-
new TextRun({
269-
text: `${entry.region} - ${entry.country}`,
268+
text: region,
270269
bold: true,
271270
size: 24,
272271
font: 'Roboto',
273272
}),
274273
],
275-
spacing: { before: 300, after: 100 },
276274
})
277275
);
278276

279-
// Priority badge
277+
// Add entries for this region
278+
entriesByRegion[region].forEach((entry) => {
279+
// Country
280+
children.push(
281+
new Paragraph({
282+
children: [
283+
new TextRun({
284+
text: `${entry.country}`,
285+
bold: true,
286+
size: 24,
287+
font: 'Roboto',
288+
}),
289+
],
290+
spacing: { before: 300, after: 100 },
291+
})
292+
);
280293
children.push(
281294
new Paragraph({
282295
children: [
283296
new TextRun({
284297
text: entry.priority === 'sg-attention'
285298
? 'SG Attention'
286299
: 'Situational Awareness',
287-
bold: true,
288-
color: entry.priority === 'sg-attention' ? 'DC2626' : '2563EB',
300+
italics: true,
289301
font: 'Roboto',
290302
}),
291303
new TextRun({
@@ -347,7 +359,6 @@ export function ExportDailyBriefingDialog({ open, onOpenChange }: ExportDialogPr
347359
new TextRun({
348360
text: entry.sourceUrl,
349361
italics: true,
350-
color: '0000FF',
351362
font: 'Roboto',
352363
}),
353364
],
@@ -378,6 +389,7 @@ export function ExportDailyBriefingDialog({ open, onOpenChange }: ExportDialogPr
378389

379390
// Separator between entries
380391
children.push(createSeparator());
392+
});
381393
});
382394

383395
// Footer
@@ -387,7 +399,7 @@ export function ExportDailyBriefingDialog({ open, onOpenChange }: ExportDialogPr
387399
spacing: { before: 400 },
388400
children: [
389401
new TextRun({
390-
text: `Generated on ${new Date().toLocaleString('en-US')}`,
402+
text: `Morning Briefing of the ${new Date().toLocaleString('en-US')}`,
391403
italics: true,
392404
font: 'Roboto',
393405
}),

0 commit comments

Comments
 (0)