migrate to app dir and ssr

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-01-20 22:54:38 +01:00
parent 719a82f1c4
commit 308ae98472
194 changed files with 4706 additions and 2194 deletions

View File

@@ -0,0 +1,34 @@
import { useMemo } from 'react';
import type { IChartData } from '@/app/_trpc/client';
import { alphabetIds } from '@/utils/constants';
import { getChartColor } from '@/utils/theme';
export function useRechartDataModel(data: IChartData) {
return useMemo(() => {
return (
data.series[0]?.data.map(({ date }) => {
return {
date,
...data.series.reduce((acc, serie, idx) => {
return {
...acc,
...serie.data.reduce(
(acc2, item) => {
if (item.date === date) {
acc2[`${idx}:count`] = item.count;
acc2[`${idx}:payload`] = {
...item,
color: getChartColor(idx),
};
}
return acc2;
},
{} as Record<string, any>
),
};
}, {}),
};
}) ?? []
);
}, [data]);
}