Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion components/SessionReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface SessionReportModalProps {
onClose: () => void;
}

const MEMBER_DETAIL_FIRST_PAGE_ROWS = 18;
const MEMBER_DETAIL_CONTINUED_ROWS = 26;

const formatDate = (value: string) =>
new Date(`${value}T00:00:00`).toLocaleDateString(undefined, {
day: 'numeric',
Expand Down Expand Up @@ -60,7 +63,17 @@ 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
+ 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,
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
: 0;

return (
Expand Down
53 changes: 45 additions & 8 deletions components/reports/SessionReportDocument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const BB_BACKGROUND_URL = bbBackground;
const COMPANY_LOGO_URL = companyLogo;
const JUNIOR_LOGO_URL = juniorLogo;

const MEMBER_DETAIL_FIRST_PAGE_ROWS = 18;
const MEMBER_DETAIL_CONTINUED_ROWS = 26;

const styles = StyleSheet.create({
page: {
backgroundColor: '#f8fafc',
Expand Down Expand Up @@ -53,15 +56,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,
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
coverMainLogo: {
width: 120,
Expand Down Expand Up @@ -229,8 +257,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 +274,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 +355,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 +615,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 +807,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 +905,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
Loading