mirror of
				https://github.com/r-freeman/portfolio.git
				synced 2025-11-04 12:21:11 +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 {getAllArticles} from '@/lib/getAllArticles'
 | 
			
		||||
import {getViews} from '@/lib/views'
 | 
			
		||||
import {CardProps} from '@/types'
 | 
			
		||||
 | 
			
		||||
export async function getDashboardData() {
 | 
			
		||||
    const [totalRepos, totalFollowers] = await Promise.all([
 | 
			
		||||
@ -12,7 +13,7 @@ export async function getDashboardData() {
 | 
			
		||||
    const totalArticles = (await getAllArticles()).length
 | 
			
		||||
    const totalArticleViews = (await getViews()).views
 | 
			
		||||
 | 
			
		||||
    const data = [
 | 
			
		||||
    const data: CardProps[] = [
 | 
			
		||||
        {
 | 
			
		||||
            title: "Repos",
 | 
			
		||||
            metric: totalRepos,
 | 
			
		||||
@ -45,11 +46,10 @@ export async function getDashboardData() {
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    const groups = data.reduce((acc, item) => {
 | 
			
		||||
        // @ts-ignore
 | 
			
		||||
    const groups = data.reduce((acc: { [key: string]: CardProps[] }, 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 {groupName, groupItems}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user