Recently, I've started using next.js and came across the getStaticProps
function. In this function, I'm loading data from a Google Sheet table into a constant. The result is an array of arrays, just like what the Google API returns shown below:
[ [ "CLIENT A", "MIKE", "UNKNOWN", "TRADICIONAL" ], [ "CLIENT B", "MARY", "UNKNOWN", "MOROSO" ], [ "CLIENT C", "MIKE", "CLIENT C S.A DE C.V.", "TRADICIONAL" ], [ "CLIENT D", "JOHN", "RAZON SOCIAL CLIENT", "TRADICIONAL" ] ]
I am passing this array as props but struggling to manipulate the information in order to display it in the desired format:
CLIENT ASalesperson: MIKE
Razón Social: UNKNOWN
Category: TRADICIONAL
--------------------
CLIENT BSalesperson: MARY
Razón Social: UNKNOWN
Category: MOROSO
--------------------
CLIENT CSalesperson: MIKE
Razón Social: CLIENT C S.A DE C.V.
Category: TRADICIONAL
I have been trying to figure out a way to add keys to the array, such as:
{ client: "CLIENT A", salesperson: "MIKE", razonsocial: "UNKNOWN", category: "TRADICIONAL", }
I also attempted to map the array of arrays but encountered an error stating that mapping was not possible.
If anyone could provide guidance on the best approach to handling this array, I would greatly appreciate it!