Skip to content

Commit

Permalink
code-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pooranjoyb authored Dec 10, 2024
1 parent 07f92e1 commit d33a5fd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/Patient/SampleViewAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,20 @@ export default function SampleViewAdmin() {
};

const parseExportData = (data: string) => {
const rows = data.trim().split("\n");
const headerColumns = rows[0].split(",");
const [header, ...rows] = data.trim().split("\n");
const headerColumns = header.split(",").map((col) => col.trim());

return [
rows[0],
...rows.slice(1).map((row) => {
header,
...rows.map((row) => {
const columns = row.split(",").map((field, index) => {
const header = headerColumns[index]?.trim();
const header = headerColumns[index];

if (header === "Patient Age") {
return field.trim();
}

if (header === "Date of Sample" || header === "Date of Result") {
if (["Date of Sample", "Date of Result"].includes(header)) {
const formattedDate = formatDateTime(field.trim());
return formattedDate === "Invalid Date" ? "" : formattedDate;
}
Expand Down

0 comments on commit d33a5fd

Please sign in to comment.