1
1
import { useRouter } from "next/router"
2
2
import { GetStaticProps } from "next/types"
3
- import { SSRConfig , useTranslation } from "next-i18next"
3
+ import { useTranslation } from "next-i18next"
4
4
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
5
5
import {
6
6
Box ,
@@ -12,7 +12,7 @@ import {
12
12
UnorderedList ,
13
13
} from "@chakra-ui/react"
14
14
15
- import { BasePageProps } from "@/lib/types"
15
+ import { AllTimeData , BasePageProps , Unpacked } from "@/lib/types"
16
16
17
17
import Breadcrumbs from "@/components/Breadcrumbs"
18
18
import FeedbackCard from "@/components/FeedbackCard"
@@ -28,8 +28,11 @@ import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
28
28
29
29
import allTimeData from "../../../data/translation-reports/alltime/alltime-data.json"
30
30
31
- type Props = SSRConfig & {
32
- lastDeployDate : string
31
+ type TranslatorDataType = {
32
+ user : {
33
+ username : Unpacked < AllTimeData [ "data" ] > [ "user" ] [ "username" ]
34
+ fullName : Unpacked < AllTimeData [ "data" ] > [ "user" ] [ "fullName" ]
35
+ }
33
36
}
34
37
35
38
export const getStaticProps = ( async ( { locale } ) => {
@@ -65,39 +68,38 @@ const Contributors = () => {
65
68
const router = useRouter ( )
66
69
67
70
// TODO: Remove specific user checks once Acolad has updated their usernames
68
- const translatorData =
69
- allTimeData . data . flatMap (
70
- // use flatMap to get cleaner object types withouts nulls
71
- ( item ) => {
72
- const user = item ?. user
73
- if ( ! user ) return [ ]
74
-
75
- const userName = user . username
76
- if ( ! userName ) return [ ]
77
-
78
- const fullName = user . fullName ?? ""
79
-
80
- return userName !== "ethdotorg" &&
81
- ! userName . includes ( "LQS_" ) &&
82
- ! userName . includes ( "REMOVED_USER" ) &&
83
- ! userName . includes ( "Aco_" ) &&
84
- ! fullName . includes ( "Aco_" ) &&
85
- ! userName . includes ( "Acc_" ) &&
86
- ! fullName . includes ( "Acc_" ) &&
87
- userName !== "Finnish_Sandberg" &&
88
- userName !== "Norwegian_Sandberg" &&
89
- userName !== "Swedish_Sandberg"
90
- ? [
91
- {
92
- user : {
93
- username : userName ,
94
- fullName : fullName ,
95
- } ,
71
+ const translatorData = (
72
+ allTimeData as AllTimeData
73
+ ) . data . flatMap < TranslatorDataType > (
74
+ // use flatMap to get cleaner object types withouts nulls
75
+ ( item ) => {
76
+ const user = item . user
77
+
78
+ const userName = user . username
79
+
80
+ const fullName = user . fullName
81
+
82
+ return userName !== "ethdotorg" &&
83
+ ! userName . includes ( "LQS_" ) &&
84
+ ! userName . includes ( "REMOVED_USER" ) &&
85
+ ! userName . includes ( "Aco_" ) &&
86
+ ! fullName . includes ( "Aco_" ) &&
87
+ ! userName . includes ( "Acc_" ) &&
88
+ ! fullName . includes ( "Acc_" ) &&
89
+ userName !== "Finnish_Sandberg" &&
90
+ userName !== "Norwegian_Sandberg" &&
91
+ userName !== "Swedish_Sandberg"
92
+ ? [
93
+ {
94
+ user : {
95
+ username : userName ,
96
+ fullName : fullName ,
96
97
} ,
97
- ]
98
- : [ ]
99
- }
100
- ) ?? [ ]
98
+ } ,
99
+ ]
100
+ : [ ]
101
+ }
102
+ )
101
103
102
104
return (
103
105
< Flex direction = "column" align = "center" w = "full" >
0 commit comments