Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ flowchart LR
- `components/*` implements pages and shared UI.
- `components/reports/*` contains the branded session PDF document used by the dashboard export flow.
- Navigation is app-state driven rather than router-driven.
- `@react-pdf/renderer` documents are the styling exception: those files use `StyleSheet.create()` and PDF-specific inline layout values because the PDF renderer does not support the app's Tailwind/PostCSS runtime classes.

### 2. Hook Layer

Expand Down
18 changes: 17 additions & 1 deletion components/SessionReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { PDFDownloadLink } from '@react-pdf/renderer';

import Modal from './Modal';
import SessionReportDocument from './reports/SessionReportDocument';
import {
MEMBER_DETAIL_CONTINUED_ROWS,
MEMBER_DETAIL_FIRST_PAGE_ROWS,
} from './reports/reportConstants';
import { buildSessionReportData, getSectionDateRange } from '../services/reporting/sessionReport';
import type { Boy, Section } from '../types';

Expand Down Expand Up @@ -60,7 +64,19 @@ const SessionReportModal: React.FC<SessionReportModalProps> = ({
const sectionLabel = activeSection === 'company' ? 'Company Section' : 'Junior Section';
const filename = `${activeSection}-session-report-${startDate || 'start'}-to-${endDate || 'end'}.pdf`;
const estimatedPageCount = report
? 1 + 1 + 1 + Math.max(1, Math.ceil(report.meetings.length / 18)) + 1 + Math.max(1, Math.ceil(report.members.length / (activeSection === 'junior' ? 14 : 16))) + report.members.reduce((sum, member) => sum + 1 + Math.ceil(Math.max(member.meetings.length - 14, 0) / 22), 0)
? 1
+ 1
+ 1
+ Math.max(1, Math.ceil(report.meetings.length / 18))
+ 1
+ (report.members.length === 0
? 0
: Math.max(1, Math.ceil(report.members.length / (activeSection === 'junior' ? 14 : 16))))
+ report.members.reduce(
(sum, member) =>
sum + 1 + Math.ceil(Math.max(member.meetings.length - MEMBER_DETAIL_FIRST_PAGE_ROWS, 0) / MEMBER_DETAIL_CONTINUED_ROWS),
0,
)
: 0;

return (
Expand Down
54 changes: 46 additions & 8 deletions components/reports/SessionReportDocument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import bbLogo from '../../assets/branding/bb-logo.png';
import bbBackground from '../../assets/branding/bb-background.jpg';
import companyLogo from '../../assets/branding/company-logo.png';
import juniorLogo from '../../assets/branding/junior-logo.png';
import {
MEMBER_DETAIL_CONTINUED_ROWS,
MEMBER_DETAIL_FIRST_PAGE_ROWS,
} from './reportConstants';

const BB_LOGO_URL = bbLogo;
const BB_BACKGROUND_URL = bbBackground;
Expand Down Expand Up @@ -53,15 +57,40 @@ const styles = StyleSheet.create({
},
coverPhotoCard: {
width: '34%',
height: 228,
backgroundColor: '#18233f',
borderRadius: 18,
overflow: 'hidden',
border: '1 solid #314469',
position: 'relative',
justifyContent: 'center',
alignItems: 'center',
},
coverPhoto: {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: 228,
height: '100%',
objectFit: 'cover',
opacity: 0.32,
},
coverPhotoInner: {
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 18,
},
coverPhotoLogo: {
width: 96,
height: 96,
objectFit: 'contain',
marginBottom: 10,
},
coverPhotoLabel: {
color: '#dbe7ff',
fontSize: 10,
textAlign: 'center',
lineHeight: 1.4,
},
coverMainLogo: {
width: 120,
Expand Down Expand Up @@ -229,8 +258,8 @@ const styles = StyleSheet.create({
backgroundColor: '#ffffff',
border: '1 solid #e2e8f0',
borderRadius: 10,
padding: 14,
marginBottom: 14,
padding: 12,
marginBottom: 12,
},
memberTableSection: {
marginTop: 6,
Expand All @@ -246,7 +275,7 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'space-between',
borderBottom: '1 solid #f1f5f9',
paddingVertical: 5,
paddingVertical: 4,
},
keyLabel: {
fontSize: 9,
Expand Down Expand Up @@ -327,9 +356,9 @@ const styles = StyleSheet.create({
backgroundColor: '#f8fafc',
},
tableCell: {
paddingVertical: 7,
paddingVertical: 5,
paddingHorizontal: 8,
fontSize: 8.5,
fontSize: 8,
color: '#0f172a',
},
tableHeadCell: {
Expand Down Expand Up @@ -587,6 +616,12 @@ const SessionReportDocument: React.FC<SessionReportDocumentProps> = ({ report })
</View>
<View style={styles.coverPhotoCard}>
<Image src={BB_BACKGROUND_URL} style={styles.coverPhoto} />
<View style={styles.coverPhotoInner}>
<Image src={accent.sectionLogo} style={styles.coverPhotoLogo} />
<Text style={styles.coverPhotoLabel}>
End-of-session attendance, marks, and member performance for the selected section.
</Text>
</View>
</View>
</View>
<View>
Expand Down Expand Up @@ -773,7 +808,10 @@ const SessionReportDocument: React.FC<SessionReportDocumentProps> = ({ report })
))}

{report.members.flatMap((member) => {
const continuationChunks = chunk<MemberMeetingRecord>(member.meetings.slice(14), 22);
const continuationChunks = chunk<MemberMeetingRecord>(
member.meetings.slice(MEMBER_DETAIL_FIRST_PAGE_ROWS),
MEMBER_DETAIL_CONTINUED_ROWS,
);

return [
<Page key={member.id} size="A4" style={styles.page}>
Expand Down Expand Up @@ -868,7 +906,7 @@ const SessionReportDocument: React.FC<SessionReportDocumentProps> = ({ report })
<Text style={[styles.tableCell, styles.tableHeadCell, { width: '25%' }]}>Behaviour</Text>
)}
</View>
{member.meetings.slice(0, 14).map((meeting, index) => (
{member.meetings.slice(0, MEMBER_DETAIL_FIRST_PAGE_ROWS).map((meeting, index) => (
<View key={meeting.date} style={[styles.tableRow, index % 2 === 1 ? styles.tableRowAlt : null]}>
<Text style={[styles.tableCell, { width: '22%' }]}>{formatDate(meeting.date)}</Text>
<Text style={[styles.tableCell, { width: '14%' }]}>{meeting.attended ? 'Present' : 'Absent'}</Text>
Expand Down
2 changes: 2 additions & 0 deletions components/reports/reportConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const MEMBER_DETAIL_FIRST_PAGE_ROWS = 18;
export const MEMBER_DETAIL_CONTINUED_ROWS = 26;
Loading