Skip to content

Commit

Permalink
Merge pull request #31 from anuaimi/14-make-download-button-work
Browse files Browse the repository at this point in the history
make download button work
  • Loading branch information
anuaimi authored Apr 18, 2023
2 parents 1d10f18 + 63e0aee commit cc6ab41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ function Download({paper, layout, year}:DownloadProps) {

const downloadLayout = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
// need to get state of: pageSize, layout, year
const msg = "paperSize: " + paper + " layout: " + layout + " year: " + year;
alert(msg);
// window.open("https://philofaxy.com/inserts/__2020%20revamp/1.1%20day%20per%20page/2023%201.1.1.pdf")

const pdfUrl = `layouts/${paper}/${year}/${layout}.pdf`
// console.log("insert url is " + pdfUrl);
window.open(pdfUrl);

}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/PaperPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function PaperPreview({paper, layout}:PaperPreviewProps) {
const generatePreviewUrl = () => {

const previewUrl = `images/${paper}/${layout}.png`;
console.log("preview url is " + previewUrl);
// console.log("preview url is " + previewUrl);
return previewUrl;
}

Expand Down
12 changes: 6 additions & 6 deletions src/PlannerLayouts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ function PlannerLayouts({paper, setPaperSize, layout, setLayout}:PlannerLayoutPr

const getTabIndex = (paperSize:string) => {
if (paperSize === "a4-a5") {
console.log("a4-a5 is selected");
// console.log("a4-a5 is selected");
return 0;
}
else if (paperSize === "personal") {
console.log("personal is selected");
// console.log("personal is selected");
return 1;
} else {
// must be pocket
console.log("pocket is selected");
// console.log("pocket is selected");
return 2;
}
}

const handleTabChange= (index: number) => {
if (index === 0) {
setPaperSize('a4-a5');
console.log('set paper size to a4-a5');
// console.log('set paper size to a4-a5');
} else if (index === 1) {
setPaperSize('personal');
console.log('set paper size to personal');
// console.log('set paper size to personal');
} else {
setPaperSize('pocket');
console.log('set paper size to pocket');
// console.log('set paper size to pocket');
}
}

Expand Down

0 comments on commit cc6ab41

Please sign in to comment.