Skip to content

Commit 13c6f52

Browse files
swap types with generated types
1 parent b8a110c commit 13c6f52

File tree

4 files changed

+30
-31
lines changed

4 files changed

+30
-31
lines changed

frontend/src/app/my/mentorship/programs/[programKey]/page.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { useParams, useSearchParams, useRouter } from 'next/navigation'
66
import { useSession } from 'next-auth/react'
77
import { useEffect, useMemo, useState } from 'react'
88
import { ErrorDisplay, handleAppError } from 'app/global-error'
9-
import { UPDATE_PROGRAM_STATUS_MUTATION } from 'server/mutations/programsMutations'
9+
import { ProgramStatusEnum } from 'types/__generated__/graphql'
10+
import { UpdateProgramStatusDocument } from 'types/__generated__/programsMutations.generated'
1011
import {
1112
GetProgramAndModulesDocument,
1213
GetProgramAndModulesQuery,
1314
} from 'types/__generated__/programsQueries.generated'
1415
import type { ExtendedSession } from 'types/auth'
15-
import { ProgramStatusEnum } from 'types/mentorship'
1616
import { formatDate } from 'utils/dateFormatter'
1717
import DetailsCard from 'components/CardDetailsPage'
1818
import LoadingSpinner from 'components/LoadingSpinner'
@@ -30,8 +30,7 @@ const ProgramDetailsPage = () => {
3030
const [modules, setModules] = useState<GetProgramAndModulesQuery['getProgramModules']>([])
3131
const [isRefetching, setIsRefetching] = useState(false)
3232

33-
// TODO: update type
34-
const [updateProgram] = useMutation(UPDATE_PROGRAM_STATUS_MUTATION, {
33+
const [updateProgram] = useMutation(UpdateProgramStatusDocument, {
3534
onError: handleAppError,
3635
})
3736

@@ -142,7 +141,7 @@ const ProgramDetailsPage = () => {
142141

143142
return (
144143
<DetailsCard
145-
modules={modules}
144+
modules={modules} //TODO: update type
146145
status={program.status}
147146
setStatus={updateStatus}
148147
canUpdateStatus={canUpdateStatus}

frontend/src/app/snapshots/[id]/page.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {
1010
GetSnapshotDetailsDocument,
1111
GetSnapshotDetailsQuery,
1212
} from 'types/__generated__/snapshotQueries.generated'
13-
import type { Chapter } from 'types/chapter'
14-
import type { Project } from 'types/project'
1513
import { level } from 'utils/data'
1614
import { formatDate } from 'utils/dateFormatter'
1715
import { getFilteredIcons, handleSocialUrls } from 'utils/utility'
@@ -40,7 +38,7 @@ const SnapshotDetailsPage: React.FC = () => {
4038
}
4139
}, [graphQLData, graphQLRequestError, snapshotKey])
4240

43-
const renderProjectCard = (project: Project) => {
41+
const renderProjectCard = (project: GetSnapshotDetailsQuery['snapshot']['newProjects'][0]) => {
4442
const params: string[] = ['forksCount', 'starsCount', 'contributorsCount']
4543
const filteredIcons = getFilteredIcons(project, params)
4644

@@ -68,7 +66,7 @@ const SnapshotDetailsPage: React.FC = () => {
6866
)
6967
}
7068

71-
const renderChapterCard = (chapter: Chapter) => {
69+
const renderChapterCard = (chapter: GetSnapshotDetailsQuery['snapshot']['newChapters'][0]) => {
7270
const params: string[] = ['updatedAt']
7371
const filteredIcons = getFilteredIcons(chapter, params)
7472
const formattedUrls = handleSocialUrls(chapter.relatedUrls)
@@ -144,23 +142,21 @@ const SnapshotDetailsPage: React.FC = () => {
144142
</div>
145143
<div className="flex flex-col gap-6">
146144
{' '}
147-
// TODO: update type
148145
{snapshot.newChapters.filter((chapter) => chapter.isActive).map(renderChapterCard)}
149146
</div>
150147
</div>
151148
)}
152149

153-
{snapshot.newProjects &&
154-
snapshot.newProjects.length > 0 && ( // TODO: update type
155-
<div className="mb-8">
156-
<h2 className="mb-4 text-2xl font-semibold text-gray-700 dark:text-gray-200">
157-
New Projects
158-
</h2>
159-
<div className="flex flex-col gap-6">
160-
{snapshot.newProjects.filter((project) => project.isActive).map(renderProjectCard)}
161-
</div>
150+
{snapshot.newProjects && snapshot.newProjects.length > 0 && (
151+
<div className="mb-8">
152+
<h2 className="mb-4 text-2xl font-semibold text-gray-700 dark:text-gray-200">
153+
New Projects
154+
</h2>
155+
<div className="flex flex-col gap-6">
156+
{snapshot.newProjects.filter((project) => project.isActive).map(renderProjectCard)}
162157
</div>
163-
)}
158+
</div>
159+
)}
164160

165161
{snapshot.newReleases && snapshot.newReleases.length > 0 && (
166162
<div className="mb-8">

frontend/src/app/snapshots/page.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
GetCommunitySnapshotsDocument,
99
GetCommunitySnapshotsQuery,
1010
} from 'types/__generated__/snapshotQueries.generated'
11-
import type { Snapshot } from 'types/snapshot'
1211
import LoadingSpinner from 'components/LoadingSpinner'
1312
import SnapshotCard from 'components/SnapshotCard'
1413

@@ -38,11 +37,11 @@ const SnapshotsPage: React.FC = () => {
3837

3938
const router = useRouter()
4039

41-
const handleButtonClick = (snapshot: Snapshot) => {
40+
const handleButtonClick = (snapshot: GetCommunitySnapshotsQuery['snapshots'][0]) => {
4241
router.push(`/snapshots/${snapshot.key}`)
4342
}
4443

45-
const renderSnapshotCard = (snapshot: Snapshot) => {
44+
const renderSnapshotCard = (snapshot: GetCommunitySnapshotsQuery['snapshots'][0]) => {
4645
const SubmitButton = {
4746
label: 'View Details',
4847
icon: <FontAwesomeIconWrapper icon="fa-solid fa-right-to-bracket" />,
@@ -54,8 +53,8 @@ const SnapshotsPage: React.FC = () => {
5453
key={snapshot.key}
5554
title={snapshot.title}
5655
button={SubmitButton}
57-
startAt={snapshot.startAt}
58-
endAt={snapshot.endAt}
56+
startAt={snapshot.startAt as string}
57+
endAt={snapshot.endAt as string}
5958
/>
6059
)
6160
}
@@ -71,11 +70,9 @@ const SnapshotsPage: React.FC = () => {
7170
{!snapshots?.length ? (
7271
<div className="col-span-full py-8 text-center">No Snapshots found</div>
7372
) : (
74-
snapshots.map(
75-
(
76-
snapshot: GetCommunitySnapshotsQuery['snapshots'][0] // TODO: update type
77-
) => <div key={snapshot.key}>{renderSnapshotCard(snapshot)}</div>
78-
)
73+
snapshots.map((snapshot: GetCommunitySnapshotsQuery['snapshots'][0]) => (
74+
<div key={snapshot.key}>{renderSnapshotCard(snapshot)}</div>
75+
))
7976
)}
8077
</div>
8178
</div>

frontend/src/utils/utility.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import relativeTime from 'dayjs/plugin/relativeTime'
44
import { twMerge } from 'tailwind-merge'
55
import { fetchCsrfToken } from 'server/fetchCsrfToken'
66

7+
import { GetSnapshotDetailsQuery } from 'types/__generated__/snapshotQueries.generated'
78
import type { Chapter } from 'types/chapter'
89
import type { Committee } from 'types/committee'
910
import type { Icon } from 'types/icon'
@@ -17,7 +18,13 @@ export function cn(...inputs: ClassValue[]) {
1718
return twMerge(clsx(inputs))
1819
}
1920

20-
type ProjectType = Project | Issue | Committee | Chapter
21+
type ProjectType =
22+
| Project
23+
| Issue
24+
| Committee
25+
| Chapter
26+
| GetSnapshotDetailsQuery['snapshot']['newChapters'][0]
27+
| GetSnapshotDetailsQuery['snapshot']['newProjects'][0]
2128

2229
export const getFilteredIcons = (project: ProjectType, params: string[]): Icon => {
2330
const filteredIcons = params.reduce((acc: Icon, key) => {

0 commit comments

Comments
 (0)