Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 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,13 @@ 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 +36,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
});
});
};
};