Skip to content

Commit

Permalink
Merge pull request #599 from stiftelsen-effekt/598-bad-moment-import
Browse files Browse the repository at this point in the history
Fix moment import
  • Loading branch information
fellmirr authored Aug 22, 2023
2 parents 648912f + 1c63f0a commit 7c58d75
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/custom_modules/dateRangeHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as moment from "moment";
import moment from "moment";

module.exports = {
/** A function that checks for the parameters formDate and toDate, and returns JS Date objects coresponding. Throws exception if errors.
Expand All @@ -17,8 +17,8 @@ module.exports = {

//Check if dates are valid ISO 8601
if (
!(moment as any)(fromDate, moment.ISO_8601, true).isValid() ||
!(moment as any)(toDate, moment.ISO_8601, true).isValid()
!moment(fromDate, moment.ISO_8601, true).isValid() ||
!moment(toDate, moment.ISO_8601, true).isValid()
)
throw new Error("Dates must be in ISO 8601 format");

Expand Down
2 changes: 1 addition & 1 deletion src/custom_modules/parsers/bank.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as moment from "moment";
import moment from "moment";
import { parse } from "csv-parse/sync";

const parseUtil = require("./util");
Expand Down
1 change: 0 additions & 1 deletion src/custom_modules/parsers/tax.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as moment from "moment";
import { parse } from "csv-parse/sync";
const parseUtil = require("./util");

Expand Down
2 changes: 1 addition & 1 deletion src/custom_modules/parsers/vipps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as moment from "moment";
import moment from "moment";
import { parse } from "csv-parse/sync";
const parseUtil = require("./util");

Expand Down
4 changes: 2 additions & 2 deletions src/routes/reports/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ module.exports = async (req, res, next) => {
"Content-Type": "application/vnd.ms-excel",
"Content-disposition":
"attachment;filename=Individual_Donations_" +
(moment as any)(dates.fromDate).format("YYYY-MM-DD") +
moment(dates.fromDate).format("YYYY-MM-DD") +
"_to_" +
(moment as any)(dates.toDate).format("YYYY-MM-DD") +
moment(dates.toDate).format("YYYY-MM-DD") +
".xlsx",
"Content-Length": excelFile.length,
});
Expand Down

0 comments on commit 7c58d75

Please sign in to comment.