Skip to content

Commit d9da28e

Browse files
authored
Merge pull request #2472 from flacial/3/2081-dojoadminpage-editadd-challenges
refactor: Make refetch prop type generic
2 parents 11f481f + fd75b60 commit d9da28e

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

components/admin/lessons/AdminLessonInputs/AdminLessonInputs.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import { formChange } from '../../../../helpers/formChange'
33
import { FormCard, MD_INPUT, Option, TextField } from '../../../FormCard'
44
import styles from './adminLessonInputs.module.scss'
55
import { isEqual } from 'lodash'
6-
import {
7-
ApolloError,
8-
OperationVariables,
9-
ApolloQueryResult
10-
} from '@apollo/client'
6+
import { ApolloError, ApolloQueryResult } from '@apollo/client'
117
import QueryInfo from '../../../QueryInfo'
8+
import { Exact } from '../../../../graphql'
129

1310
export type Item = {
1411
id?: number
@@ -18,17 +15,15 @@ export type Item = {
1815
lesson?: { __typename?: string; id?: number }
1916
}
2017

21-
export type Props<MainItem extends Item> = {
18+
export type Props = {
2219
lessonId: number
2320
title?: string
2421
item?: Item
2522
itemName?: string
2623
loading: boolean
27-
refetch: (variables?: Partial<OperationVariables>) => Promise<
28-
ApolloQueryResult<{
29-
[key: string]: MainItem[]
30-
}>
31-
>
24+
refetch: (
25+
variables?: Partial<Exact<{ [key: string]: never }>> | undefined
26+
) => Promise<ApolloQueryResult<any>>
3227
onActionFinish?: (
3328
m: (Item & { lesson: { id: number } }) | null,
3429
e: { name: string; content: string; order: number } | null
@@ -61,7 +56,7 @@ const initValues = (
6156
}
6257
]
6358

64-
const AdminLessonInputs = <MainItem extends Item>({
59+
const AdminLessonInputs = ({
6560
title,
6661
lessonId,
6762
item,
@@ -70,7 +65,7 @@ const AdminLessonInputs = <MainItem extends Item>({
7065
refetch,
7166
onActionFinish,
7267
action
73-
}: Props<MainItem>) => {
68+
}: Props) => {
7469
const [formOptions, setFormOptions] = useState<any>(initValues())
7570
const [name, content, order] = formOptions
7671

pages/admin/lessons/[lessonSlug]/[pageName]/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const IntroductionPage = ({ lesson }: { lesson: Lesson }) => {
139139
type ModulesPageProps = {
140140
modules: Modules
141141
lessonId: number
142-
refetch: Props<Module>['refetch']
142+
refetch: Props['refetch']
143143
}
144144
const ModulesPage = ({ modules, lessonId, refetch }: ModulesPageProps) => {
145145
const [selectedIndex, setSelectedIndex] = useState(-1)
@@ -237,7 +237,7 @@ type ContentProps = {
237237
pageName?: string | string[]
238238
modules: Modules
239239
lessonId: number
240-
refetch: Props<Module>['refetch']
240+
refetch: Props['refetch']
241241
lesson: Lesson
242242
}
243243
const Content = ({

0 commit comments

Comments
 (0)