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
10 changes: 10 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"@emotion/styled": "^11.11.0",
"@fontsource/eczar": "^4.5.12",
"@fontsource/work-sans": "^4.5.14",
"@react-pdf/font": "2.2.1",
"@react-pdf/fontkit": "2.0.2",
"@react-pdf/pdfkit": "2.1.0",
"@react-pdf/renderer": "2.0.19",
"@rjsf/bootstrap-4": "^2.5.1",
"@rjsf/core": "^2.5.1",
"@testing-library/jest-dom": "^5.17.0",
Expand Down Expand Up @@ -47,6 +51,12 @@
"typescript": "^4.1.2",
"web-vitals": "^1.1.2"
},
"overrides": {
"react-error-overlay": "6.0.9",
"@react-pdf/font": "2.2.1",
"@react-pdf/fontkit": "2.0.2",
"@react-pdf/pdfkit": "2.1.0"
},
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
Expand Down
50 changes: 42 additions & 8 deletions frontend/src/components/overview/CaseOverviewFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import React from "react";
import { Box, Button, Flex, useDisclosure } from "@chakra-ui/react";
import {
Document,
Page,
Text,
View,
StyleSheet,
PDFDownloadLink,
} from "@react-pdf/renderer";
import { FileText } from "react-feather";
import ArchiveCaseModal from "../dashboard/ArchiveCaseModal";

Expand All @@ -17,6 +25,33 @@ const CaseOverviewFooter = (): React.ReactElement => {
onClose: onCloseArchiveCaseModal,
} = useDisclosure();

// style pdf document
const styles = StyleSheet.create({
page: {
flexDirection: "row",
backgroundColor: "#E4E4E4",
},
section: {
margin: 10,
padding: 10,
flexGrow: 1,
},
});

// place dynamic data into document here
const MyDocument = () => (
<Document>
<Page size="A4" style={styles.page}>
<View style={styles.section}>
<Text>Section #1</Text>
</View>
<View style={styles.section}>
<Text>Section #2</Text>
</View>
</Page>
</Document>
);

return (
<Flex
bg="gray.50"
Expand All @@ -31,14 +66,13 @@ const CaseOverviewFooter = (): React.ReactElement => {
position="fixed"
bottom="0"
>
<Button
onClick={() => {
// TODO: Handle generate report logic
}}
>
<FileText width="13px" />
<Box pl="2">Generate Report (PDF)</Box>
</Button>
<PDFDownloadLink document={<MyDocument />} fileName="fee_acceptance.pdf">
{({ loading }) => (loading ? "Loading document..." : "Download now!")}
<Button onClick={() => {}}>
<FileText width="13px" />
<Box pl="2">Generate Report (PDF)</Box>
</Button>
</PDFDownloadLink>

<Button
width={{ sm: "95vw", md: "45vw", lg: "auto" }}
Expand Down
Loading