Skip to content

Commit

Permalink
Issue developer-job-simulation#3 Revenue Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishvora committed Nov 24, 2022
1 parent 6da77e9 commit e6787dc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ui.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {fetchCompanies} from "./api";
import { fetchCompanies } from "./api";
import {
ACCOUNT_EXECUTIVE_FIELD_NAME,
COMPANIES_TABLE_HEADERS,
COMPANY_NAME_FIELD_NAME,
CREATED_AT_FIELD_NAME,
REVENUE_YTD_FIELD_NAME,
STATUS_FIELD_NAME
STATUS_FIELD_NAME,
} from "./constants";

export const makeTable = async () => {
Expand All @@ -20,13 +20,14 @@ export const makeTable = async () => {
companiesToDisplay.push(COMPANIES_TABLE_HEADERS);

// Here we simply rearrange company fields in the order in which we want to display them in UI
companies.map(company => {
companies.map((company) => {
const row = [];

row.push(
company[COMPANY_NAME_FIELD_NAME],
company[STATUS_FIELD_NAME],
company[CREATED_AT_FIELD_NAME],
company[REVENUE_YTD_FIELD_NAME],
company[REVENUE_YTD_FIELD_NAME].toLocaleString("en", { maximumSignificantDigits: 3 }),
company[ACCOUNT_EXECUTIVE_FIELD_NAME]
);
companiesToDisplay.push(row);
Expand All @@ -36,12 +37,12 @@ export const makeTable = async () => {
const table = document.createElement("table");
document.body.appendChild(table); // Drew the main table node on the document

companiesToDisplay.forEach(row => {
companiesToDisplay.forEach((row) => {
const tr = table.insertRow(); //Create a new row

row.forEach(column => {
row.forEach((column) => {
const td = tr.insertCell();
td.innerText = column; // Take string from placeholder variable and append it to <tr> node
});
});
};
};

0 comments on commit e6787dc

Please sign in to comment.