Skip to content

Commit

Permalink
Fix issue with Yield timestamp order (#299)
Browse files Browse the repository at this point in the history
fix(charts): Use Array to build PPS graph data

Using the map return doesn't guarantee order
  • Loading branch information
bestatigen authored Dec 2, 2022
1 parent 3ae8d1d commit 0439e00
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions packages/front-end/src/components/VaultChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,30 @@ export const VaultChart = () => {
`,
{
onCompleted: (data) => {
const refinedData: any = data?.pricePerShares
? data.pricePerShares.map((ppsEpoch: any) => {
const dateLocale = new Date(
parseInt(ppsEpoch.timestamp) * 1000
).toLocaleString("default", {
month: "numeric",
day: "numeric",
year: "numeric",
});
const refinedData: any =
data?.pricePerShares?.length > 0
? new Array(data.pricePerShares.length)
: [];

return {
epoch: ppsEpoch.id,
// @reminder: For presentation it's ok but reminder that number of float decimals is 17
growthSinceFirstEpoch: parseFloat(
ppsEpoch.growthSinceFirstEpoch
),
timestamp: ppsEpoch.timestamp,
dateLocale,
};
})
: [];
data.pricePerShares.map((ppsEpoch: any) => {
const dateLocale = new Date(
parseInt(ppsEpoch.timestamp) * 1000
).toLocaleString("default", {
month: "numeric",
day: "numeric",
year: "numeric",
});

Object.keys(refinedData).length > 0 &&
setPricePerShares(Object.values(refinedData));
refinedData[+ppsEpoch.id - 1] = {
epoch: ppsEpoch.id,
// @reminder: For presentation it's ok but reminder that number of float decimals is 17
growthSinceFirstEpoch: parseFloat(ppsEpoch.growthSinceFirstEpoch),
timestamp: ppsEpoch.timestamp,
dateLocale,
};
});

setPricePerShares(refinedData);
},
onError: (err) => {
console.log(err);
Expand Down

0 comments on commit 0439e00

Please sign in to comment.