-
-
Notifications
You must be signed in to change notification settings - Fork 206
feat: added download agenda as a pdf #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
harshhgithub
wants to merge
34
commits into
asyncapi:master
Choose a base branch
from
harshhgithub:agenda-as-pdf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3d3378a
added download pdf component
harshhgithub 80829e3
Merge branch 'master' into agenda-as-pdf
harshhgithub 1e85eb3
resolveed conflicts
harshhgithub 1dfd8f2
Merge branch 'agenda-as-pdf' of https://github.com/harshhgithub/confe…
harshhgithub 1920996
resolved
harshhgithub 9b57118
removed the comments and fixed the wording
harshhgithub 5b8b1fc
Merge branch 'master' into agenda-as-pdf
harshhgithub 885c85c
Merge branch 'master' into agenda-as-pdf
AceTheCreator 4f40261
Merge branch 'master' into agenda-as-pdf
harshhgithub 7e2c441
made the requested changes
harshhgithub 14223e6
Merge branch 'agenda-as-pdf' of https://github.com/harshhgithub/confe…
harshhgithub 8b2b163
Merge branch 'master' into agenda-as-pdf
thulieblack fed790c
fixed
harshhgithub effd067
Merge branch 'agenda-as-pdf' of https://github.com/harshhgithub/confe…
harshhgithub e61e26b
Merge branch 'master' into agenda-as-pdf
AceTheCreator 569a750
Merge branch 'master' into agenda-as-pdf
harshhgithub 0f841c7
Merge branch 'master' into agenda-as-pdf
harshhgithub e6e0cbf
Merge branch 'master' into agenda-as-pdf
AceTheCreator f45419d
Merge branch 'master' into agenda-as-pdf
harshhgithub 0e02fa8
made the changes
harshhgithub 7413795
Merge branch 'agenda-as-pdf' of https://github.com/harshhgithub/confe…
harshhgithub f323d10
made some changes
harshhgithub da767c2
check
harshhgithub d81692a
dependencies
harshhgithub 9f6e7f5
fixed
harshhgithub b93f9e0
fixed errors
harshhgithub ce4c1af
Merge branch 'master' into agenda-as-pdf
AceTheCreator cd9a72d
Merge branch 'master' into agenda-as-pdf
harshhgithub 6d50cd0
extended getEventStatusMethod
harshhgithub 83e52ef
Merge branch 'agenda-as-pdf' of https://github.com/harshhgithub/confe…
harshhgithub e4f4cbe
Merge branch 'master' into agenda-as-pdf
harshhgithub c9b11ae
made the asked changes and added unit test
harshhgithub 774126d
Merge branch 'agenda-as-pdf' of https://github.com/harshhgithub/confe…
harshhgithub cdcc4e8
Merge branch 'master' into agenda-as-pdf
harshhgithub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| 'use client'; | ||
| import React from 'react'; | ||
| import { | ||
| Page, | ||
| Text, | ||
| View, | ||
| Document, | ||
| StyleSheet, | ||
| Image, | ||
| Font, | ||
| PDFDownloadLink, | ||
| PDFViewer, | ||
| } from '@react-pdf/renderer'; | ||
| import Button from '../Buttons/button'; | ||
| import { ExtendedCity, Speaker, Agenda as AgendaType } from '../../types/types'; | ||
|
|
||
| Font.register({ | ||
| family: 'Open Sans', | ||
| fonts: [ | ||
| { | ||
| src: 'https://cdn.jsdelivr.net/npm/open-sans-all@0.1.3/fonts/open-sans-regular.ttf', | ||
| }, | ||
| { | ||
| src: 'https://cdn.jsdelivr.net/npm/open-sans-all@0.1.3/fonts/open-sans-600.ttf', | ||
| fontWeight: 600, | ||
| }, | ||
| { | ||
| src: 'https://cdn.jsdelivr.net/npm/open-sans-all@0.1.3/fonts/open-sans-800.ttf', | ||
| fontWeight: 800, | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| page: { | ||
| backgroundColor: '#1B1130', | ||
| padding: 40, | ||
| color: '#fff', | ||
| fontFamily: 'Open Sans', | ||
| }, | ||
| logo: { | ||
| width: 90, | ||
| marginBottom: 10, | ||
| alignSelf: 'center', | ||
| }, | ||
| header: { | ||
| textAlign: 'center', | ||
| marginBottom: 20, | ||
| }, | ||
| title: { | ||
| fontSize: 26, | ||
| fontWeight: 800, | ||
| marginBottom: 4, | ||
| }, | ||
| subtitle: { | ||
| fontSize: 16, | ||
| fontWeight: 600, | ||
| color: '#E74694', | ||
| }, | ||
| date: { | ||
| textAlign: 'center', | ||
| fontSize: 13, | ||
| marginTop: 6, | ||
| }, | ||
| tableHeader: { | ||
| flexDirection: 'row', | ||
| borderBottomWidth: 1, | ||
| borderBottomColor: '#E74694', | ||
| paddingBottom: 6, | ||
| marginTop: 12, | ||
| }, | ||
| headerText: { | ||
| fontSize: 12, | ||
| fontWeight: 600, | ||
| color: '#E74694', | ||
| }, | ||
| row: { | ||
| flexDirection: 'row', | ||
| borderBottomWidth: 0.5, | ||
| borderBottomColor: '#666', | ||
| paddingVertical: 8, | ||
| }, | ||
|
|
||
| timeCol: { width: '17%', fontSize: 12, paddingRight: 6 }, | ||
| sessionCol: { width: '50%', paddingHorizontal: 10 }, | ||
| speakerCol: { width: '33%', fontSize: 12, paddingLeft: 6 }, | ||
| sessionTitle: { fontSize: 13, fontWeight: 600, color: '#fff' }, | ||
| sessionType: { fontSize: 10, color: '#bbb' }, | ||
| speakerName: { fontSize: 12, fontWeight: 600, color: '#fff' }, | ||
| speakerTitle: { fontSize: 10, color: '#ccc' }, | ||
|
|
||
| footer: { | ||
| position: 'absolute', | ||
| bottom: 25, | ||
| left: 0, | ||
| right: 0, | ||
| textAlign: 'center', | ||
| fontSize: 10, | ||
| color: '#aaa', | ||
| }, | ||
| }); | ||
|
|
||
| const cleanAgenda = (agenda: AgendaType[]) => { | ||
| let tz: string | null = null; | ||
| const processed = agenda.map((item) => { | ||
| const tzMatch = item.time.match(/\b(?!AM|PM)([A-Z]{2,4})\b/g); | ||
| if (tzMatch && !tz) tz = tzMatch[0]; | ||
| return { ...item, time: item.time.replace(/\b(?!AM|PM)([A-Z]{2,4})\b/g, '') }; | ||
| }); | ||
| return { processed, tz }; | ||
| }; | ||
|
|
||
| const AgendaPDF = ({ city }: { city: ExtendedCity }) => { | ||
| const { processed, tz } = cleanAgenda(city.agenda); | ||
| return ( | ||
| <Document> | ||
| <Page style={styles.page}> | ||
| <View style={styles.header}> | ||
| <Image src="/img/logos/2025-logo.png" style={styles.logo} /> | ||
| <Text style={styles.title}> | ||
| {city.name}, {city.country} | ||
| </Text> | ||
| <Text style={styles.subtitle}>Conference Agenda</Text> | ||
| <Text style={styles.date}> | ||
| {city.date} {tz && `(${tz})`} | ||
| </Text> | ||
| </View> | ||
|
|
||
| <View style={styles.tableHeader}> | ||
| <Text style={[styles.headerText, { width: '17%' }]}>Time</Text> | ||
| <Text style={[styles.headerText, { width: '50%' }]}>Session</Text> | ||
| <Text style={[styles.headerText, { width: '33%' }]}>Speaker</Text> | ||
| </View> | ||
|
|
||
| {processed.map((item, i) => ( | ||
| <View style={styles.row} key={i} wrap={false}> | ||
| <Text style={styles.timeCol}>{item.time}</Text> | ||
| <View style={styles.sessionCol}> | ||
| <Text style={styles.sessionTitle}>{item.session}</Text> | ||
| <Text style={styles.sessionType}>{item.type}</Text> | ||
| </View> | ||
| <View style={styles.speakerCol}> | ||
| {Array.isArray(item.speaker) | ||
| ? item.speaker.map((id: number) => { | ||
| const sp = city.speakers.find((s: Speaker) => s.id === id); | ||
| return ( | ||
| <View key={id}> | ||
| <Text style={styles.speakerName}>{sp?.name}</Text> | ||
| <Text style={styles.speakerTitle}>{sp?.title}</Text> | ||
| </View> | ||
| ); | ||
| }) | ||
| : (() => { | ||
| const sp = city.speakers.find( | ||
| (s: Speaker) => s.id === item.speaker | ||
| ); | ||
| return ( | ||
| <> | ||
| <Text style={styles.speakerName}>{sp?.name}</Text> | ||
| <Text style={styles.speakerTitle}>{sp?.title}</Text> | ||
| </> | ||
| ); | ||
| })()} | ||
| </View> | ||
| </View> | ||
| ))} | ||
|
|
||
| <Text style={styles.footer}> | ||
| AsyncAPI Conference © {new Date().getFullYear()} | ||
| </Text> | ||
| </Page> | ||
| </Document> | ||
| ); | ||
| }; | ||
|
|
||
| export const PdfViewer = ({ city }: { city: ExtendedCity }) => ( | ||
| <div className="w-full flex justify-center h-full"> | ||
| <PDFViewer className="w-[85%] h-[90vh]"> | ||
| <AgendaPDF city={city} /> | ||
| </PDFViewer> | ||
| </div> | ||
| ); | ||
|
|
||
| export const PdfDownloadButton = ({ city }: { city: ExtendedCity }) => ( | ||
| <div className="w-full flex justify-center mt-6"> | ||
| <PDFDownloadLink | ||
| document={<AgendaPDF city={city} />} | ||
| fileName={`${city.name}-Agenda.pdf`} | ||
| style={{ textDecoration: 'none', width: '100%', maxWidth: '220px' }} | ||
| > | ||
| {({ loading }) => ( | ||
| <Button | ||
| type="button" | ||
| className="w-full min-w-[200px] px-10 py-3 whitespace-nowrap" | ||
| disabled={loading} | ||
| > | ||
| {loading ? 'Preparing Agenda…' : 'Download Agenda'} | ||
| </Button> | ||
| )} | ||
| </PDFDownloadLink> | ||
| </div> | ||
| ); | ||
|
|
||
| export default AgendaPDF; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a helper function to check whether an event is in the past, so it can be reused throughout the application. Right now, a new check is created each time it’s needed (for example, the tickets section also checks for past events).