mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-22 13:35:41 +00:00
Fix typescript issue in dashboard lib
This commit is contained in:
parent
48c32c333e
commit
c34ad0fa5c
@ -1,6 +1,7 @@
|
|||||||
import {getTotalFollowers, getTotalRepos, getTotalStars} from '@/lib/github'
|
import {getTotalFollowers, getTotalRepos, getTotalStars} from '@/lib/github'
|
||||||
import {getAllArticles} from '@/lib/getAllArticles'
|
import {getAllArticles} from '@/lib/getAllArticles'
|
||||||
import {getViews} from '@/lib/views'
|
import {getViews} from '@/lib/views'
|
||||||
|
import {CardProps} from '@/types'
|
||||||
|
|
||||||
export async function getDashboardData() {
|
export async function getDashboardData() {
|
||||||
const [totalRepos, totalFollowers] = await Promise.all([
|
const [totalRepos, totalFollowers] = await Promise.all([
|
||||||
@ -12,7 +13,7 @@ export async function getDashboardData() {
|
|||||||
const totalArticles = (await getAllArticles()).length
|
const totalArticles = (await getAllArticles()).length
|
||||||
const totalArticleViews = (await getViews()).views
|
const totalArticleViews = (await getViews()).views
|
||||||
|
|
||||||
const data = [
|
const data: CardProps[] = [
|
||||||
{
|
{
|
||||||
title: "Repos",
|
title: "Repos",
|
||||||
metric: totalRepos,
|
metric: totalRepos,
|
||||||
@ -45,11 +46,10 @@ export async function getDashboardData() {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const groups = data.reduce((acc, item) => {
|
const groups = data.reduce((acc: { [key: string]: CardProps[] }, item) => {
|
||||||
// @ts-ignore
|
|
||||||
(acc[item.group] = acc[item.group] || []).push(item);
|
(acc[item.group] = acc[item.group] || []).push(item);
|
||||||
return acc;
|
return acc
|
||||||
}, {})
|
}, {} as { [key: string]: CardProps[] })
|
||||||
|
|
||||||
return Object.entries(groups).map(([groupName, groupItems]) => {
|
return Object.entries(groups).map(([groupName, groupItems]) => {
|
||||||
return {groupName, groupItems}
|
return {groupName, groupItems}
|
||||||
|
Loading…
Reference in New Issue
Block a user