Skip to content

Commit

Permalink
fix descriptions and run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-sellner committed Jun 24, 2023
1 parent d87800e commit bca3ccb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
23 changes: 18 additions & 5 deletions frontend/src/helper/CSVConverter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CSVLog } from "../types/CSVLog";
const convertToCSVLog = (logRecord: LogRecord): CSVLog => {
const attnTo = `${logRecord.attnToFirstName} ${logRecord.attnToLastName}`;
const employee = `${logRecord.employeeFirstName} ${logRecord.employeeLastName}`;

return {
attnTo,
building: logRecord.building,
Expand All @@ -22,10 +22,19 @@ const CSVConverter = (data: LogRecord[]): boolean => {
try {
const csvRows = [];

const headers = ["attnTo", "building", "datetime", "employee", "flagged", "note", "residentId", "tags"];
const headers = [
"attnTo",
"building",
"datetime",
"employee",
"flagged",
"note",
"residentId",
"tags",
];
csvRows.push(headers.join(","));
data.forEach((log: LogRecord) => {
const logCSV = convertToCSVLog(log);
const logCSV = convertToCSVLog(log);
const values = Object.values(logCSV).join(",");
csvRows.push(values);
});
Expand All @@ -36,9 +45,13 @@ const CSVConverter = (data: LogRecord[]): boolean => {
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;


// Get date for file name
// "fr-CA" formats the date into YYYY-MM-DD
const dateToday = new Date();
const dateTodayString = dateToday.toLocaleString("fr-CA", {timeZone: "America/Toronto"}).substring(0, 10);
const dateTodayString = dateToday
.toLocaleString("fr-CA", { timeZone: "America/Toronto" })
.substring(0, 10);

link.setAttribute("download", `log_records ${dateTodayString}.csv`);
document.body.appendChild(link);
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/types/CSVLog.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export type CSVLog = {
attnTo: string;
building: string;
datetime: string;
employee: string;
flagged: boolean;
note: string;
residentId: string;
tags: string;
};
attnTo: string;
building: string;
datetime: string;
employee: string;
flagged: boolean;
note: string;
residentId: string;
tags: string;
};

0 comments on commit bca3ccb

Please sign in to comment.