Skip to content

Commit

Permalink
Move default value in function
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed Mar 8, 2024
1 parent 9acfb15 commit ba8998c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/components/ExportButton/ExportButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,18 @@ function ExportButton({
return;
}

let templateValues = {};
let templateValues;
let imageUrl;
let fileName = `trafimage-${new Date().toISOString().slice(0, 10)}.pdf`;
let fileName;

const { exportConfig } = topic;
if (exportConfig) {
const { getTemplateValues, getOverlayImageUrl, getExportFileName } =
exportConfig;
templateValues = getTemplateValues
? getTemplateValues(i18n.language, t)
: {};
imageUrl =
getOverlayImageUrl &&
getOverlayImageUrl(i18n.language, exportFormat);
fileName = getExportFileName
? getExportFileName(t, exportFormat, i18n.language)
: fileName;
templateValues = getTemplateValues?.(i18n.language, t);
imageUrl = getOverlayImageUrl?.(i18n.language, exportFormat);
fileName =
getExportFileName?.(t, exportFormat, i18n.language) || fileName;
}

const scaleLineControl = mapToExport
Expand Down
4 changes: 2 additions & 2 deletions src/utils/exportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ export const exportPdf = async (
canvas,
exportScale,
exportSize,
templateValues,
templateValues = {},
overlayImageUrl,
exportFileName,
exportFileName = `trafimage-${new Date().toISOString().slice(0, 10)}.pdf`,
scaleLineConfig,
) => {
clean(mapToExport, map, new LayerService(layers));
Expand Down

0 comments on commit ba8998c

Please sign in to comment.