From 3f2da991b45ec495406ee85915b3eabc0fc07b21 Mon Sep 17 00:00:00 2001 From: Andrzej Stepien Date: Wed, 6 Sep 2023 23:27:02 +0200 Subject: [PATCH] dynamically capitalise headings --- src/Components/Table.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Components/Table.jsx b/src/Components/Table.jsx index a729ab9..30e03ec 100644 --- a/src/Components/Table.jsx +++ b/src/Components/Table.jsx @@ -9,6 +9,7 @@ export default function Table(props) { const sort = (data,sortBy) => { const isDate = (str) =>{ if(str && DateTime.fromFormat(str,'yyyy-MM-dd').isValid){ + console.log("found a date!") return true } return false @@ -69,7 +70,6 @@ export default function Table(props) { }) } } - //NEED TO DYNAMICALLY CAPITALISE HEADINGS HERE AT SOME POINT return {Object.keys(data[0]).map((heading, i) => { const isSortable = () => { @@ -83,7 +83,8 @@ export default function Table(props) { } return"\u2002" } - return + const capitalisedHeading = heading.slice(0,1).toUpperCase()+heading.slice(1) + return })} } @@ -100,7 +101,7 @@ export default function Table(props) { return } const getOriginalRowByID = (array,row) => { - return array.find(e=>e?.id===row?.id) //THIS CAN BE CLEANED UP WHEN ALL ID COLUMNS ARE LOWERCASE + return array.find(e=>e?.id===row?.id) } if(props?.clickables?.find(e=>e[0]===key)){ const index = props.clickables?.findIndex(row=>row[0]==key)