diff --git a/src/components/client/pdf/Certificate.tsx b/src/components/client/pdf/Certificate.tsx index 9106bf988..ea126bee7 100644 --- a/src/components/client/pdf/Certificate.tsx +++ b/src/components/client/pdf/Certificate.tsx @@ -6,6 +6,7 @@ import { formatDateString } from 'common/util/date' import { money } from 'common/util/money' import theme from 'common/theme' import { DonationType } from 'gql/donations.enums' +import { ServerUser } from 'service/auth' Font.register({ family: 'Arial', @@ -122,11 +123,12 @@ const styles = StyleSheet.create({ type Props = { donation: DonationResponse + user: ServerUser | null | undefined } -export default function Certificate({ donation }: Props) { - const companyName = donation.person?.company - ? donation.person.company.companyName - : donation.affiliate.company.companyName +export default function Certificate({ donation, user }: Props) { + const userName = `${user?.given_name} ${user?.family_name}` ?? '' + const companyName = `${user?.company}` ?? '' + return ( @@ -143,8 +145,7 @@ export default function Certificate({ donation }: Props) { С този сертификат Управителният съвет на Сдружение „Подкрепи БГ“ удостоверява, че: - {donation.type === DonationType.donation && - `${donation.person?.firstName} ${donation.person?.lastName}`} + {donation.type === DonationType.donation && userName} {donation.type === DonationType.corporate && companyName} diff --git a/src/pages/api/pdf/certificate/[donationId].tsx b/src/pages/api/pdf/certificate/[donationId].tsx index 7a73b6f6b..4fa29fa90 100644 --- a/src/pages/api/pdf/certificate/[donationId].tsx +++ b/src/pages/api/pdf/certificate/[donationId].tsx @@ -24,7 +24,7 @@ const Handler: NextApiHandler = async (req: NextApiRequest, res: NextApiResponse if (!donation) { res.status(404).json({ notFound: true }) } else { - const pdfStream = await renderToStream() + const pdfStream = await renderToStream() res.setHeader('Content-Type', 'application/pdf') pdfStream.pipe(res) } diff --git a/src/service/auth.ts b/src/service/auth.ts index bf38d8c0b..88135d086 100644 --- a/src/service/auth.ts +++ b/src/service/auth.ts @@ -51,6 +51,7 @@ export type ServerUser = ParsedToken & { session_state: string 'allowed-origins': string[] selfReg?: boolean + company: string // access realm_access: { roles: RealmRole[] } resource_access: { account: { roles: ResourceRole[] } }