From 83b78faef0c72edc0158771ce326e02eb51e8c93 Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Sun, 8 Jun 2025 21:50:44 +0530 Subject: [PATCH 01/17] fixed backend to return camelCase --- backend/apps/core/api/algolia.py | 6 +- backend/apps/core/utils/index.py | 20 +++++ backend/poetry.lock | 16 +++- backend/pyproject.toml | 1 + frontend/src/app/contribute/page.tsx | 6 +- frontend/src/app/projects/page.tsx | 14 +-- frontend/src/components/ChapterMap.tsx | 49 ++++++----- frontend/src/components/ChapterMapWrapper.tsx | 4 +- frontend/src/server/fetchAlgoliaData.ts | 4 +- frontend/src/types/chapter.ts | 67 ++++++++------- frontend/src/types/contributor.ts | 14 +-- frontend/src/types/issue.ts | 10 +-- frontend/src/types/project.ts | 85 +++++++++++++------ frontend/src/utils/utility.ts | 17 ++-- 14 files changed, 192 insertions(+), 121 deletions(-) diff --git a/backend/apps/core/api/algolia.py b/backend/apps/core/api/algolia.py index cab33ad56b..cc45167918 100644 --- a/backend/apps/core/api/algolia.py +++ b/backend/apps/core/api/algolia.py @@ -14,7 +14,7 @@ from apps.common.index import IndexBase from apps.common.utils import get_user_ip_address -from apps.core.utils.index import get_params_for_index +from apps.core.utils.index import deep_camelize, get_params_for_index from apps.core.validators import validate_search_params CACHE_PREFIX = "algolia_proxy" @@ -58,8 +58,10 @@ def get_search_results( response = client.search(search_method_params={"requests": [search_params]}) search_result = response.results[0].to_dict() + cleaned_search_result = deep_camelize(search_result["hits"]) + return { - "hits": search_result.get("hits", []), + "hits": cleaned_search_result, "nbPages": search_result.get("nbPages", 0), } diff --git a/backend/apps/core/utils/index.py b/backend/apps/core/utils/index.py index 7a37b94dc1..fa692f6391 100644 --- a/backend/apps/core/utils/index.py +++ b/backend/apps/core/utils/index.py @@ -5,6 +5,7 @@ from algoliasearch_django import register, unregister from algoliasearch_django.registration import RegistrationError from django.apps import apps +from humps import camelize def get_params_for_index(index_name: str) -> dict: @@ -159,3 +160,22 @@ def unregister_indexes(app_names: tuple[str, ...] = ("github", "owasp")) -> None for model in apps.get_app_config(app_name).get_models(): with contextlib.suppress(RegistrationError): unregister(model) + + +def deep_camelize(obj) -> dict | list: + """Deep camelize. + + Args: + obj: The object to camelize. + + Returns: + The camelize object. + + """ + if isinstance(obj, dict): + return { + camelize(key.removeprefix("idx_")): deep_camelize(value) for key, value in obj.items() + } + if isinstance(obj, list): + return [deep_camelize(item) for item in obj] + return obj diff --git a/backend/poetry.lock b/backend/poetry.lock index 150edb4a95..8760ebcbb3 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -2223,6 +2223,18 @@ files = [ [package.extras] windows-terminal = ["colorama (>=0.4.6)"] +[[package]] +name = "pyhumps" +version = "3.8.0" +description = "🐫 Convert strings (and dictionary keys) between snake case, camel case and pascal case in Python. Inspired by Humps for Node" +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "pyhumps-3.8.0-py3-none-any.whl", hash = "sha256:060e1954d9069f428232a1adda165db0b9d8dfdce1d265d36df7fbff540acfd6"}, + {file = "pyhumps-3.8.0.tar.gz", hash = "sha256:498026258f7ee1a8e447c2e28526c0bea9407f9a59c03260aee4bd6c04d681a3"}, +] + [[package]] name = "pyjwt" version = "2.10.1" @@ -3273,4 +3285,4 @@ propcache = ">=0.2.1" [metadata] lock-version = "2.1" python-versions = "^3.13" -content-hash = "74b08acb4ffd0b2eb81f79aa7f03a92a4ecd113a770de88d4f64e2f14e81948c" +content-hash = "99fcf7b7f6b7826bd97b65324380b0c1a30867a37d24190dc92c49aa1d1509f5" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 81258e5463..507cb53076 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -51,6 +51,7 @@ slack-sdk = "^3.35.0" strawberry-graphql = {extras = ["django"], version = "^0.270.1"} thefuzz = "^0.22.1" strawberry-graphql-django = "^0.59.1" +pyhumps = "^3.8.0" [tool.poetry.group.dev.dependencies] djlint = "^1.36.4" diff --git a/frontend/src/app/contribute/page.tsx b/frontend/src/app/contribute/page.tsx index b9cee29dd3..756af6a2bd 100644 --- a/frontend/src/app/contribute/page.tsx +++ b/frontend/src/app/contribute/page.tsx @@ -28,7 +28,7 @@ const ContributePage = () => { const [modalOpenIndex, setModalOpenIndex] = useState(null) const renderContributeCard = (issue: IssueType, index: number) => { - const params: string[] = ['created_at', 'comments_count'] + const params: string[] = ['createdAt', 'commentsCount'] const filteredIcons = getFilteredIcons(issue, params) const SubmitButton = { @@ -49,8 +49,8 @@ const ContributePage = () => { key={issue.objectID} title={issue.title} url={issue.url} - projectName={issue.project_name} - projectLink={issue.project_url} + projectName={issue.projectName} + projectLink={issue.projectUrl} summary={issue.summary} icons={filteredIcons} button={SubmitButton} diff --git a/frontend/src/app/projects/page.tsx b/frontend/src/app/projects/page.tsx index cf9055f6bc..ae9f819595 100644 --- a/frontend/src/app/projects/page.tsx +++ b/frontend/src/app/projects/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { ProjectTypeAlgolia } from 'types/project' +import { ProjectBase } from 'types/project' import { level } from 'utils/data' import { sortOptionsProject } from 'utils/sortingOptions' import { getFilteredIcons } from 'utils/utility' @@ -22,7 +22,7 @@ const ProjectsPage = () => { handlePageChange, handleSortChange, handleOrderChange, - } = useSearchPage({ + } = useSearchPage({ indexName: 'projects', pageTitle: 'OWASP Projects', defaultSortBy: 'default', @@ -30,8 +30,8 @@ const ProjectsPage = () => { }) const router = useRouter() - const renderProjectCard = (project: ProjectTypeAlgolia) => { - const params: string[] = ['forks_count', 'stars_count', 'contributors_count'] + const renderProjectCard = (project: ProjectBase) => { + const params: string[] = ['forksCount', 'starsCount', 'contributorsCount'] const filteredIcons = getFilteredIcons(project, params) const handleButtonClick = () => { router.push(`/projects/${project.key}`) @@ -47,11 +47,11 @@ const ProjectsPage = () => { ) @@ -78,7 +78,7 @@ const ProjectsPage = () => { } totalPages={totalPages} > - {projects && projects.filter((project) => project.is_active).map(renderProjectCard)} + {projects && projects.filter((project) => project.isActive).map(renderProjectCard)} ) } diff --git a/frontend/src/components/ChapterMap.tsx b/frontend/src/components/ChapterMap.tsx index 3d6fa1cec3..0890f7d0c2 100644 --- a/frontend/src/components/ChapterMap.tsx +++ b/frontend/src/components/ChapterMap.tsx @@ -1,7 +1,7 @@ 'use client' import L, { MarkerClusterGroup } from 'leaflet' -import React, { useEffect, useMemo, useRef } from 'react' -import { GeoLocDataAlgolia, GeoLocDataGraphQL } from 'types/chapter' +import React, { useEffect, useRef } from 'react' +import { ChapterType } from 'types/chapter' import 'leaflet.markercluster' import 'leaflet/dist/leaflet.css' import 'leaflet.markercluster/dist/MarkerCluster.css' @@ -13,24 +13,14 @@ const ChapterMap = ({ showLocal, style, }: { - geoLocData: GeoLocDataGraphQL[] | GeoLocDataAlgolia[] + geoLocData: ChapterType[] showLocal: boolean style: React.CSSProperties }) => { const mapRef = useRef(null) const markerClusterRef = useRef(null) - const chapters = useMemo(() => { - return geoLocData.map((chapter) => ({ - lat: '_geoloc' in chapter ? chapter._geoloc.lat : chapter.geoLocation.lat, - lng: '_geoloc' in chapter ? chapter._geoloc.lng : chapter.geoLocation.lng, - key: chapter.key, - name: chapter.name, - })) - }, [geoLocData]) - useEffect(() => { - if (typeof window === 'undefined') return if (!mapRef.current) { mapRef.current = L.map('chapter-map', { worldCopyJump: false, @@ -58,7 +48,7 @@ const ChapterMap = ({ const markerClusterGroup = markerClusterRef.current - const markers = chapters.map((chapter) => { + const markers = geoLocData.map((chapter) => { const markerIcon = new L.Icon({ iconAnchor: [12, 41], iconRetinaUrl: '/img/marker-icon-2x.png', @@ -69,7 +59,13 @@ const ChapterMap = ({ shadowUrl: '/img/marker-shadow.png', }) - const marker = L.marker([chapter.lat, chapter.lng], { icon: markerIcon }) + const marker = L.marker( + [ + chapter._geoloc?.lat || chapter.geoLocation?.lat, + chapter._geoloc?.lng || chapter.geoLocation?.lng, + ], + { icon: markerIcon } + ) const popup = L.popup() const popupContent = document.createElement('div') popupContent.className = 'popup-content' @@ -84,16 +80,27 @@ const ChapterMap = ({ markerClusterGroup.addLayers(markers) - if (showLocal && chapters.length > 0) { + if (showLocal && geoLocData.length > 0) { const maxNearestChapters = 5 - const localChapters = chapters.slice(0, maxNearestChapters - 1) - const localBounds = L.latLngBounds(localChapters.map((ch) => [ch.lat, ch.lng])) + const localChapters = geoLocData.slice(0, maxNearestChapters - 1) + const localBounds = L.latLngBounds( + localChapters.map((chapter) => [ + chapter._geoloc?.lat || chapter.geoLocation?.lat, + chapter._geoloc?.lng || chapter.geoLocation?.lng, + ]) + ) const maxZoom = 7 - const nearestChapter = chapters[0] - map.setView([nearestChapter.lat, nearestChapter.lng], maxZoom) + const nearestChapter = geoLocData[0] + map.setView( + [ + nearestChapter._geoloc?.lat || nearestChapter.geoLocation?.lat, + nearestChapter._geoloc?.lng || nearestChapter.geoLocation?.lng, + ], + maxZoom + ) map.fitBounds(localBounds, { maxZoom: maxZoom }) } - }, [chapters, showLocal]) + }, [geoLocData, showLocal]) return
} diff --git a/frontend/src/components/ChapterMapWrapper.tsx b/frontend/src/components/ChapterMapWrapper.tsx index 0f7a27dfe3..ad26fe4315 100644 --- a/frontend/src/components/ChapterMapWrapper.tsx +++ b/frontend/src/components/ChapterMapWrapper.tsx @@ -1,11 +1,11 @@ import dynamic from 'next/dynamic' import React from 'react' -import { GeoLocDataAlgolia, GeoLocDataGraphQL } from 'types/chapter' +import { ChapterType } from 'types/chapter' const ChapterMap = dynamic(() => import('./ChapterMap'), { ssr: false }) const ChapterMapWrapper = (props: { - geoLocData: GeoLocDataGraphQL[] | GeoLocDataAlgolia[] + geoLocData: ChapterType[] showLocal: boolean style: React.CSSProperties }) => { diff --git a/frontend/src/server/fetchAlgoliaData.ts b/frontend/src/server/fetchAlgoliaData.ts index 1a33561fe2..a02cd2e3a7 100644 --- a/frontend/src/server/fetchAlgoliaData.ts +++ b/frontend/src/server/fetchAlgoliaData.ts @@ -1,5 +1,4 @@ import { AppError } from 'app/global-error' -import { IndexedObject, removeIdxPrefix } from 'server/utility' import { AlgoliaResponseType } from 'types/algolia' import { IDX_URL } from 'utils/credentials' import { getCsrfToken } from 'utils/utility' @@ -43,10 +42,9 @@ export const fetchAlgoliaData = async ( const results = await response.json() if (results && results.hits.length > 0) { const { hits, nbPages } = results - const cleanedHits = hits.map((hit: IndexedObject) => removeIdxPrefix(hit)) as T[] return { - hits: cleanedHits, + hits: hits, totalPages: nbPages || 0, } } else { diff --git a/frontend/src/types/chapter.ts b/frontend/src/types/chapter.ts index a11bbd90fd..827a636441 100644 --- a/frontend/src/types/chapter.ts +++ b/frontend/src/types/chapter.ts @@ -2,53 +2,54 @@ import { TopContributorsTypeAlgolia } from 'types/contributor' export interface ChapterDataType { active_committees_count: number - chapters: ChapterTypeAlgolia[] + chapters: ChapterType[] total_pages: number } -export interface ChapterTypeAlgolia { - _geoloc: { lat: number; lng: number } - created_at: number - is_active: boolean +export interface ChapterType { + _geoloc?: { lat: number; lng: number } + geoLocation?: { lat: number; lng: number } + createdAt: number + isActive: boolean key: string leaders: string[] name: string objectID: string region: string - related_urls: string[] - summary: string - suggested_location: string - top_contributors: TopContributorsTypeAlgolia[] - updated_at: number - url: string -} - -export interface ChapterTypeGraphQL { - geoLocation: GeoLocation - isActive: boolean - key: string - name: string - region: string relatedUrls: string[] summary: string suggestedLocation: string + topContributors: TopContributorsTypeAlgolia[] updatedAt: number url: string } -export interface GeoLocation { - lat: number - lng: number -} +// export interface ChapterTypeGraphQL { +// geoLocation: GeoLocation +// isActive: boolean +// key: string +// name: string +// region: string +// relatedUrls: string[] +// summary: string +// suggestedLocation: string +// updatedAt: number +// url: string +// } -export interface GeoLocDataAlgolia { - _geoloc: { lat: number; lng: number } - key: string - name: string -} +// export interface GeoLocation { +// lat: number +// lng: number +// } -export interface GeoLocDataGraphQL { - geoLocation: GeoLocation - key: string - name: string -} +// export interface GeoLocDataAlgolia { +// _geoloc: { lat: number; lng: number } +// key: string +// name: string +// } + +// export interface GeoLocDataGraphQL { +// geoLocation: { lat: number; lng: number } +// key: string +// name: string +// } diff --git a/frontend/src/types/contributor.ts b/frontend/src/types/contributor.ts index 928f97605f..f2b03cf545 100644 --- a/frontend/src/types/contributor.ts +++ b/frontend/src/types/contributor.ts @@ -1,11 +1,11 @@ -export type TopContributorsTypeAlgolia = { - avatar_url: string - contributions_count: number - login: string - name: string -} +// export type TopContributors = { +// avatarUrl: string +// contributionsCount: number +// login: string +// name: string +// } -export type TopContributorsTypeGraphql = { +export type TopContributorsType = { avatarUrl: string contributionsCount: number login: string diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts index 65c1ed79a0..f78e8b7b39 100644 --- a/frontend/src/types/issue.ts +++ b/frontend/src/types/issue.ts @@ -5,15 +5,15 @@ export interface IssuesDataType { } export interface IssueType { - created_at: number + createdAt: number hint: string labels: string[] - project_name: string - project_url: string - repository_languages: string[] + projectName: string + projectUrl: string + repositoryLanguages: string[] summary: string title: string - updated_at: number + updatedAt: number url: string objectID: string } diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts index 81e1156d0e..9f41110254 100644 --- a/frontend/src/types/project.ts +++ b/frontend/src/types/project.ts @@ -1,9 +1,9 @@ -import { TopContributorsTypeAlgolia, TopContributorsTypeGraphql } from 'types/contributor' +import { TopContributorsType } from 'types/contributor' export interface ProjectDataType { active_projects_count: number total_pages: number - projects: ProjectTypeAlgolia[] + projects: ProjectBase[] } export interface ProjectIssuesType { @@ -56,31 +56,9 @@ export interface ProjectStatsType { stars: number } -export interface ProjectTypeAlgolia { - contributors_count: number - description: string - forks_count: number - is_active: boolean - issues_count: number - key: string - languages: string[] - leaders: string[] - level: string - name: string - objectID: string - organizations: string - repositories_count: number - stars_count: number - summary: string - topics: string[] - top_contributors: TopContributorsTypeAlgolia[] - type: string - updated_at: number - url: string -} - -export interface ProjectTypeGraphql { +export interface ProjectBase { contributorsCount: number + description: string forksCount: number isActive: boolean issuesCount: number @@ -89,21 +67,74 @@ export interface ProjectTypeGraphql { leaders: string[] level: string name: string + organizations: string repositoriesCount: number starsCount: number summary: string topics: string[] + topContributors: TopContributorsType[] type: string updatedAt: number url: string +} + +export interface ProjectTypeGraphql extends ProjectBase { recentIssues: ProjectIssuesType[] recentPullRequests: ProjectPullRequestsType[] recentReleases: ProjectReleaseType[] repositories: RepositoryCardProps[] - topContributors: TopContributorsTypeGraphql[] + topContributors: TopContributorsType[] recentMilestones: ProjectMilestonesType[] } +// export interface ProjectType{ +// contributorsCount: number +// description: string +// forksCount: number +// isActive: boolean +// issuesCount: number +// key: string +// languages: string[] +// leaders: string[] +// level: string +// name: string +// objectID: string +// organizations: string +// repositoriesCount: number +// starsCount: number +// summary: string +// topics: string[] +// topContributors: TopContributorsType[] +// type: string +// updatedAt: number +// url: string +// } + +// export interface ProjectTypeGraphql { +// contributorsCount: number +// forksCount: number +// isActive: boolean +// issuesCount: number +// key: string +// languages: string[] +// leaders: string[] +// level: string +// name: string +// repositoriesCount: number +// starsCount: number +// summary: string +// topics: string[] +// type: string +// updatedAt: number +// url: string +// recentIssues: ProjectIssuesType[] +// recentPullRequests: ProjectPullRequestsType[] +// recentReleases: ProjectReleaseType[] +// repositories: RepositoryCardProps[] +// topContributors: TopContributorsTypeGraphql[] +// recentMilestones: ProjectMilestonesType[] +// } + export interface RepositoriesCardProps { repositories: RepositoryCardProps[] } diff --git a/frontend/src/utils/utility.ts b/frontend/src/utils/utility.ts index d0648da437..8af6a5377e 100644 --- a/frontend/src/utils/utility.ts +++ b/frontend/src/utils/utility.ts @@ -3,12 +3,11 @@ import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' import { twMerge } from 'tailwind-merge' import { fetchCsrfToken } from 'server/fetchCsrfToken' -import { ChapterTypeGraphQL } from 'types/chapter' import { CommitteeTypeAlgolia } from 'types/committee' import { IconType } from 'types/icon' import { IssueType } from 'types/issue' -import { ProjectTypeAlgolia, ProjectTypeGraphql } from 'types/project' +import { ProjectBase, ProjectTypeGraphql } from 'types/project' import { IconKeys, Icons, urlMappings } from 'utils/data' dayjs.extend(relativeTime) @@ -17,15 +16,15 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } -type projectType = ProjectTypeAlgolia | IssueType | CommitteeTypeAlgolia +type projectType = ProjectBase | IssueType | CommitteeTypeAlgolia export const getFilteredIcons = (project: projectType, params: string[]): IconType => { const filteredIcons = params.reduce((acc: IconType, key) => { if (Icons[key as IconKeys] && project[key as keyof typeof project] !== undefined) { - if (key === 'created_at') { - acc[key] = dayjs.unix(project[key as keyof projectType] as number).fromNow() + if (key === 'createdAt') { + acc[key] = dayjs.unix(project[key as keyof projectType] as unknown as number).fromNow() } else { - acc[key] = project[key as keyof typeof project] as number + acc[key] = project[key as keyof typeof project] as unknown as number } } return acc @@ -35,15 +34,15 @@ export const getFilteredIcons = (project: projectType, params: string[]): IconTy } export const getFilteredIconsGraphql = ( - project: ProjectTypeGraphql | ChapterTypeGraphQL, + project: ProjectTypeGraphql, params: string[] ): IconType => { const filteredIcons = params.reduce((acc: IconType, key) => { if (Icons[key as IconKeys] && project[key as keyof typeof project] !== undefined) { if (key === 'createdAt') { - acc[key] = dayjs.unix(project[key as keyof projectType] as number).fromNow() + acc[key] = dayjs.unix(project[key as keyof projectType] as unknown as number).fromNow() } else { - acc[key] = project[key as keyof typeof project] as number + acc[key] = project[key as keyof typeof project] as unknown as number } } return acc From a483358057c07ddf38bb438cabeb9624af0eb555 Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Sun, 8 Jun 2025 23:43:32 +0530 Subject: [PATCH 02/17] fixed types for chapters, committees, members and organizations --- frontend/src/app/chapters/page.tsx | 18 +++---- frontend/src/app/committees/page.tsx | 12 ++--- frontend/src/app/members/page.tsx | 6 +-- frontend/src/app/organizations/page.tsx | 12 ++--- frontend/src/types/chapter.ts | 4 +- frontend/src/types/committee.ts | 65 ++++++++++++++++--------- frontend/src/types/organization.ts | 14 +++--- frontend/src/types/user.ts | 40 ++++++--------- frontend/src/utils/utility.ts | 5 +- 9 files changed, 95 insertions(+), 81 deletions(-) diff --git a/frontend/src/app/chapters/page.tsx b/frontend/src/app/chapters/page.tsx index 10118d1413..a6488ccb06 100644 --- a/frontend/src/app/chapters/page.tsx +++ b/frontend/src/app/chapters/page.tsx @@ -5,14 +5,14 @@ import { useEffect, useState } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { fetchAlgoliaData } from 'server/fetchAlgoliaData' import { AlgoliaResponseType } from 'types/algolia' -import { ChapterTypeAlgolia } from 'types/chapter' +import { ChapterType } from 'types/chapter' import { getFilteredIcons, handleSocialUrls } from 'utils/utility' import Card from 'components/Card' import ChapterMapWrapper from 'components/ChapterMapWrapper' import SearchPageLayout from 'components/SearchPageLayout' const ChaptersPage = () => { - const [geoLocData, setGeoLocData] = useState([]) + const [geoLocData, setGeoLocData] = useState([]) const { items: chapters, isLoaded, @@ -21,7 +21,7 @@ const ChaptersPage = () => { searchQuery, handleSearch, handlePageChange, - } = useSearchPage({ + } = useSearchPage({ indexName: 'chapters', pageTitle: 'OWASP Chapters', }) @@ -34,7 +34,7 @@ const ChaptersPage = () => { currentPage, hitsPerPage: currentPage === 1 ? 1000 : 25, } - const data: AlgoliaResponseType = await fetchAlgoliaData( + const data: AlgoliaResponseType = await fetchAlgoliaData( searchParams.indexName, searchParams.query, searchParams.currentPage, @@ -46,10 +46,10 @@ const ChaptersPage = () => { }, [currentPage]) const router = useRouter() - const renderChapterCard = (chapter: ChapterTypeAlgolia) => { - const params: string[] = ['updated_at'] + const renderChapterCard = (chapter: ChapterType) => { + const params: string[] = ['updatedAt'] const filteredIcons = getFilteredIcons(chapter, params) - const formattedUrls = handleSocialUrls(chapter.related_urls) + const formattedUrls = handleSocialUrls(chapter.relatedUrls) const handleButtonClick = () => { router.push(`/chapters/${chapter.key}`) @@ -68,7 +68,7 @@ const ChaptersPage = () => { url={`/chapters/${chapter.key}`} summary={chapter.summary} icons={filteredIcons} - topContributors={chapter.top_contributors} + topContributors={chapter.topContributors} button={SubmitButton} social={formattedUrls} /> @@ -100,7 +100,7 @@ const ChaptersPage = () => { }} /> )} - {chapters && chapters.filter((chapter) => chapter.is_active).map(renderChapterCard)} + {chapters && chapters.filter((chapter) => chapter.isActive).map(renderChapterCard)} ) } diff --git a/frontend/src/app/committees/page.tsx b/frontend/src/app/committees/page.tsx index 0f2dadec6e..651420d2e2 100644 --- a/frontend/src/app/committees/page.tsx +++ b/frontend/src/app/committees/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { CommitteeTypeAlgolia } from 'types/committee' +import { CommitteeBase } from 'types/committee' import { getFilteredIcons, handleSocialUrls } from 'utils/utility' import Card from 'components/Card' import SearchPageLayout from 'components/SearchPageLayout' @@ -16,15 +16,15 @@ const CommitteesPage = () => { searchQuery, handleSearch, handlePageChange, - } = useSearchPage({ + } = useSearchPage({ indexName: 'committees', pageTitle: 'OWASP Committees', }) const router = useRouter() - const renderCommitteeCard = (committee: CommitteeTypeAlgolia) => { - const params: string[] = ['updated_at'] + const renderCommitteeCard = (committee: CommitteeBase) => { + const params: string[] = ['updatedAt'] const filteredIcons = getFilteredIcons(committee, params) - const formattedUrls = handleSocialUrls(committee.related_urls) + const formattedUrls = handleSocialUrls(committee.relatedUrls) const handleButtonClick = () => { router.push(`/committees/${committee.key}`) } @@ -42,7 +42,7 @@ const CommitteesPage = () => { url={`/committees/${committee.key}`} summary={committee.summary} icons={filteredIcons} - topContributors={committee.top_contributors} + topContributors={committee.topContributors} button={SubmitButton} social={formattedUrls} tooltipLabel={`Learn more about ${committee.name}`} diff --git a/frontend/src/app/members/page.tsx b/frontend/src/app/members/page.tsx index 5fb910ea55..bd2764e424 100644 --- a/frontend/src/app/members/page.tsx +++ b/frontend/src/app/members/page.tsx @@ -36,14 +36,14 @@ const UsersPage = () => { return ( ) diff --git a/frontend/src/app/organizations/page.tsx b/frontend/src/app/organizations/page.tsx index 147f24228d..c44c5b6463 100644 --- a/frontend/src/app/organizations/page.tsx +++ b/frontend/src/app/organizations/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { OrganizationTypeAlgolia } from 'types/organization' +import { Organization } from 'types/organization' import SearchPageLayout from 'components/SearchPageLayout' import UserCard from 'components/UserCard' @@ -15,7 +15,7 @@ const OrganizationPage = () => { searchQuery, handleSearch, handlePageChange, - } = useSearchPage({ + } = useSearchPage({ indexName: 'organizations', pageTitle: 'GitHub Organizations', hitsPerPage: 24, @@ -23,7 +23,7 @@ const OrganizationPage = () => { const router = useRouter() - const renderOrganizationCard = (organization: OrganizationTypeAlgolia) => { + const renderOrganizationCard = (organization: Organization) => { const handleButtonClick = () => { router.push(`/organizations/${organization.login}`) } @@ -36,15 +36,15 @@ const OrganizationPage = () => { return ( ) diff --git a/frontend/src/types/chapter.ts b/frontend/src/types/chapter.ts index 827a636441..7751319429 100644 --- a/frontend/src/types/chapter.ts +++ b/frontend/src/types/chapter.ts @@ -1,4 +1,4 @@ -import { TopContributorsTypeAlgolia } from 'types/contributor' +import { TopContributorsType } from 'types/contributor' export interface ChapterDataType { active_committees_count: number @@ -19,7 +19,7 @@ export interface ChapterType { relatedUrls: string[] summary: string suggestedLocation: string - topContributors: TopContributorsTypeAlgolia[] + topContributors: TopContributorsType[] updatedAt: number url: string } diff --git a/frontend/src/types/committee.ts b/frontend/src/types/committee.ts index c8928d33b3..6a9e37f39d 100644 --- a/frontend/src/types/committee.ts +++ b/frontend/src/types/committee.ts @@ -1,41 +1,62 @@ -import { TopContributorsTypeGraphql } from 'types/contributor' +import { TopContributorsType } from 'types/contributor' -export interface CommitteeTypeAlgolia { - created_at: number +// export interface CommitteeTypeAlgolia { +// created_at: number +// key: string +// leaders: string[] +// name: string +// related_urls: string[] +// top_contributors: { +// avatar_url: string +// contributions_count: number +// login: string +// name: string +// }[] +// summary: string +// updated_at: number +// url: string +// objectID: string +// } + +export interface CommitteeBase { + createdAt: number key: string leaders: string[] name: string - related_urls: string[] - top_contributors: { - avatar_url: string - contributions_count: number - login: string - name: string - }[] + objectID?: string + relatedUrls: string[] + topContributors: TopContributorsType[] summary: string - updated_at: number + updatedAt: number url: string - objectID: string } -export interface CommitteeDetailsTypeGraphQL { +export interface CommitteeDetailsType extends CommitteeBase { contributorsCount: number - createdAt: number forksCount: number issuesCount: number - leaders: string[] - name: string - relatedUrls: string[] starsCount: number - topContributors: TopContributorsTypeGraphql[] repositoriesCount: number - summary: string - updatedAt: number - url: string } +// export interface CommitteeDetailsTypeGraphQL { +// contributorsCount: number +// createdAt: number +// forksCount: number +// issuesCount: number +// leaders: string[] +// name: string +// relatedUrls: string[] +// starsCount: number +// topContributors: TopContributorsTypeGraphql[] +// repositoriesCount: number +// summary: string +// updatedAt: number +// url: string +// } + export interface CommitteeDataType { active_committees_count: number - committees: CommitteeTypeAlgolia[] + committees: CommitteeBase[] total_pages: number } diff --git a/frontend/src/types/organization.ts b/frontend/src/types/organization.ts index 871f6ffb70..c4b969b225 100644 --- a/frontend/src/types/organization.ts +++ b/frontend/src/types/organization.ts @@ -1,17 +1,17 @@ -export interface OrganizationTypeAlgolia { - avatar_url: string - collaborators_count: number +export interface Organization { + avatarUrl: string + collaboratorsCount: number company?: string - created_at: number + createdAt: number description?: string email?: string - followers_count: number + followersCount: number key: string location?: string login: string name: string objectID: string - public_repositories_count: number - updated_at: number + publicRepositoriesCount: number + updatedAt: number url: string } diff --git a/frontend/src/types/user.ts b/frontend/src/types/user.ts index 5b90198253..ca88ef55a1 100644 --- a/frontend/src/types/user.ts +++ b/frontend/src/types/user.ts @@ -39,46 +39,38 @@ export type Release = { url: string } -export type User = { - avatar_url: string +export interface UserBase { + createdAt: T + avatarUrl: string bio?: string | null company?: string | null - created_at: number email?: string | null - followers_count: number - following_count: number + followersCount: number + followingCount: number issues?: Issue[] - issues_count?: number + issuesCount?: number key: string location?: string | null login: string name?: string | null - public_repositories_count: number + publicRepositoriesCount: number releases?: Release[] - releases_count?: number + releasesCount?: number url: string - contributions_count: number + contributionsCount: number } -export interface UserDetailsProps { - avatarUrl: string - bio: string | null - company: string | null - createdAt: string - email: string | null - followersCount: number - followingCount: number - issues?: Issue[] +export type User = UserBase + +export interface UserDetailsProps extends UserBase { issuesCount: number + releasesCount: number location: string | null - login: string + company: string | null + bio: string | null + email: string | null name: string | null - publicRepositoriesCount: number - releases?: Release[] - releasesCount: number topRepositories: RepositoryCardProps[] - url: string - contributionsCount: number } export interface PullRequestsType { diff --git a/frontend/src/utils/utility.ts b/frontend/src/utils/utility.ts index 8af6a5377e..b6fbd32a85 100644 --- a/frontend/src/utils/utility.ts +++ b/frontend/src/utils/utility.ts @@ -4,7 +4,8 @@ import relativeTime from 'dayjs/plugin/relativeTime' import { twMerge } from 'tailwind-merge' import { fetchCsrfToken } from 'server/fetchCsrfToken' -import { CommitteeTypeAlgolia } from 'types/committee' +import { ChapterType } from 'types/chapter' +import { CommitteeBase } from 'types/committee' import { IconType } from 'types/icon' import { IssueType } from 'types/issue' import { ProjectBase, ProjectTypeGraphql } from 'types/project' @@ -16,7 +17,7 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } -type projectType = ProjectBase | IssueType | CommitteeTypeAlgolia +type projectType = ProjectBase | IssueType | CommitteeBase | ChapterType export const getFilteredIcons = (project: projectType, params: string[]): IconType => { const filteredIcons = params.reduce((acc: IconType, key) => { From 1c1d4b199319ce6efd096892d7412f4bd0e65788 Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Mon, 9 Jun 2025 00:09:57 +0530 Subject: [PATCH 03/17] fixed types for all pages --- frontend/src/app/about/page.tsx | 8 ++++---- frontend/src/app/chapters/[chapterKey]/page.tsx | 8 ++++---- frontend/src/app/committees/[committeeKey]/page.tsx | 8 ++++---- .../repositories/[repositoryKey]/page.tsx | 4 ++-- frontend/src/app/page.tsx | 6 +++--- frontend/src/app/projects/[projectKey]/page.tsx | 8 ++++---- frontend/src/app/snapshots/[id]/page.tsx | 8 ++++---- frontend/src/types/project.ts | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/frontend/src/app/about/page.tsx b/frontend/src/app/about/page.tsx index cb909c5da0..9063621b25 100644 --- a/frontend/src/app/about/page.tsx +++ b/frontend/src/app/about/page.tsx @@ -20,8 +20,8 @@ import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_PROJECT_METADATA, GET_TOP_CONTRIBUTORS } from 'server/queries/projectQueries' import { GET_LEADER_DATA } from 'server/queries/userQueries' -import { TopContributorsTypeGraphql } from 'types/contributor' -import { ProjectTypeGraphql } from 'types/project' +import { TopContributorsType } from 'types/contributor' +import { ProjectType } from 'types/project' import { User } from 'types/user' import { aboutText, technologies } from 'utils/aboutData' import AnchorTitle from 'components/AnchorTitle' @@ -54,8 +54,8 @@ const About = () => { } ) - const [projectMetadata, setProjectMetadata] = useState(null) - const [topContributors, setTopContributors] = useState([]) + const [projectMetadata, setProjectMetadata] = useState(null) + const [topContributors, setTopContributors] = useState([]) useEffect(() => { if (projectMetadataResponse?.project) { diff --git a/frontend/src/app/chapters/[chapterKey]/page.tsx b/frontend/src/app/chapters/[chapterKey]/page.tsx index 371f31f80a..d691106913 100644 --- a/frontend/src/app/chapters/[chapterKey]/page.tsx +++ b/frontend/src/app/chapters/[chapterKey]/page.tsx @@ -5,16 +5,16 @@ import { useParams } from 'next/navigation' import { useState, useEffect } from 'react' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_CHAPTER_DATA } from 'server/queries/chapterQueries' -import { ChapterTypeGraphQL } from 'types/chapter' -import { TopContributorsTypeGraphql } from 'types/contributor' +import { ChapterType } from 'types/chapter' +import { TopContributorsType } from 'types/contributor' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' import LoadingSpinner from 'components/LoadingSpinner' export default function ChapterDetailsPage() { const { chapterKey } = useParams() - const [chapter, setChapter] = useState({} as ChapterTypeGraphQL) - const [topContributors, setTopContributors] = useState([]) + const [chapter, setChapter] = useState({} as ChapterType) + const [topContributors, setTopContributors] = useState([]) const [isLoading, setIsLoading] = useState(true) const { data, error: graphQLRequestError } = useQuery(GET_CHAPTER_DATA, { diff --git a/frontend/src/app/committees/[committeeKey]/page.tsx b/frontend/src/app/committees/[committeeKey]/page.tsx index 9307454d94..184fcf6955 100644 --- a/frontend/src/app/committees/[committeeKey]/page.tsx +++ b/frontend/src/app/committees/[committeeKey]/page.tsx @@ -12,15 +12,15 @@ import { useParams } from 'next/navigation' import { useState, useEffect } from 'react' import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_COMMITTEE_DATA } from 'server/queries/committeeQueries' -import type { CommitteeDetailsTypeGraphQL } from 'types/committee' -import { TopContributorsTypeGraphql } from 'types/contributor' +import { CommitteeDetailsType } from 'types/committee' +import { TopContributorsType } from 'types/contributor' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' import LoadingSpinner from 'components/LoadingSpinner' export default function CommitteeDetailsPage() { const { committeeKey } = useParams<{ committeeKey: string }>() - const [committee, setCommittee] = useState(null) - const [topContributors, setTopContributors] = useState([]) + const [committee, setCommittee] = useState(null) + const [topContributors, setTopContributors] = useState([]) const [isLoading, setIsLoading] = useState(true) const { data, error: graphQLRequestError } = useQuery(GET_COMMITTEE_DATA, { diff --git a/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx b/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx index cb416b49ac..1881f6ec8e 100644 --- a/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx +++ b/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx @@ -13,7 +13,7 @@ import { useParams } from 'next/navigation' import { useEffect, useState } from 'react' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_REPOSITORY_DATA } from 'server/queries/repositoryQueries' -import { TopContributorsTypeGraphql } from 'types/contributor' +import { TopContributorsType } from 'types/contributor' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' import LoadingSpinner from 'components/LoadingSpinner' @@ -21,7 +21,7 @@ import LoadingSpinner from 'components/LoadingSpinner' const RepositoryDetailsPage = () => { const { repositoryKey, organizationKey } = useParams() const [repository, setRepository] = useState(null) - const [topContributors, setTopContributors] = useState([]) + const [topContributors, setTopContributors] = useState([]) const [recentPullRequests, setRecentPullRequests] = useState(null) const [isLoading, setIsLoading] = useState(true) const { data, error: graphQLRequestError } = useQuery(GET_REPOSITORY_DATA, { diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index ec766d89a2..8822759cbb 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -22,7 +22,7 @@ import { useEffect, useState } from 'react' import { fetchAlgoliaData } from 'server/fetchAlgoliaData' import { GET_MAIN_PAGE_DATA } from 'server/queries/homeQueries' import { AlgoliaResponseType } from 'types/algolia' -import { ChapterTypeAlgolia } from 'types/chapter' +import { ChapterType } from 'types/chapter' import { EventType } from 'types/event' import { MainPageData } from 'types/home' import { capitalize } from 'utils/capitalize' @@ -50,7 +50,7 @@ export default function Home() { variables: { distinct: true }, }) - const [geoLocData, setGeoLocData] = useState([]) + const [geoLocData, setGeoLocData] = useState([]) const [modalOpenIndex, setModalOpenIndex] = useState(null) useEffect(() => { @@ -79,7 +79,7 @@ export default function Home() { currentPage: 1, hitsPerPage: 1000, } - const data: AlgoliaResponseType = await fetchAlgoliaData( + const data: AlgoliaResponseType = await fetchAlgoliaData( searchParams.indexName, searchParams.query, searchParams.currentPage, diff --git a/frontend/src/app/projects/[projectKey]/page.tsx b/frontend/src/app/projects/[projectKey]/page.tsx index c69beeaa85..e061f4479d 100644 --- a/frontend/src/app/projects/[projectKey]/page.tsx +++ b/frontend/src/app/projects/[projectKey]/page.tsx @@ -12,8 +12,8 @@ import { useParams } from 'next/navigation' import { useState, useEffect } from 'react' import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_PROJECT_DATA } from 'server/queries/projectQueries' -import { TopContributorsTypeGraphql } from 'types/contributor' -import { ProjectTypeGraphql } from 'types/project' +import { TopContributorsType } from 'types/contributor' +import { ProjectType } from 'types/project' import { capitalize } from 'utils/capitalize' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' @@ -21,8 +21,8 @@ import LoadingSpinner from 'components/LoadingSpinner' const ProjectDetailsPage = () => { const { projectKey } = useParams() const [isLoading, setIsLoading] = useState(true) - const [project, setProject] = useState(null) - const [topContributors, setTopContributors] = useState([]) + const [project, setProject] = useState(null) + const [topContributors, setTopContributors] = useState([]) const { data, error: graphQLRequestError } = useQuery(GET_PROJECT_DATA, { variables: { key: projectKey }, }) diff --git a/frontend/src/app/snapshots/[id]/page.tsx b/frontend/src/app/snapshots/[id]/page.tsx index 65d3e82af3..cc535f66b8 100644 --- a/frontend/src/app/snapshots/[id]/page.tsx +++ b/frontend/src/app/snapshots/[id]/page.tsx @@ -7,8 +7,8 @@ import React, { useState, useEffect } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_SNAPSHOT_DETAILS } from 'server/queries/snapshotQueries' -import { ChapterTypeGraphQL } from 'types/chapter' -import { ProjectTypeGraphql } from 'types/project' +import { ChapterType } from 'types/chapter' +import { ProjectType } from 'types/project' import { SnapshotDetailsProps } from 'types/snapshot' import { level } from 'utils/data' import { formatDate } from 'utils/dateFormatter' @@ -38,7 +38,7 @@ const SnapshotDetailsPage: React.FC = () => { } }, [graphQLData, graphQLRequestError, snapshotKey]) - const renderProjectCard = (project: ProjectTypeGraphql) => { + const renderProjectCard = (project: ProjectType) => { const params: string[] = ['forksCount', 'starsCount', 'contributorsCount'] const filteredIcons = getFilteredIconsGraphql(project, params) @@ -66,7 +66,7 @@ const SnapshotDetailsPage: React.FC = () => { ) } - const renderChapterCard = (chapter: ChapterTypeGraphQL) => { + const renderChapterCard = (chapter: ChapterType) => { const params: string[] = ['updatedAt'] const filteredIcons = getFilteredIconsGraphql(chapter, params) const formattedUrls = handleSocialUrls(chapter.relatedUrls) diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts index 9f41110254..56bf8ed794 100644 --- a/frontend/src/types/project.ts +++ b/frontend/src/types/project.ts @@ -78,7 +78,7 @@ export interface ProjectBase { url: string } -export interface ProjectTypeGraphql extends ProjectBase { +export interface ProjectType extends ProjectBase { recentIssues: ProjectIssuesType[] recentPullRequests: ProjectPullRequestsType[] recentReleases: ProjectReleaseType[] From 1e3be201810e7d009334937a04634541a687f875 Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Mon, 9 Jun 2025 01:55:11 +0530 Subject: [PATCH 04/17] fixed types of all the pages, component, utility, types --- .../src/app/chapters/[chapterKey]/page.tsx | 4 +- frontend/src/app/members/page.tsx | 4 +- frontend/src/app/organizations/page.tsx | 4 +- .../src/app/projects/[projectKey]/page.tsx | 2 +- frontend/src/app/snapshots/[id]/page.tsx | 6 +- frontend/src/components/CardDetailsPage.tsx | 6 +- frontend/src/components/ContributorAvatar.tsx | 20 ++--- frontend/src/components/MultiSearch.tsx | 30 +++---- frontend/src/components/TopContributors.tsx | 4 +- frontend/src/components/UserCard.tsx | 12 +-- frontend/src/server/utility.ts | 14 ---- frontend/src/types/card.ts | 16 ++-- frontend/src/types/chapter.ts | 50 ++++-------- frontend/src/types/committee.ts | 40 ---------- frontend/src/types/contributor.ts | 9 +-- frontend/src/types/home.ts | 4 +- frontend/src/types/project.ts | 80 +++---------------- frontend/src/types/search.ts | 13 +-- frontend/src/types/snapshot.ts | 8 +- frontend/src/utils/logger.ts | 28 ------- frontend/src/utils/utility.ts | 20 +---- 21 files changed, 86 insertions(+), 288 deletions(-) delete mode 100644 frontend/src/server/utility.ts delete mode 100644 frontend/src/utils/logger.ts diff --git a/frontend/src/app/chapters/[chapterKey]/page.tsx b/frontend/src/app/chapters/[chapterKey]/page.tsx index d691106913..a82d327a94 100644 --- a/frontend/src/app/chapters/[chapterKey]/page.tsx +++ b/frontend/src/app/chapters/[chapterKey]/page.tsx @@ -62,8 +62,8 @@ export default function ChapterDetailsPage() { return ( { button={SubmitButton} company={user.company || ''} email={user.email || ''} - followers_count={user.followersCount} + followersCount={user.followersCount} location={user.location || ''} name={user.name || `@${user.login}`} - repositories_count={user.publicRepositoriesCount} + repositoriesCount={user.publicRepositoriesCount} className="h-64 w-80 bg-white p-6 text-left shadow-lg transition-transform duration-500 hover:scale-105 hover:shadow-xl dark:bg-gray-800 dark:shadow-gray-900/30" /> ) diff --git a/frontend/src/app/organizations/page.tsx b/frontend/src/app/organizations/page.tsx index c44c5b6463..c4cd7cad7c 100644 --- a/frontend/src/app/organizations/page.tsx +++ b/frontend/src/app/organizations/page.tsx @@ -40,11 +40,11 @@ const OrganizationPage = () => { button={SubmitButton} company={organization.company || ''} email={organization.email || ''} - followers_count={organization.followersCount} + followersCount={organization.followersCount} key={organization.objectID} location={organization.location || `@${organization.login}`} name={organization.name} - repositories_count={organization.publicRepositoriesCount} + repositoriesCount={organization.publicRepositoriesCount} className="h-64 w-80 bg-white p-6 text-left shadow-lg transition-transform duration-500 hover:scale-105 hover:shadow-xl dark:bg-gray-800 dark:shadow-gray-900/30" /> ) diff --git a/frontend/src/app/projects/[projectKey]/page.tsx b/frontend/src/app/projects/[projectKey]/page.tsx index e061f4479d..7aa0fe2cf1 100644 --- a/frontend/src/app/projects/[projectKey]/page.tsx +++ b/frontend/src/app/projects/[projectKey]/page.tsx @@ -91,7 +91,7 @@ const ProjectDetailsPage = () => { return ( { const renderProjectCard = (project: ProjectType) => { const params: string[] = ['forksCount', 'starsCount', 'contributorsCount'] - const filteredIcons = getFilteredIconsGraphql(project, params) + const filteredIcons = getFilteredIcons(project, params) const handleButtonClick = () => { router.push(`/projects/${project.key}`) @@ -68,7 +68,7 @@ const SnapshotDetailsPage: React.FC = () => { const renderChapterCard = (chapter: ChapterType) => { const params: string[] = ['updatedAt'] - const filteredIcons = getFilteredIconsGraphql(chapter, params) + const filteredIcons = getFilteredIcons(chapter, params) const formattedUrls = handleSocialUrls(chapter.relatedUrls) const handleButtonClick = () => { diff --git a/frontend/src/components/CardDetailsPage.tsx b/frontend/src/components/CardDetailsPage.tsx index 95fd57f8da..923b4b9e88 100644 --- a/frontend/src/components/CardDetailsPage.tsx +++ b/frontend/src/components/CardDetailsPage.tsx @@ -27,7 +27,7 @@ import TopContributors from 'components/TopContributors' const DetailsCard = ({ title, - is_active = true, + isActive = true, summary, description, heatmap, @@ -52,7 +52,7 @@ const DetailsCard = ({

{title}

{description}

- {!is_active && ( + {!isActive && ( Inactive )} {summary && ( @@ -123,7 +123,7 @@ const DetailsCard = ({ {type === 'chapter' && geolocationData && (
{ + contributor: TopContributorsType +): contributor is TopContributorsType => { return ( typeof contributor === 'object' && contributor !== null && @@ -24,19 +24,19 @@ const ContributorAvatar = memo(({ contributor, uniqueKey }: ContributorProps) => const isAlgolia = isAlgoliaContributor(contributor) const avatarUrl = isAlgolia - ? contributor.avatar_url - : (contributor as TopContributorsTypeGraphql).avatarUrl + ? contributor.avatarUrl + : (contributor as TopContributorsType).avatarUrl const contributionsCount = isAlgolia - ? contributor.contributions_count - : (contributor as TopContributorsTypeGraphql).contributionsCount + ? contributor.contributionsCount + : (contributor as TopContributorsType).contributionsCount const { login, name } = contributor const displayName = name || login const repositoryInfo = - !isAlgolia && (contributor as TopContributorsTypeGraphql).projectName - ? ` in ${(contributor as TopContributorsTypeGraphql).projectName}` + !isAlgolia && (contributor as TopContributorsType).projectName + ? ` in ${(contributor as TopContributorsType).projectName}` : '' return ( diff --git a/frontend/src/components/MultiSearch.tsx b/frontend/src/components/MultiSearch.tsx index 27de1f6bf4..208447ef7c 100644 --- a/frontend/src/components/MultiSearch.tsx +++ b/frontend/src/components/MultiSearch.tsx @@ -14,10 +14,10 @@ import { useRouter } from 'next/navigation' import type React from 'react' import { useState, useEffect, useMemo, useCallback, useRef } from 'react' import { fetchAlgoliaData } from 'server/fetchAlgoliaData' -import { ChapterTypeAlgolia } from 'types/chapter' +import { ChapterType } from 'types/chapter' import { EventType } from 'types/event' -import { OrganizationTypeAlgolia } from 'types/organization' -import { ProjectTypeAlgolia } from 'types/project' +import { Organization } from 'types/organization' +import { ProjectBase } from 'types/project' import { MultiSearchBarProps, Suggestion } from 'types/search' import { User } from 'types/user' @@ -58,10 +58,10 @@ const MultiSearchBar: React.FC = ({ return { indexName: index, hits: data.hits as - | ChapterTypeAlgolia[] + | ChapterType[] | EventType[] - | OrganizationTypeAlgolia[] - | ProjectTypeAlgolia[] + | Organization[] + | ProjectBase[] | User[], totalPages: data.totalPages || 0, } @@ -74,11 +74,11 @@ const MultiSearchBar: React.FC = ({ if (filteredEvents.length > 0) { results.push({ indexName: 'events', - hits: filteredEvents.slice(0, suggestionCount), + hits: filteredEvents.slice(0, suggestionCount) as EventType[], totalPages: 1, }) } - setSuggestions(results.filter((result) => result.hits.length > 0)) + setSuggestions(results.filter((result) => result.hits.length > 0) as Suggestion[]) setShowSuggestions(true) } else { setSuggestions([]) @@ -96,12 +96,7 @@ const MultiSearchBar: React.FC = ({ const handleSuggestionClick = useCallback( ( - suggestion: - | ChapterTypeAlgolia - | ProjectTypeAlgolia - | User - | EventType - | OrganizationTypeAlgolia, + suggestion: ChapterType | ProjectBase | User | EventType | Organization, indexName: string ) => { setSearchQuery(suggestion.name ?? '') @@ -140,12 +135,7 @@ const MultiSearchBar: React.FC = ({ const { index, subIndex } = highlightedIndex const suggestion = suggestions[index].hits[subIndex] handleSuggestionClick( - suggestion as - | ChapterTypeAlgolia - | OrganizationTypeAlgolia - | ProjectTypeAlgolia - | User - | EventType, + suggestion as ChapterType | Organization | ProjectBase | User | EventType, suggestions[index].indexName ) } else if (event.key === 'ArrowDown') { diff --git a/frontend/src/components/TopContributors.tsx b/frontend/src/components/TopContributors.tsx index 08c21a5563..784752b7e3 100644 --- a/frontend/src/components/TopContributors.tsx +++ b/frontend/src/components/TopContributors.tsx @@ -5,7 +5,7 @@ import { Button } from '@heroui/button' import Image from 'next/image' import Link from 'next/link' import { useState } from 'react' -import { TopContributorsTypeGraphql } from 'types/contributor' +import { TopContributorsType } from 'types/contributor' import { capitalize } from 'utils/capitalize' import { pluralize } from 'utils/pluralize' import { getMemberUrl, getProjectUrl } from 'utils/urlFormatter' @@ -19,7 +19,7 @@ const TopContributors = ({ type, icon, }: { - contributors: TopContributorsTypeGraphql[] + contributors: TopContributorsType[] label?: string maxInitialDisplay?: number type: string diff --git a/frontend/src/components/UserCard.tsx b/frontend/src/components/UserCard.tsx index 92705aed42..a11289eba7 100644 --- a/frontend/src/components/UserCard.tsx +++ b/frontend/src/components/UserCard.tsx @@ -12,10 +12,10 @@ const UserCard = ({ company, description, email, - followers_count, + followersCount, location, name, - repositories_count, + repositoriesCount, }: UserCardProps) => { return (
- { const { projectKey } = useParams() const [isLoading, setIsLoading] = useState(true) const [project, setProject] = useState(null) - const [topContributors, setTopContributors] = useState([]) + const [topContributors, setTopContributors] = useState([]) const { data, error: graphQLRequestError } = useQuery(GET_PROJECT_DATA, { variables: { key: projectKey }, }) diff --git a/frontend/src/app/snapshots/[id]/page.tsx b/frontend/src/app/snapshots/[id]/page.tsx index 1ad31205f6..0808a01473 100644 --- a/frontend/src/app/snapshots/[id]/page.tsx +++ b/frontend/src/app/snapshots/[id]/page.tsx @@ -7,7 +7,7 @@ import React, { useState, useEffect } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_SNAPSHOT_DETAILS } from 'server/queries/snapshotQueries' -import { ChapterType } from 'types/chapter' +import { Chapter } from 'types/chapter' import { ProjectType } from 'types/project' import { SnapshotDetailsProps } from 'types/snapshot' import { level } from 'utils/data' @@ -66,7 +66,7 @@ const SnapshotDetailsPage: React.FC = () => { ) } - const renderChapterCard = (chapter: ChapterType) => { + const renderChapterCard = (chapter: Chapter) => { const params: string[] = ['updatedAt'] const filteredIcons = getFilteredIcons(chapter, params) const formattedUrls = handleSocialUrls(chapter.relatedUrls) diff --git a/frontend/src/components/CardDetailsPage.tsx b/frontend/src/components/CardDetailsPage.tsx index 923b4b9e88..6d34e1e8ff 100644 --- a/frontend/src/components/CardDetailsPage.tsx +++ b/frontend/src/components/CardDetailsPage.tsx @@ -23,7 +23,7 @@ import RecentReleases from 'components/RecentReleases' import RepositoriesCard from 'components/RepositoriesCard' import SecondaryCard from 'components/SecondaryCard' import ToggleableList from 'components/ToggleableList' -import TopContributors from 'components/TopContributors' +import TopContributorsList from 'components/TopContributorsList' const DetailsCard = ({ title, @@ -153,7 +153,7 @@ const DetailsCard = ({
)} {topContributors && ( - { diff --git a/frontend/src/components/ChapterMapWrapper.tsx b/frontend/src/components/ChapterMapWrapper.tsx index ad26fe4315..232747f772 100644 --- a/frontend/src/components/ChapterMapWrapper.tsx +++ b/frontend/src/components/ChapterMapWrapper.tsx @@ -1,11 +1,11 @@ import dynamic from 'next/dynamic' import React from 'react' -import { ChapterType } from 'types/chapter' +import { Chapter } from 'types/chapter' const ChapterMap = dynamic(() => import('./ChapterMap'), { ssr: false }) const ChapterMapWrapper = (props: { - geoLocData: ChapterType[] + geoLocData: Chapter[] showLocal: boolean style: React.CSSProperties }) => { diff --git a/frontend/src/components/ContributorAvatar.tsx b/frontend/src/components/ContributorAvatar.tsx index fd6b6fa172..2a2986993a 100644 --- a/frontend/src/components/ContributorAvatar.tsx +++ b/frontend/src/components/ContributorAvatar.tsx @@ -2,16 +2,14 @@ import { Tooltip } from '@heroui/tooltip' import Image from 'next/image' import Link from 'next/link' import { memo } from 'react' -import { TopContributorsType } from 'types/contributor' +import { TopContributors } from 'types/contributor' type ContributorProps = { - contributor: TopContributorsType + contributor: TopContributors uniqueKey: string } -const isAlgoliaContributor = ( - contributor: TopContributorsType -): contributor is TopContributorsType => { +const isAlgoliaContributor = (contributor: TopContributors): contributor is TopContributors => { return ( typeof contributor === 'object' && contributor !== null && @@ -23,20 +21,18 @@ const isAlgoliaContributor = ( const ContributorAvatar = memo(({ contributor, uniqueKey }: ContributorProps) => { const isAlgolia = isAlgoliaContributor(contributor) - const avatarUrl = isAlgolia - ? contributor.avatarUrl - : (contributor as TopContributorsType).avatarUrl + const avatarUrl = isAlgolia ? contributor.avatarUrl : (contributor as TopContributors).avatarUrl const contributionsCount = isAlgolia ? contributor.contributionsCount - : (contributor as TopContributorsType).contributionsCount + : (contributor as TopContributors).contributionsCount const { login, name } = contributor const displayName = name || login const repositoryInfo = - !isAlgolia && (contributor as TopContributorsType).projectName - ? ` in ${(contributor as TopContributorsType).projectName}` + !isAlgolia && (contributor as TopContributors).projectName + ? ` in ${(contributor as TopContributors).projectName}` : '' return ( diff --git a/frontend/src/components/ItemCardList.tsx b/frontend/src/components/ItemCardList.tsx index d29c4a6f48..8ec38a55c4 100644 --- a/frontend/src/components/ItemCardList.tsx +++ b/frontend/src/components/ItemCardList.tsx @@ -4,7 +4,7 @@ import Image from 'next/image' import Link from 'next/link' import React, { JSX } from 'react' import { ProjectIssuesType, ProjectReleaseType, ProjectMilestonesType } from 'types/project' -import { PullRequestsType } from 'types/user' +import { PullRequest } from 'types/user' import SecondaryCard from 'components/SecondaryCard' import { TruncatedText } from 'components/TruncatedText' @@ -17,7 +17,7 @@ const ItemCardList = ({ showSingleColumn = true, }: { title: React.ReactNode - data: ProjectReleaseType[] | ProjectIssuesType[] | PullRequestsType[] | ProjectMilestonesType[] + data: ProjectReleaseType[] | ProjectIssuesType[] | PullRequest[] | ProjectMilestonesType[] icon?: IconProp showAvatar?: boolean showSingleColumn?: boolean diff --git a/frontend/src/components/MultiSearch.tsx b/frontend/src/components/MultiSearch.tsx index f1adab9d34..f44758dbb1 100644 --- a/frontend/src/components/MultiSearch.tsx +++ b/frontend/src/components/MultiSearch.tsx @@ -14,7 +14,7 @@ import { useRouter } from 'next/navigation' import type React from 'react' import { useState, useEffect, useMemo, useCallback, useRef } from 'react' import { fetchAlgoliaData } from 'server/fetchAlgoliaData' -import { ChapterType } from 'types/chapter' +import { Chapter } from 'types/chapter' import { EventType } from 'types/event' import { OrganizationType } from 'types/organization' import { ProjectType } from 'types/project' @@ -58,7 +58,7 @@ const MultiSearchBar: React.FC = ({ return { indexName: index, hits: data.hits as - | ChapterType[] + | Chapter[] | EventType[] | OrganizationType[] | ProjectType[] @@ -96,7 +96,7 @@ const MultiSearchBar: React.FC = ({ const handleSuggestionClick = useCallback( ( - suggestion: ChapterType | ProjectType | User | EventType | OrganizationType, + suggestion: Chapter | ProjectType | User | EventType | OrganizationType, indexName: string ) => { setSearchQuery(suggestion.name ?? '') @@ -135,7 +135,7 @@ const MultiSearchBar: React.FC = ({ const { index, subIndex } = highlightedIndex const suggestion = suggestions[index].hits[subIndex] handleSuggestionClick( - suggestion as ChapterType | OrganizationType | ProjectType | User | EventType, + suggestion as Chapter | OrganizationType | ProjectType | User | EventType, suggestions[index].indexName ) } else if (event.key === 'ArrowDown') { diff --git a/frontend/src/components/TopContributors.tsx b/frontend/src/components/TopContributorsList.tsx similarity index 96% rename from frontend/src/components/TopContributors.tsx rename to frontend/src/components/TopContributorsList.tsx index 784752b7e3..24dfd02128 100644 --- a/frontend/src/components/TopContributors.tsx +++ b/frontend/src/components/TopContributorsList.tsx @@ -5,21 +5,21 @@ import { Button } from '@heroui/button' import Image from 'next/image' import Link from 'next/link' import { useState } from 'react' -import { TopContributorsType } from 'types/contributor' +import { TopContributors } from 'types/contributor' import { capitalize } from 'utils/capitalize' import { pluralize } from 'utils/pluralize' import { getMemberUrl, getProjectUrl } from 'utils/urlFormatter' import AnchorTitle from 'components/AnchorTitle' import SecondaryCard from 'components/SecondaryCard' -const TopContributors = ({ +const TopContributorsList = ({ contributors, label = 'Top Contributors', maxInitialDisplay = 6, type, icon, }: { - contributors: TopContributorsType[] + contributors: TopContributors[] label?: string maxInitialDisplay?: number type: string @@ -109,4 +109,4 @@ const TopContributors = ({ ) } -export default TopContributors +export default TopContributorsList diff --git a/frontend/src/server/fetchAlgoliaData.ts b/frontend/src/server/fetchAlgoliaData.ts index a02cd2e3a7..abd03d9f71 100644 --- a/frontend/src/server/fetchAlgoliaData.ts +++ b/frontend/src/server/fetchAlgoliaData.ts @@ -1,5 +1,5 @@ import { AppError } from 'app/global-error' -import { AlgoliaResponseType } from 'types/algolia' +import { AlgoliaResponse } from 'types/algolia' import { IDX_URL } from 'utils/credentials' import { getCsrfToken } from 'utils/utility' @@ -9,7 +9,7 @@ export const fetchAlgoliaData = async ( currentPage = 0, hitsPerPage = 25, facetFilters: string[] = [] -): Promise> => { +): Promise> => { try { if (['projects', 'chapters'].includes(indexName)) { facetFilters.push('idx_is_active:true') diff --git a/frontend/src/types/algolia.ts b/frontend/src/types/algolia.ts index 7a46da5c67..f1d3197cfd 100644 --- a/frontend/src/types/algolia.ts +++ b/frontend/src/types/algolia.ts @@ -1,9 +1,9 @@ -export interface AlgoliaResponseType { +export interface AlgoliaResponse { hits: T[] totalPages?: number } -export type AlgoliaRequestType = { +export type AlgoliaRequest = { aroundLatLngViaIP?: boolean attributesToHighlight: string[] attributesToRetrieve: string[] diff --git a/frontend/src/types/card.ts b/frontend/src/types/card.ts index a0befa70cd..d3eff135c8 100644 --- a/frontend/src/types/card.ts +++ b/frontend/src/types/card.ts @@ -1,8 +1,8 @@ import { IconDefinition } from '@fortawesome/free-solid-svg-icons' import { JSX } from 'react' import { ButtonType } from 'types/button' -import { ChapterType } from 'types/chapter' -import { TopContributorsType } from 'types/contributor' +import { Chapter } from 'types/chapter' +import { TopContributors } from 'types/contributor' import { IconType } from 'types/icon' import { Level } from 'types/level' import { @@ -24,7 +24,7 @@ export interface CardProps { summary: string title: string tooltipLabel?: string - topContributors?: TopContributorsType[] + topContributors?: TopContributors[] url: string } @@ -37,7 +37,7 @@ type stats = { export interface DetailsCardProps { description?: string details?: { label: string; value: string | JSX.Element }[] - geolocationData?: ChapterType[] + geolocationData?: Chapter[] heatmap?: JSX.Element isActive?: boolean languages?: string[] @@ -51,7 +51,7 @@ export interface DetailsCardProps { summary?: string showAvatar?: boolean title?: string - topContributors?: TopContributorsType[] + topContributors?: TopContributors[] topics?: string[] type: string userSummary?: JSX.Element diff --git a/frontend/src/types/chapter.ts b/frontend/src/types/chapter.ts index c2fad9ae16..d61b94246c 100644 --- a/frontend/src/types/chapter.ts +++ b/frontend/src/types/chapter.ts @@ -1,9 +1,9 @@ -import { TopContributorsType } from 'types/contributor' +import { TopContributors } from 'types/contributor' -export type ChapterType = { +export type Chapter = { _geoloc?: { lat: number; lng: number } - geoLocation?: { lat: number; lng: number } createdAt: number + geoLocation?: { lat: number; lng: number } isActive: boolean key: string leaders: string[] @@ -11,9 +11,9 @@ export type ChapterType = { objectID: string region: string relatedUrls: string[] - summary: string suggestedLocation: string - topContributors: TopContributorsType[] + summary: string + topContributors: TopContributors[] updatedAt: number url: string } diff --git a/frontend/src/types/committee.ts b/frontend/src/types/committee.ts index 4f826921b0..c4fe94dae1 100644 --- a/frontend/src/types/committee.ts +++ b/frontend/src/types/committee.ts @@ -1,19 +1,19 @@ -import { TopContributorsType } from 'types/contributor' +import { TopContributors } from 'types/contributor' -export interface CommitteeType { +export interface Committee { + contributorsCount?: number createdAt: number + forksCount?: number + issuesCount?: number key: string leaders: string[] name: string objectID?: string relatedUrls: string[] - topContributors: TopContributorsType[] + repositoriesCount?: number + starsCount?: number summary: string + topContributors: TopContributors[] updatedAt: number url: string - contributorsCount?: number - forksCount?: number - issuesCount?: number - starsCount?: number - repositoriesCount?: number } diff --git a/frontend/src/types/contributor.ts b/frontend/src/types/contributor.ts index e473161f0b..e7ef4f9e0e 100644 --- a/frontend/src/types/contributor.ts +++ b/frontend/src/types/contributor.ts @@ -1,4 +1,4 @@ -export type TopContributorsType = { +export type TopContributors = { avatarUrl: string contributionsCount: number login: string diff --git a/frontend/src/types/home.ts b/frontend/src/types/home.ts index 0497f89e99..42670abaf3 100644 --- a/frontend/src/types/home.ts +++ b/frontend/src/types/home.ts @@ -1,9 +1,9 @@ -import { TopContributorsType } from 'types/contributor' +import { TopContributors } from 'types/contributor' import { EventType } from 'types/event' import { ProjectIssuesType, ProjectReleaseType, ProjectMilestonesType } from 'types/project' export type MainPageData = { - topContributors: TopContributorsType[] + topContributors: TopContributors[] recentIssues: ProjectIssuesType[] recentReleases: ProjectReleaseType[] upcomingEvents: EventType[] diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts index 6fae8e2cd2..5b6f1f7822 100644 --- a/frontend/src/types/project.ts +++ b/frontend/src/types/project.ts @@ -1,4 +1,4 @@ -import { TopContributorsType } from 'types/contributor' +import { TopContributors } from 'types/contributor' export type Author = { avatarUrl: string @@ -63,7 +63,7 @@ export interface ProjectType { starsCount: number summary: string topics: string[] - topContributors: TopContributorsType[] + topContributors: TopContributors[] type: string updatedAt: number url: string diff --git a/frontend/src/types/search.ts b/frontend/src/types/search.ts index ef252485f8..ec30ca4962 100644 --- a/frontend/src/types/search.ts +++ b/frontend/src/types/search.ts @@ -1,4 +1,4 @@ -import { ChapterType } from 'types/chapter' +import { Chapter } from 'types/chapter' import { EventType } from 'types/event' import { OrganizationType } from 'types/organization' import { ProjectType } from 'types/project' @@ -14,6 +14,6 @@ export interface MultiSearchBarProps { export type Suggestion = { indexName: string - hits: ChapterType[] | EventType[] | OrganizationType[] | ProjectType[] | User[] + hits: Chapter[] | EventType[] | OrganizationType[] | ProjectType[] | User[] totalPages: number } diff --git a/frontend/src/types/snapshot.ts b/frontend/src/types/snapshot.ts index 78e14c3898..b7f13a2074 100644 --- a/frontend/src/types/snapshot.ts +++ b/frontend/src/types/snapshot.ts @@ -1,4 +1,4 @@ -import { ChapterType } from 'types/chapter' +import { Chapter } from 'types/chapter' import { ProjectType } from 'types/project' export type ReleaseType = { @@ -15,7 +15,7 @@ export interface SnapshotDetailsProps { title: string newReleases: ReleaseType[] newProjects: ProjectType[] - newChapters: ChapterType[] + newChapters: Chapter[] } export type Snapshots = { diff --git a/frontend/src/types/user.ts b/frontend/src/types/user.ts index 6f32ded0dc..7c8397083d 100644 --- a/frontend/src/types/user.ts +++ b/frontend/src/types/user.ts @@ -48,7 +48,7 @@ export type User = UserType export type UserDetails = UserType -export type PullRequestsType = { +export type PullRequest = { createdAt: string organizationName: string repositoryName?: string diff --git a/frontend/src/utils/utility.ts b/frontend/src/utils/utility.ts index a422652982..1954d32997 100644 --- a/frontend/src/utils/utility.ts +++ b/frontend/src/utils/utility.ts @@ -4,8 +4,8 @@ import relativeTime from 'dayjs/plugin/relativeTime' import { twMerge } from 'tailwind-merge' import { fetchCsrfToken } from 'server/fetchCsrfToken' -import { ChapterType } from 'types/chapter' -import { CommitteeType } from 'types/committee' +import { Chapter } from 'types/chapter' +import { Committee } from 'types/committee' import { IconType } from 'types/icon' import { IssueType } from 'types/issue' import { ProjectType } from 'types/project' @@ -17,7 +17,7 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } -type projectType = ProjectType | IssueType | CommitteeType | ChapterType +type projectType = ProjectType | IssueType | Committee | Chapter export const getFilteredIcons = (project: projectType, params: string[]): IconType => { const filteredIcons = params.reduce((acc: IconType, key) => { From d7f2a8c6e8306ad59bb863b17b42083dff447d79 Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Thu, 12 Jun 2025 21:18:58 +0530 Subject: [PATCH 09/17] fixed types and import with types --- backend/apps/core/utils/index.py | 14 +++- backend/poetry.lock | 14 +--- backend/pyproject.toml | 1 - frontend/src/app/about/page.tsx | 6 +- .../src/app/chapters/[chapterKey]/page.tsx | 4 +- frontend/src/app/chapters/page.tsx | 4 +- .../app/committees/[committeeKey]/page.tsx | 4 +- frontend/src/app/contribute/page.tsx | 2 +- frontend/src/app/members/[memberKey]/page.tsx | 21 +++-- frontend/src/app/members/page.tsx | 2 +- .../repositories/[repositoryKey]/page.tsx | 2 +- frontend/src/app/organizations/page.tsx | 2 +- .../src/app/projects/[projectKey]/page.tsx | 4 +- frontend/src/app/projects/page.tsx | 2 +- frontend/src/app/snapshots/[id]/page.tsx | 6 +- frontend/src/app/snapshots/page.tsx | 2 +- frontend/src/components/Card.tsx | 2 +- frontend/src/components/CardDetailsPage.tsx | 2 +- frontend/src/components/ChapterMap.tsx | 2 +- frontend/src/components/ChapterMapWrapper.tsx | 2 +- frontend/src/components/ContributorAvatar.tsx | 2 +- frontend/src/components/DisplayIcon.tsx | 2 +- frontend/src/components/Footer.tsx | 2 +- frontend/src/components/InfoBlock.tsx | 2 +- frontend/src/components/ItemCardList.tsx | 8 +- frontend/src/components/LeadersList.tsx | 2 +- frontend/src/components/LogoCarousel.tsx | 2 +- frontend/src/components/Milestones.tsx | 4 +- frontend/src/components/Modal.tsx | 2 +- frontend/src/components/MultiSearch.tsx | 12 +-- frontend/src/components/NavButton.tsx | 2 +- frontend/src/components/NavDropDown.tsx | 2 +- frontend/src/components/RecentIssues.tsx | 4 +- .../src/components/RecentPullRequests.tsx | 5 +- frontend/src/components/RecentReleases.tsx | 4 +- frontend/src/components/RepositoriesCard.tsx | 2 +- frontend/src/components/SnapshotCard.tsx | 2 +- frontend/src/components/SortBy.tsx | 2 +- .../src/components/TopContributorsList.tsx | 2 +- frontend/src/components/UserCard.tsx | 2 +- frontend/src/components/skeletons/Card.tsx | 2 +- .../src/components/skeletons/UserCard.tsx | 2 +- frontend/src/server/fetchAlgoliaData.ts | 2 +- frontend/src/types/algolia.ts | 2 +- frontend/src/types/button.ts | 6 +- frontend/src/types/card.ts | 36 ++++----- frontend/src/types/chapter.ts | 6 +- frontend/src/types/committee.ts | 4 +- frontend/src/types/home.ts | 49 ++++-------- frontend/src/types/issue.ts | 2 +- frontend/src/types/milestone.ts | 15 ++++ frontend/src/types/modal.ts | 4 +- frontend/src/types/organization.ts | 2 +- frontend/src/types/project.ts | 77 ++++--------------- frontend/src/types/pullRequest.ts | 10 +++ frontend/src/types/release.ts | 13 ++++ frontend/src/types/search.ts | 2 +- frontend/src/types/skeleton.ts | 4 +- frontend/src/types/snapshot.ts | 14 +--- frontend/src/types/sortBy.ts | 2 +- frontend/src/types/user.ts | 48 ++---------- frontend/src/utils/constants.ts | 4 +- frontend/src/utils/utility.ts | 10 +-- 63 files changed, 203 insertions(+), 276 deletions(-) create mode 100644 frontend/src/types/milestone.ts create mode 100644 frontend/src/types/pullRequest.ts create mode 100644 frontend/src/types/release.ts diff --git a/backend/apps/core/utils/index.py b/backend/apps/core/utils/index.py index fa692f6391..4f2cf079b5 100644 --- a/backend/apps/core/utils/index.py +++ b/backend/apps/core/utils/index.py @@ -5,7 +5,6 @@ from algoliasearch_django import register, unregister from algoliasearch_django.registration import RegistrationError from django.apps import apps -from humps import camelize def get_params_for_index(index_name: str) -> dict: @@ -179,3 +178,16 @@ def deep_camelize(obj) -> dict | list: if isinstance(obj, list): return [deep_camelize(item) for item in obj] return obj + + +def camelize(key: str) -> str: + """Camelize a string. + + Args: + key (str): The string to camelize. + + Returns: + str: The camelize string. + + """ + return key.replace("_", "").title() diff --git a/backend/poetry.lock b/backend/poetry.lock index 39f9c4f626..0d83386ddc 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -2226,18 +2226,6 @@ files = [ [package.extras] windows-terminal = ["colorama (>=0.4.6)"] -[[package]] -name = "pyhumps" -version = "3.8.0" -description = "🐫 Convert strings (and dictionary keys) between snake case, camel case and pascal case in Python. Inspired by Humps for Node" -optional = false -python-versions = "*" -groups = ["main"] -files = [ - {file = "pyhumps-3.8.0-py3-none-any.whl", hash = "sha256:060e1954d9069f428232a1adda165db0b9d8dfdce1d265d36df7fbff540acfd6"}, - {file = "pyhumps-3.8.0.tar.gz", hash = "sha256:498026258f7ee1a8e447c2e28526c0bea9407f9a59c03260aee4bd6c04d681a3"}, -] - [[package]] name = "pyjwt" version = "2.10.1" @@ -3288,4 +3276,4 @@ propcache = ">=0.2.1" [metadata] lock-version = "2.1" python-versions = "^3.13" -content-hash = "99fcf7b7f6b7826bd97b65324380b0c1a30867a37d24190dc92c49aa1d1509f5" +content-hash = "74b08acb4ffd0b2eb81f79aa7f03a92a4ecd113a770de88d4f64e2f14e81948c" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 507cb53076..81258e5463 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -51,7 +51,6 @@ slack-sdk = "^3.35.0" strawberry-graphql = {extras = ["django"], version = "^0.270.1"} thefuzz = "^0.22.1" strawberry-graphql-django = "^0.59.1" -pyhumps = "^3.8.0" [tool.poetry.group.dev.dependencies] djlint = "^1.36.4" diff --git a/frontend/src/app/about/page.tsx b/frontend/src/app/about/page.tsx index 324c400449..b676ff72f9 100644 --- a/frontend/src/app/about/page.tsx +++ b/frontend/src/app/about/page.tsx @@ -20,9 +20,9 @@ import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_PROJECT_METADATA, GET_TOP_CONTRIBUTORS } from 'server/queries/projectQueries' import { GET_LEADER_DATA } from 'server/queries/userQueries' -import { TopContributors } from 'types/contributor' -import { ProjectType } from 'types/project' -import { User } from 'types/user' +import type { TopContributors } from 'types/contributor' +import type { ProjectType } from 'types/project' +import type { User } from 'types/user' import { aboutText, technologies } from 'utils/aboutData' import AnchorTitle from 'components/AnchorTitle' import AnimatedCounter from 'components/AnimatedCounter' diff --git a/frontend/src/app/chapters/[chapterKey]/page.tsx b/frontend/src/app/chapters/[chapterKey]/page.tsx index 5da5d4e2f8..0eb73fa746 100644 --- a/frontend/src/app/chapters/[chapterKey]/page.tsx +++ b/frontend/src/app/chapters/[chapterKey]/page.tsx @@ -5,8 +5,8 @@ import { useParams } from 'next/navigation' import { useState, useEffect } from 'react' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_CHAPTER_DATA } from 'server/queries/chapterQueries' -import { Chapter } from 'types/chapter' -import { TopContributors } from 'types/contributor' +import type { Chapter } from 'types/chapter' +import type { TopContributors } from 'types/contributor' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' import LoadingSpinner from 'components/LoadingSpinner' diff --git a/frontend/src/app/chapters/page.tsx b/frontend/src/app/chapters/page.tsx index 403e07e2a3..15d93df6ea 100644 --- a/frontend/src/app/chapters/page.tsx +++ b/frontend/src/app/chapters/page.tsx @@ -4,8 +4,8 @@ import { useRouter } from 'next/navigation' import { useEffect, useState } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { fetchAlgoliaData } from 'server/fetchAlgoliaData' -import { AlgoliaResponse } from 'types/algolia' -import { Chapter } from 'types/chapter' +import type { AlgoliaResponse } from 'types/algolia' +import type { Chapter } from 'types/chapter' import { getFilteredIcons, handleSocialUrls } from 'utils/utility' import Card from 'components/Card' import ChapterMapWrapper from 'components/ChapterMapWrapper' diff --git a/frontend/src/app/committees/[committeeKey]/page.tsx b/frontend/src/app/committees/[committeeKey]/page.tsx index bfd730f896..6954c6ed8a 100644 --- a/frontend/src/app/committees/[committeeKey]/page.tsx +++ b/frontend/src/app/committees/[committeeKey]/page.tsx @@ -12,8 +12,8 @@ import { useParams } from 'next/navigation' import { useState, useEffect } from 'react' import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_COMMITTEE_DATA } from 'server/queries/committeeQueries' -import { Committee } from 'types/committee' -import { TopContributors } from 'types/contributor' +import type { Committee } from 'types/committee' +import type { TopContributors } from 'types/contributor' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' import LoadingSpinner from 'components/LoadingSpinner' diff --git a/frontend/src/app/contribute/page.tsx b/frontend/src/app/contribute/page.tsx index 756af6a2bd..55361cc6ac 100644 --- a/frontend/src/app/contribute/page.tsx +++ b/frontend/src/app/contribute/page.tsx @@ -4,7 +4,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import React, { useState } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { IssueType } from 'types/issue' +import type { IssueType } from 'types/issue' import { getFilteredIcons } from 'utils/utility' import Card from 'components/Card' diff --git a/frontend/src/app/members/[memberKey]/page.tsx b/frontend/src/app/members/[memberKey]/page.tsx index fc5debf15d..a37ff6e2fa 100644 --- a/frontend/src/app/members/[memberKey]/page.tsx +++ b/frontend/src/app/members/[memberKey]/page.tsx @@ -12,13 +12,12 @@ import { useParams } from 'next/navigation' import React, { useState, useEffect, useRef } from 'react' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_USER_DATA } from 'server/queries/userQueries' -import type { - ProjectIssuesType, - ProjectMilestonesType, - ProjectReleaseType, - RepositoryCardProps, -} from 'types/project' -import type { ItemCardPullRequests, UserDetails } from 'types/user' +import type { IssueType } from 'types/issue' +import type { MilestonesType } from 'types/milestone' +import type { RepositoryCardProps } from 'types/project' +import type { PullRequestType } from 'types/pullRequest' +import type { ReleaseType } from 'types/release' +import type { UserDetails } from 'types/user' import { formatDate } from 'utils/dateFormatter' import { drawContributions, fetchHeatmapData, HeatmapData } from 'utils/helpers/githubHeatmap' import DetailsCard from 'components/CardDetailsPage' @@ -27,11 +26,11 @@ import LoadingSpinner from 'components/LoadingSpinner' const UserDetailsPage: React.FC = () => { const { memberKey } = useParams() const [user, setUser] = useState() - const [issues, setIssues] = useState([]) + const [issues, setIssues] = useState([]) const [topRepositories, setTopRepositories] = useState([]) - const [milestones, setMilestones] = useState([]) - const [pullRequests, setPullRequests] = useState([]) - const [releases, setReleases] = useState([]) + const [milestones, setMilestones] = useState([]) + const [pullRequests, setPullRequests] = useState([]) + const [releases, setReleases] = useState([]) const [data, setData] = useState({} as HeatmapData) const [isLoading, setIsLoading] = useState(true) const [username, setUsername] = useState('') diff --git a/frontend/src/app/members/page.tsx b/frontend/src/app/members/page.tsx index fb56b4af6e..00dd7f08e6 100644 --- a/frontend/src/app/members/page.tsx +++ b/frontend/src/app/members/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { User } from 'types/user' +import type { User } from 'types/user' import SearchPageLayout from 'components/SearchPageLayout' import UserCard from 'components/UserCard' diff --git a/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx b/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx index 67e0d0e4f0..6c52a697f9 100644 --- a/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx +++ b/frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx @@ -13,7 +13,7 @@ import { useParams } from 'next/navigation' import { useEffect, useState } from 'react' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_REPOSITORY_DATA } from 'server/queries/repositoryQueries' -import { TopContributors } from 'types/contributor' +import type { TopContributors } from 'types/contributor' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' import LoadingSpinner from 'components/LoadingSpinner' diff --git a/frontend/src/app/organizations/page.tsx b/frontend/src/app/organizations/page.tsx index f62669c79a..6176fa8b70 100644 --- a/frontend/src/app/organizations/page.tsx +++ b/frontend/src/app/organizations/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { OrganizationType } from 'types/organization' +import type { OrganizationType } from 'types/organization' import SearchPageLayout from 'components/SearchPageLayout' import UserCard from 'components/UserCard' diff --git a/frontend/src/app/projects/[projectKey]/page.tsx b/frontend/src/app/projects/[projectKey]/page.tsx index fd7c087297..91acd61b6b 100644 --- a/frontend/src/app/projects/[projectKey]/page.tsx +++ b/frontend/src/app/projects/[projectKey]/page.tsx @@ -12,8 +12,8 @@ import { useParams } from 'next/navigation' import { useState, useEffect } from 'react' import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_PROJECT_DATA } from 'server/queries/projectQueries' -import { TopContributors } from 'types/contributor' -import { ProjectType } from 'types/project' +import type { TopContributors } from 'types/contributor' +import type { ProjectType } from 'types/project' import { capitalize } from 'utils/capitalize' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' diff --git a/frontend/src/app/projects/page.tsx b/frontend/src/app/projects/page.tsx index d5deca0cfc..b019e1a4b5 100644 --- a/frontend/src/app/projects/page.tsx +++ b/frontend/src/app/projects/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { ProjectType } from 'types/project' +import type { ProjectType } from 'types/project' import { level } from 'utils/data' import { sortOptionsProject } from 'utils/sortingOptions' import { getFilteredIcons } from 'utils/utility' diff --git a/frontend/src/app/snapshots/[id]/page.tsx b/frontend/src/app/snapshots/[id]/page.tsx index 0808a01473..41bbf29b69 100644 --- a/frontend/src/app/snapshots/[id]/page.tsx +++ b/frontend/src/app/snapshots/[id]/page.tsx @@ -7,9 +7,9 @@ import React, { useState, useEffect } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_SNAPSHOT_DETAILS } from 'server/queries/snapshotQueries' -import { Chapter } from 'types/chapter' -import { ProjectType } from 'types/project' -import { SnapshotDetailsProps } from 'types/snapshot' +import type { Chapter } from 'types/chapter' +import type { ProjectType } from 'types/project' +import type { SnapshotDetailsProps } from 'types/snapshot' import { level } from 'utils/data' import { formatDate } from 'utils/dateFormatter' import { getFilteredIcons, handleSocialUrls } from 'utils/utility' diff --git a/frontend/src/app/snapshots/page.tsx b/frontend/src/app/snapshots/page.tsx index 1a01dfc8ce..d228083215 100644 --- a/frontend/src/app/snapshots/page.tsx +++ b/frontend/src/app/snapshots/page.tsx @@ -5,7 +5,7 @@ import { useRouter } from 'next/navigation' import React, { useState, useEffect } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { GET_COMMUNITY_SNAPSHOTS } from 'server/queries/snapshotQueries' -import { Snapshots } from 'types/snapshot' +import type { Snapshots } from 'types/snapshot' import LoadingSpinner from 'components/LoadingSpinner' import SnapshotCard from 'components/SnapshotCard' diff --git a/frontend/src/components/Card.tsx b/frontend/src/components/Card.tsx index 6ae9df3c40..09e28da50b 100644 --- a/frontend/src/components/Card.tsx +++ b/frontend/src/components/Card.tsx @@ -2,7 +2,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Tooltip } from '@heroui/tooltip' import Link from 'next/link' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { CardProps } from 'types/card' +import type { CardProps } from 'types/card' import { Icons } from 'utils/data' import { getSocialIcon } from 'utils/urlIconMappings' import ActionButton from 'components/ActionButton' diff --git a/frontend/src/components/CardDetailsPage.tsx b/frontend/src/components/CardDetailsPage.tsx index 6d34e1e8ff..9fb2c1752b 100644 --- a/frontend/src/components/CardDetailsPage.tsx +++ b/frontend/src/components/CardDetailsPage.tsx @@ -9,7 +9,7 @@ import { faRectangleList, } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { DetailsCardProps } from 'types/card' +import type { DetailsCardProps } from 'types/card' import { capitalize } from 'utils/capitalize' import { getSocialIcon } from 'utils/urlIconMappings' import AnchorTitle from 'components/AnchorTitle' diff --git a/frontend/src/components/ChapterMap.tsx b/frontend/src/components/ChapterMap.tsx index 073902377a..36c360aca5 100644 --- a/frontend/src/components/ChapterMap.tsx +++ b/frontend/src/components/ChapterMap.tsx @@ -1,7 +1,7 @@ 'use client' import L, { MarkerClusterGroup } from 'leaflet' import React, { useEffect, useRef } from 'react' -import { Chapter } from 'types/chapter' +import type { Chapter } from 'types/chapter' import 'leaflet.markercluster' import 'leaflet/dist/leaflet.css' import 'leaflet.markercluster/dist/MarkerCluster.css' diff --git a/frontend/src/components/ChapterMapWrapper.tsx b/frontend/src/components/ChapterMapWrapper.tsx index 232747f772..48fb313e4a 100644 --- a/frontend/src/components/ChapterMapWrapper.tsx +++ b/frontend/src/components/ChapterMapWrapper.tsx @@ -1,6 +1,6 @@ import dynamic from 'next/dynamic' import React from 'react' -import { Chapter } from 'types/chapter' +import type { Chapter } from 'types/chapter' const ChapterMap = dynamic(() => import('./ChapterMap'), { ssr: false }) diff --git a/frontend/src/components/ContributorAvatar.tsx b/frontend/src/components/ContributorAvatar.tsx index 2a2986993a..1b6ada1e4a 100644 --- a/frontend/src/components/ContributorAvatar.tsx +++ b/frontend/src/components/ContributorAvatar.tsx @@ -2,7 +2,7 @@ import { Tooltip } from '@heroui/tooltip' import Image from 'next/image' import Link from 'next/link' import { memo } from 'react' -import { TopContributors } from 'types/contributor' +import type { TopContributors } from 'types/contributor' type ContributorProps = { contributor: TopContributors diff --git a/frontend/src/components/DisplayIcon.tsx b/frontend/src/components/DisplayIcon.tsx index d01597ba4b..651e24f00b 100644 --- a/frontend/src/components/DisplayIcon.tsx +++ b/frontend/src/components/DisplayIcon.tsx @@ -1,7 +1,7 @@ import { Tooltip } from '@heroui/tooltip' import { millify } from 'millify' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { IconType } from 'types/icon' +import type { IconType } from 'types/icon' import { IconKeys, Icons } from 'utils/data' export default function DisplayIcon({ item, icons }: { item: string; icons: IconType }) { diff --git a/frontend/src/components/Footer.tsx b/frontend/src/components/Footer.tsx index 65b77b26b2..acb61e71f7 100644 --- a/frontend/src/components/Footer.tsx +++ b/frontend/src/components/Footer.tsx @@ -4,7 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Button } from '@heroui/button' import Link from 'next/link' import { useState, useCallback } from 'react' -import { Section } from 'types/section' +import type { Section } from 'types/section' import { footerIcons } from 'utils/constants' import { footerSections } from 'utils/constants' diff --git a/frontend/src/components/InfoBlock.tsx b/frontend/src/components/InfoBlock.tsx index 95d853ef96..477ed4f352 100644 --- a/frontend/src/components/InfoBlock.tsx +++ b/frontend/src/components/InfoBlock.tsx @@ -1,4 +1,4 @@ -import { IconProp } from '@fortawesome/fontawesome-svg-core' +import type { IconProp } from '@fortawesome/fontawesome-svg-core' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import millify from 'millify' import { pluralize } from 'utils/pluralize' diff --git a/frontend/src/components/ItemCardList.tsx b/frontend/src/components/ItemCardList.tsx index 8ec38a55c4..c3a84f43c7 100644 --- a/frontend/src/components/ItemCardList.tsx +++ b/frontend/src/components/ItemCardList.tsx @@ -3,8 +3,10 @@ import { Tooltip } from '@heroui/tooltip' import Image from 'next/image' import Link from 'next/link' import React, { JSX } from 'react' -import { ProjectIssuesType, ProjectReleaseType, ProjectMilestonesType } from 'types/project' -import { PullRequest } from 'types/user' +import type { IssueType } from 'types/issue' +import type { MilestonesType } from 'types/milestone' +import type { PullRequestType } from 'types/pullRequest' +import type { ReleaseType } from 'types/release' import SecondaryCard from 'components/SecondaryCard' import { TruncatedText } from 'components/TruncatedText' @@ -17,7 +19,7 @@ const ItemCardList = ({ showSingleColumn = true, }: { title: React.ReactNode - data: ProjectReleaseType[] | ProjectIssuesType[] | PullRequest[] | ProjectMilestonesType[] + data: ReleaseType[] | IssueType[] | PullRequestType[] | MilestonesType[] icon?: IconProp showAvatar?: boolean showSingleColumn?: boolean diff --git a/frontend/src/components/LeadersList.tsx b/frontend/src/components/LeadersList.tsx index 8cfff26a49..d79b3ae623 100644 --- a/frontend/src/components/LeadersList.tsx +++ b/frontend/src/components/LeadersList.tsx @@ -1,5 +1,5 @@ import Link from 'next/link' -import { LeadersListProps } from 'types/leaders' +import type { LeadersListProps } from 'types/leaders' import { TruncatedText } from 'components/TruncatedText' /** diff --git a/frontend/src/components/LogoCarousel.tsx b/frontend/src/components/LogoCarousel.tsx index 3640d970aa..bcc7bcc178 100644 --- a/frontend/src/components/LogoCarousel.tsx +++ b/frontend/src/components/LogoCarousel.tsx @@ -1,7 +1,7 @@ import Image from 'next/image' import Link from 'next/link' import { useEffect, useRef } from 'react' -import { SponsorType } from 'types/home' +import type { SponsorType } from 'types/home' interface MovingLogosProps { sponsors: SponsorType[] diff --git a/frontend/src/components/Milestones.tsx b/frontend/src/components/Milestones.tsx index 1457e31ad6..23a285d8be 100644 --- a/frontend/src/components/Milestones.tsx +++ b/frontend/src/components/Milestones.tsx @@ -8,14 +8,14 @@ import { import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useRouter } from 'next/navigation' import React from 'react' -import { ProjectMilestonesType } from 'types/project' +import type { MilestonesType } from 'types/milestone' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import ItemCardList from 'components/ItemCardList' import { TruncatedText } from 'components/TruncatedText' interface ProjectMilestonesProps { - data: ProjectMilestonesType[] + data: MilestonesType[] showAvatar?: boolean showSingleColumn?: boolean } diff --git a/frontend/src/components/Modal.tsx b/frontend/src/components/Modal.tsx index d7324bca19..9e401999d9 100644 --- a/frontend/src/components/Modal.tsx +++ b/frontend/src/components/Modal.tsx @@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Button } from '@heroui/button' import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter } from '@heroui/modal' import React from 'react' -import { ModalProps } from 'types/modal' +import type { ModalProps } from 'types/modal' import ActionButton from 'components/ActionButton' import Markdown from 'components/MarkdownWrapper' diff --git a/frontend/src/components/MultiSearch.tsx b/frontend/src/components/MultiSearch.tsx index f44758dbb1..17cce991cd 100644 --- a/frontend/src/components/MultiSearch.tsx +++ b/frontend/src/components/MultiSearch.tsx @@ -14,12 +14,12 @@ import { useRouter } from 'next/navigation' import type React from 'react' import { useState, useEffect, useMemo, useCallback, useRef } from 'react' import { fetchAlgoliaData } from 'server/fetchAlgoliaData' -import { Chapter } from 'types/chapter' -import { EventType } from 'types/event' -import { OrganizationType } from 'types/organization' -import { ProjectType } from 'types/project' -import { MultiSearchBarProps, Suggestion } from 'types/search' -import { User } from 'types/user' +import type { Chapter } from 'types/chapter' +import type { EventType } from 'types/event' +import type { OrganizationType } from 'types/organization' +import type { ProjectType } from 'types/project' +import type { MultiSearchBarProps, Suggestion } from 'types/search' +import type { User } from 'types/user' const MultiSearchBar: React.FC = ({ isLoaded, diff --git a/frontend/src/components/NavButton.tsx b/frontend/src/components/NavButton.tsx index 97ffb06181..f328a734f7 100644 --- a/frontend/src/components/NavButton.tsx +++ b/frontend/src/components/NavButton.tsx @@ -1,7 +1,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Link from 'next/link' import { useState } from 'react' -import { NavButtonProps } from 'types/button' +import type { NavButtonProps } from 'types/button' import { cn } from 'utils/utility' const NavButton = ({ diff --git a/frontend/src/components/NavDropDown.tsx b/frontend/src/components/NavDropDown.tsx index a14fc34feb..b18504cfc5 100644 --- a/frontend/src/components/NavDropDown.tsx +++ b/frontend/src/components/NavDropDown.tsx @@ -2,7 +2,7 @@ import { faChevronDown } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Link from 'next/link' import { useState, useRef, useEffect, useId } from 'react' -import { Link as LinkType } from 'types/link' +import type { Link as LinkType } from 'types/link' import { cn } from 'utils/utility' interface NavDropDownProps { diff --git a/frontend/src/components/RecentIssues.tsx b/frontend/src/components/RecentIssues.tsx index a5a16df6bf..bda130cb68 100644 --- a/frontend/src/components/RecentIssues.tsx +++ b/frontend/src/components/RecentIssues.tsx @@ -2,14 +2,14 @@ import { faCalendar, faFolderOpen, faCircleExclamation } from '@fortawesome/free import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useRouter } from 'next/navigation' import React from 'react' -import { ProjectIssuesType } from 'types/project' +import type { IssueType } from 'types/issue' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import ItemCardList from 'components/ItemCardList' import { TruncatedText } from 'components/TruncatedText' interface RecentIssuesProps { - data: ProjectIssuesType[] + data: IssueType[] showAvatar?: boolean } diff --git a/frontend/src/components/RecentPullRequests.tsx b/frontend/src/components/RecentPullRequests.tsx index e5ddcc979c..f2db18a091 100644 --- a/frontend/src/components/RecentPullRequests.tsx +++ b/frontend/src/components/RecentPullRequests.tsx @@ -2,15 +2,14 @@ import { faCalendar, faCodePullRequest, faFolderOpen } from '@fortawesome/free-s import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useRouter } from 'next/navigation' import React from 'react' -import { PullRequestsType } from 'types/home' -import { ItemCardPullRequests } from 'types/user' +import type { PullRequestType } from 'types/pullRequest' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import ItemCardList from 'components/ItemCardList' import { TruncatedText } from 'components/TruncatedText' interface RecentPullRequestsProps { - data: ItemCardPullRequests[] | PullRequestsType[] + data: PullRequestType[] showAvatar?: boolean } diff --git a/frontend/src/components/RecentReleases.tsx b/frontend/src/components/RecentReleases.tsx index 35630fdb33..782e7b04db 100644 --- a/frontend/src/components/RecentReleases.tsx +++ b/frontend/src/components/RecentReleases.tsx @@ -5,14 +5,14 @@ import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/navigation' import React from 'react' -import { ProjectReleaseType } from 'types/project' +import type { ReleaseType } from 'types/release' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import SecondaryCard from 'components/SecondaryCard' import { TruncatedText } from 'components/TruncatedText' interface RecentReleasesProps { - data: ProjectReleaseType[] + data: ReleaseType[] showAvatar?: boolean showSingleColumn?: boolean } diff --git a/frontend/src/components/RepositoriesCard.tsx b/frontend/src/components/RepositoriesCard.tsx index 88e15f12f7..eeb712828d 100644 --- a/frontend/src/components/RepositoriesCard.tsx +++ b/frontend/src/components/RepositoriesCard.tsx @@ -10,7 +10,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useRouter } from 'next/navigation' import type React from 'react' import { useState } from 'react' -import { RepositoriesCardProps, RepositoryCardProps } from 'types/project' +import type { RepositoriesCardProps, RepositoryCardProps } from 'types/project' import InfoItem from 'components/InfoItem' import { TruncatedText } from 'components/TruncatedText' diff --git a/frontend/src/components/SnapshotCard.tsx b/frontend/src/components/SnapshotCard.tsx index 78da8c999d..e80cb65255 100644 --- a/frontend/src/components/SnapshotCard.tsx +++ b/frontend/src/components/SnapshotCard.tsx @@ -1,7 +1,7 @@ import { faChevronRight, faCalendar } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Button } from '@heroui/button' -import { SnapshotCardProps } from 'types/card' +import type { SnapshotCardProps } from 'types/card' import { formatDate } from 'utils/dateFormatter' const SnapshotCard = ({ title, button, startAt, endAt }: SnapshotCardProps) => { diff --git a/frontend/src/components/SortBy.tsx b/frontend/src/components/SortBy.tsx index eabebc262a..f8f7766678 100644 --- a/frontend/src/components/SortBy.tsx +++ b/frontend/src/components/SortBy.tsx @@ -2,7 +2,7 @@ import { faArrowDownWideShort, faArrowUpWideShort } from '@fortawesome/free-soli import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Select, SelectItem } from '@heroui/select' import { Tooltip } from '@heroui/tooltip' -import { SortByProps } from 'types/sortBy' +import type { SortByProps } from 'types/sortBy' const SortBy = ({ sortOptions, diff --git a/frontend/src/components/TopContributorsList.tsx b/frontend/src/components/TopContributorsList.tsx index 24dfd02128..76d0bfe906 100644 --- a/frontend/src/components/TopContributorsList.tsx +++ b/frontend/src/components/TopContributorsList.tsx @@ -5,7 +5,7 @@ import { Button } from '@heroui/button' import Image from 'next/image' import Link from 'next/link' import { useState } from 'react' -import { TopContributors } from 'types/contributor' +import type { TopContributors } from 'types/contributor' import { capitalize } from 'utils/capitalize' import { pluralize } from 'utils/pluralize' import { getMemberUrl, getProjectUrl } from 'utils/urlFormatter' diff --git a/frontend/src/components/UserCard.tsx b/frontend/src/components/UserCard.tsx index a11289eba7..26681afdd0 100644 --- a/frontend/src/components/UserCard.tsx +++ b/frontend/src/components/UserCard.tsx @@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Button } from '@heroui/button' import millify from 'millify' import Image from 'next/image' -import { UserCardProps } from 'types/card' +import type { UserCardProps } from 'types/card' const UserCard = ({ avatar, diff --git a/frontend/src/components/skeletons/Card.tsx b/frontend/src/components/skeletons/Card.tsx index bf05d60838..71596c9edc 100644 --- a/frontend/src/components/skeletons/Card.tsx +++ b/frontend/src/components/skeletons/Card.tsx @@ -1,6 +1,6 @@ import { Skeleton } from '@heroui/skeleton' import type React from 'react' -import { CardSkeletonProps } from 'types/skeleton' +import type { CardSkeletonProps } from 'types/skeleton' const CardSkeleton: React.FC = ({ showLevel = true, diff --git a/frontend/src/components/skeletons/UserCard.tsx b/frontend/src/components/skeletons/UserCard.tsx index ba40eb8fcd..1bc7ed7a71 100644 --- a/frontend/src/components/skeletons/UserCard.tsx +++ b/frontend/src/components/skeletons/UserCard.tsx @@ -1,6 +1,6 @@ import { Skeleton } from '@heroui/skeleton' import type React from 'react' -import { UserCardSkeletonProps } from 'types/skeleton' +import type { UserCardSkeletonProps } from 'types/skeleton' const UserCardSkeleton: React.FC = ({ showAvatar = true, diff --git a/frontend/src/server/fetchAlgoliaData.ts b/frontend/src/server/fetchAlgoliaData.ts index abd03d9f71..7da2d30990 100644 --- a/frontend/src/server/fetchAlgoliaData.ts +++ b/frontend/src/server/fetchAlgoliaData.ts @@ -1,5 +1,5 @@ import { AppError } from 'app/global-error' -import { AlgoliaResponse } from 'types/algolia' +import type { AlgoliaResponse } from 'types/algolia' import { IDX_URL } from 'utils/credentials' import { getCsrfToken } from 'utils/utility' diff --git a/frontend/src/types/algolia.ts b/frontend/src/types/algolia.ts index f1d3197cfd..43e0be418e 100644 --- a/frontend/src/types/algolia.ts +++ b/frontend/src/types/algolia.ts @@ -1,4 +1,4 @@ -export interface AlgoliaResponse { +export type AlgoliaResponse = { hits: T[] totalPages?: number } diff --git a/frontend/src/types/button.ts b/frontend/src/types/button.ts index 6e8e521b84..c4306dcc04 100644 --- a/frontend/src/types/button.ts +++ b/frontend/src/types/button.ts @@ -1,5 +1,5 @@ -import { IconDefinition } from '@fortawesome/free-solid-svg-icons' -import { JSX } from 'react' +import type { IconDefinition } from '@fortawesome/free-solid-svg-icons' +import type { JSX } from 'react' export type ButtonType = { label: string @@ -8,7 +8,7 @@ export type ButtonType = { url?: string } -export interface NavButtonProps { +export type NavButtonProps = { href: string defaultIcon: IconDefinition hoverIcon: IconDefinition diff --git a/frontend/src/types/card.ts b/frontend/src/types/card.ts index d3eff135c8..669a1986a9 100644 --- a/frontend/src/types/card.ts +++ b/frontend/src/types/card.ts @@ -1,19 +1,17 @@ -import { IconDefinition } from '@fortawesome/free-solid-svg-icons' -import { JSX } from 'react' -import { ButtonType } from 'types/button' -import { Chapter } from 'types/chapter' -import { TopContributors } from 'types/contributor' -import { IconType } from 'types/icon' -import { Level } from 'types/level' -import { - ProjectIssuesType, - ProjectReleaseType, - RepositoryCardProps, - ProjectMilestonesType, -} from 'types/project' -import { ItemCardPullRequests } from 'types/user' +import type { IconDefinition } from '@fortawesome/free-solid-svg-icons' +import type { JSX } from 'react' +import type { ButtonType } from 'types/button' +import type { Chapter } from 'types/chapter' +import type { TopContributors } from 'types/contributor' +import type { IconType } from 'types/icon' +import type { IssueType } from 'types/issue' +import type { Level } from 'types/level' +import type { MilestonesType } from 'types/milestone' +import type { RepositoryCardProps } from 'types/project' +import type { PullRequestType } from 'types/pullRequest' +import type { ReleaseType } from 'types/release' -export interface CardProps { +export type CardProps = { button: ButtonType icons?: IconType isActive?: boolean @@ -41,10 +39,10 @@ export interface DetailsCardProps { heatmap?: JSX.Element isActive?: boolean languages?: string[] - pullRequests?: ItemCardPullRequests[] - recentIssues?: ProjectIssuesType[] - recentReleases?: ProjectReleaseType[] - recentMilestones?: ProjectMilestonesType[] + pullRequests?: PullRequestType[] + recentIssues?: IssueType[] + recentReleases?: ReleaseType[] + recentMilestones?: MilestonesType[] repositories?: RepositoryCardProps[] socialLinks?: string[] stats?: stats[] diff --git a/frontend/src/types/chapter.ts b/frontend/src/types/chapter.ts index d61b94246c..215a691a7a 100644 --- a/frontend/src/types/chapter.ts +++ b/frontend/src/types/chapter.ts @@ -1,9 +1,9 @@ -import { TopContributors } from 'types/contributor' +import type { TopContributors } from 'types/contributor' export type Chapter = { - _geoloc?: { lat: number; lng: number } + _geoloc?: GeoLocation createdAt: number - geoLocation?: { lat: number; lng: number } + geoLocation?: GeoLocation isActive: boolean key: string leaders: string[] diff --git a/frontend/src/types/committee.ts b/frontend/src/types/committee.ts index c4fe94dae1..e6567152c2 100644 --- a/frontend/src/types/committee.ts +++ b/frontend/src/types/committee.ts @@ -1,6 +1,6 @@ -import { TopContributors } from 'types/contributor' +import type { TopContributors } from 'types/contributor' -export interface Committee { +export type Committee = { contributorsCount?: number createdAt: number forksCount?: number diff --git a/frontend/src/types/home.ts b/frontend/src/types/home.ts index 42670abaf3..6859b768b7 100644 --- a/frontend/src/types/home.ts +++ b/frontend/src/types/home.ts @@ -1,21 +1,20 @@ -import { TopContributors } from 'types/contributor' -import { EventType } from 'types/event' -import { ProjectIssuesType, ProjectReleaseType, ProjectMilestonesType } from 'types/project' +import type { Chapter } from 'types/chapter' +import type { TopContributors } from 'types/contributor' +import type { EventType } from 'types/event' +import type { IssueType } from 'types/issue' +import type { MilestonesType } from 'types/milestone' +import { ProjectType } from 'types/project' +import type { PullRequestType } from 'types/pullRequest' +import type { ReleaseType } from 'types/release' export type MainPageData = { topContributors: TopContributors[] - recentIssues: ProjectIssuesType[] - recentReleases: ProjectReleaseType[] + recentIssues: IssueType[] + recentReleases: ReleaseType[] upcomingEvents: EventType[] - recentPullRequests: PullRequestsType[] - recentMilestones: ProjectMilestonesType[] - recentChapters: { - createdAt: string - key: string - leaders: string[] - name: string - suggestedLocation: string - }[] + recentPullRequests: PullRequestType[] + recentMilestones: MilestonesType[] + recentChapters: Chapter[] recentPosts: { authorName: string authorImageUrl: string @@ -23,15 +22,7 @@ export type MainPageData = { title: string url: string }[] - recentProjects: { - createdAt: string - key: string - leaders: string[] - name: string - openIssuesCount: number - repositoriesCount: number - type: string - }[] + recentProjects: ProjectType[] sponsors: SponsorType[] statsOverview: { activeChaptersStats: number @@ -48,15 +39,3 @@ export type SponsorType = { sponsorType: string url: string } - -export type PullRequestsType = { - author: { - avatarUrl: string - login: string - name: string - } - organizationName: string - createdAt: string - title: string - url: string -} diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts index 241edc1643..8420d116cd 100644 --- a/frontend/src/types/issue.ts +++ b/frontend/src/types/issue.ts @@ -4,7 +4,7 @@ export type IssuesDataType = { total_pages: number } -export interface IssueType { +export type IssueType = { createdAt: number hint: string labels: string[] diff --git a/frontend/src/types/milestone.ts b/frontend/src/types/milestone.ts new file mode 100644 index 0000000000..f02805a865 --- /dev/null +++ b/frontend/src/types/milestone.ts @@ -0,0 +1,15 @@ +import { User } from 'types/user' + +export type MilestonesType = { + author: User + body: string + closedIssuesCount: number + createdAt: string + openIssuesCount: number + organizationName?: string + progress?: number + repositoryName: string + state: string + title: string + url?: string +} diff --git a/frontend/src/types/modal.ts b/frontend/src/types/modal.ts index c3bc5a13ac..44a8b5bb14 100644 --- a/frontend/src/types/modal.ts +++ b/frontend/src/types/modal.ts @@ -1,7 +1,7 @@ import React from 'react' -import { ButtonType } from 'types/button' +import type { ButtonType } from 'types/button' -export interface ModalProps { +export type ModalProps = { title: string summary: string hint?: string diff --git a/frontend/src/types/organization.ts b/frontend/src/types/organization.ts index 93afc03f41..28608463d3 100644 --- a/frontend/src/types/organization.ts +++ b/frontend/src/types/organization.ts @@ -1,4 +1,4 @@ -export interface OrganizationType { +export type OrganizationType = { avatarUrl: string collaboratorsCount: number company?: string diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts index 5b6f1f7822..79a39c057a 100644 --- a/frontend/src/types/project.ts +++ b/frontend/src/types/project.ts @@ -1,43 +1,9 @@ -import { TopContributors } from 'types/contributor' - -export type Author = { - avatarUrl: string - key: string - login: string - name: string -} - -export type ProjectIssuesType = { - author: Author - createdAt: number - organizationName?: string - repositoryName?: string - title: string - url: string -} - -export type ProjectPullRequestsType = { - author: Author - createdAt: string - organizationName: string - repositoryName?: string - title: string - url: string -} - -export type ProjectMilestonesType = { - author: Author - body: string - closedIssuesCount: number - createdAt: string - openIssuesCount: number - organizationName?: string - progress?: number - repositoryName: string - state: string - title: string - url?: string -} +import type { TopContributors } from 'types/contributor' +import type { IssueType } from 'types/issue' +import { MilestonesType } from 'types/milestone' +import { OrganizationType } from 'types/organization' +import { PullRequestType } from 'types/pullRequest' +import type { ReleaseType } from 'types/release' export type ProjectStatsType = { contributors: number @@ -47,7 +13,8 @@ export type ProjectStatsType = { stars: number } -export interface ProjectType { +export type ProjectType = { + createdAt?: string contributorsCount: number description: string forksCount: number @@ -58,6 +25,7 @@ export interface ProjectType { leaders: string[] level: string name: string + openIssuesCount?: number organizations: string repositoriesCount: number starsCount: number @@ -67,38 +35,25 @@ export interface ProjectType { type: string updatedAt: number url: string - recentIssues?: ProjectIssuesType[] - recentPullRequests?: ProjectPullRequestsType[] - recentReleases?: ProjectReleaseType[] + recentIssues?: IssueType[] + recentPullRequests?: PullRequestType[] + recentReleases?: ReleaseType[] repositories?: RepositoryCardProps[] - recentMilestones?: ProjectMilestonesType[] + recentMilestones?: MilestonesType[] } -export interface RepositoriesCardProps { +export type RepositoriesCardProps = { repositories?: RepositoryCardProps[] } -export interface RepositoryCardProps { +export type RepositoryCardProps = { contributorsCount: number forksCount: number key?: string name: string openIssuesCount: number - organization?: { - login: string - } + organization?: OrganizationType starsCount: number subscribersCount: number url: string } - -export type ProjectReleaseType = { - author: Author - isPreRelease: boolean - name: string - organizationName?: string - publishedAt: number - repositoryName: string - tagName: string - url: string -} diff --git a/frontend/src/types/pullRequest.ts b/frontend/src/types/pullRequest.ts new file mode 100644 index 0000000000..4e52b9c1e3 --- /dev/null +++ b/frontend/src/types/pullRequest.ts @@ -0,0 +1,10 @@ +import type { User } from 'types/user' + +export type PullRequestType = { + author: User + createdAt: string + organizationName: string + repositoryName?: string + title: string + url: string +} diff --git a/frontend/src/types/release.ts b/frontend/src/types/release.ts new file mode 100644 index 0000000000..7a0d2ed7c9 --- /dev/null +++ b/frontend/src/types/release.ts @@ -0,0 +1,13 @@ +import type { User } from 'types/user' + +export type ReleaseType = { + author: User + isPreRelease: boolean + name: string + organizationName?: string + projectName?: string + publishedAt: number + repositoryName: string + tagName: string + url: string +} diff --git a/frontend/src/types/search.ts b/frontend/src/types/search.ts index ec30ca4962..7fdd84508b 100644 --- a/frontend/src/types/search.ts +++ b/frontend/src/types/search.ts @@ -4,7 +4,7 @@ import { OrganizationType } from 'types/organization' import { ProjectType } from 'types/project' import { User } from 'types/user' -export interface MultiSearchBarProps { +export type MultiSearchBarProps = { isLoaded: boolean placeholder: string indexes: string[] diff --git a/frontend/src/types/skeleton.ts b/frontend/src/types/skeleton.ts index f9e0559629..d9cf337fe4 100644 --- a/frontend/src/types/skeleton.ts +++ b/frontend/src/types/skeleton.ts @@ -1,4 +1,4 @@ -export interface CardSkeletonProps { +export type CardSkeletonProps = { showLevel?: boolean showIcons?: boolean showProjectName?: boolean @@ -10,7 +10,7 @@ export interface CardSkeletonProps { numIcons?: number } -export interface UserCardSkeletonProps { +export type UserCardSkeletonProps = { showAvatar?: boolean showName?: boolean showViewProfile?: boolean diff --git a/frontend/src/types/snapshot.ts b/frontend/src/types/snapshot.ts index b7f13a2074..11a0feefe7 100644 --- a/frontend/src/types/snapshot.ts +++ b/frontend/src/types/snapshot.ts @@ -1,14 +1,8 @@ -import { Chapter } from 'types/chapter' -import { ProjectType } from 'types/project' +import type { Chapter } from 'types/chapter' +import type { ProjectType } from 'types/project' +import { ReleaseType } from 'types/release' -export type ReleaseType = { - name: string - publishedAt: string - tagName: string - projectName: string -} - -export interface SnapshotDetailsProps { +export type SnapshotDetailsProps = { endAt: string key: string startAt: string diff --git a/frontend/src/types/sortBy.ts b/frontend/src/types/sortBy.ts index a235c90c74..b826d5bcf9 100644 --- a/frontend/src/types/sortBy.ts +++ b/frontend/src/types/sortBy.ts @@ -1,4 +1,4 @@ -export interface SortByProps { +export type SortByProps = { sortOptions: { key: string; label: string }[] selectedSortOption: string selectedOrder: string diff --git a/frontend/src/types/user.ts b/frontend/src/types/user.ts index 7c8397083d..5557a75024 100644 --- a/frontend/src/types/user.ts +++ b/frontend/src/types/user.ts @@ -1,37 +1,22 @@ -import { RepositoryCardProps } from 'types/project' +import type { IssueType } from 'types/issue' +import type { RepositoryCardProps } from 'types/project' +import { ReleaseType } from 'types/release' export type RepositoryDetails = { key: string ownerKey: string } -export type Issue = { - createdAt: number - number: number - repository: RepositoryDetails - title: string - url: string -} - -export type Release = { - isPreRelease: boolean - name: string - publishedAt: number - repository: RepositoryDetails - tagName: string - url: string -} - -export interface UserType { +export type UserType = { createdAt: T avatarUrl: string followersCount: number followingCount: number - issues?: Issue[] + issues?: IssueType[] key: string login: string publicRepositoriesCount: number - releases?: Release[] + releases?: ReleaseType[] url: string contributionsCount: number issuesCount?: number @@ -47,24 +32,3 @@ export interface UserType { export type User = UserType export type UserDetails = UserType - -export type PullRequest = { - createdAt: string - organizationName: string - repositoryName?: string - title: string - url: string -} - -export type ItemCardPullRequests = { - createdAt: string - title: string - author: { - login: string - avatarUrl: string - key: string - name: string - } - organizationName: string - url: string -} diff --git a/frontend/src/utils/constants.ts b/frontend/src/utils/constants.ts index 192c1415e9..9706a84909 100644 --- a/frontend/src/utils/constants.ts +++ b/frontend/src/utils/constants.ts @@ -1,6 +1,6 @@ import { faGithub, faSlack, faBluesky, faLinkedin } from '@fortawesome/free-brands-svg-icons' -import { Link } from 'types/link' -import { Section } from 'types/section' +import type { Link } from 'types/link' +import type { Section } from 'types/section' export const headerLinks: Link[] = [ { diff --git a/frontend/src/utils/utility.ts b/frontend/src/utils/utility.ts index 1954d32997..295b367c09 100644 --- a/frontend/src/utils/utility.ts +++ b/frontend/src/utils/utility.ts @@ -4,11 +4,11 @@ import relativeTime from 'dayjs/plugin/relativeTime' import { twMerge } from 'tailwind-merge' import { fetchCsrfToken } from 'server/fetchCsrfToken' -import { Chapter } from 'types/chapter' -import { Committee } from 'types/committee' -import { IconType } from 'types/icon' -import { IssueType } from 'types/issue' -import { ProjectType } from 'types/project' +import type { Chapter } from 'types/chapter' +import type { Committee } from 'types/committee' +import type { IconType } from 'types/icon' +import type { IssueType } from 'types/issue' +import type { ProjectType } from 'types/project' import { IconKeys, Icons, urlMappings } from 'utils/data' dayjs.extend(relativeTime) From 7b39bea9da54fd6012cd6e337319a25c3d7e16e4 Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Thu, 12 Jun 2025 21:58:16 +0530 Subject: [PATCH 10/17] fixed more bugs --- frontend/src/types/issue.ts | 6 ++++++ frontend/src/types/release.ts | 3 ++- frontend/src/types/user.ts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts index 8420d116cd..a1e341a048 100644 --- a/frontend/src/types/issue.ts +++ b/frontend/src/types/issue.ts @@ -1,3 +1,5 @@ +import type { RepositoryDetails, User } from 'types/user' + export type IssuesDataType = { issues: IssueType[] open_issues_count: number @@ -5,11 +7,15 @@ export type IssuesDataType = { } export type IssueType = { + author: User createdAt: number hint: string labels: string[] + number?: string + organizationName?: string projectName: string projectUrl: string + repository?: RepositoryDetails repositoryLanguages: string[] summary: string title: string diff --git a/frontend/src/types/release.ts b/frontend/src/types/release.ts index 7a0d2ed7c9..730e85fcd7 100644 --- a/frontend/src/types/release.ts +++ b/frontend/src/types/release.ts @@ -1,4 +1,4 @@ -import type { User } from 'types/user' +import type { RepositoryDetails, User } from 'types/user' export type ReleaseType = { author: User @@ -7,6 +7,7 @@ export type ReleaseType = { organizationName?: string projectName?: string publishedAt: number + repository?: RepositoryDetails repositoryName: string tagName: string url: string diff --git a/frontend/src/types/user.ts b/frontend/src/types/user.ts index 5557a75024..b602b1cea0 100644 --- a/frontend/src/types/user.ts +++ b/frontend/src/types/user.ts @@ -1,6 +1,6 @@ import type { IssueType } from 'types/issue' import type { RepositoryCardProps } from 'types/project' -import { ReleaseType } from 'types/release' +import type { ReleaseType } from 'types/release' export type RepositoryDetails = { key: string From 8c96a3b7f0c1ea3f925a1ecc6bb918695dd9fdcb Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Thu, 12 Jun 2025 22:31:38 +0530 Subject: [PATCH 11/17] updated code --- frontend/src/app/about/page.tsx | 4 +-- frontend/src/app/committees/page.tsx | 2 +- frontend/src/app/contribute/page.tsx | 6 ++-- frontend/src/app/members/[memberKey]/page.tsx | 16 +++++------ frontend/src/app/organizations/page.tsx | 6 ++-- .../src/app/projects/[projectKey]/page.tsx | 4 +-- frontend/src/app/projects/page.tsx | 6 ++-- frontend/src/app/snapshots/[id]/page.tsx | 4 +-- frontend/src/components/DisplayIcon.tsx | 4 +-- frontend/src/components/ItemCardList.tsx | 10 +++---- frontend/src/components/LogoCarousel.tsx | 4 +-- frontend/src/components/Milestones.tsx | 2 +- frontend/src/components/MultiSearch.tsx | 24 ++++++---------- frontend/src/components/RecentIssues.tsx | 4 +-- .../src/components/RecentPullRequests.tsx | 4 +-- frontend/src/components/RecentReleases.tsx | 4 +-- frontend/src/types/button.ts | 2 +- frontend/src/types/card.ts | 28 +++++++++---------- frontend/src/types/event.ts | 2 +- frontend/src/types/home.ts | 28 +++++++++---------- frontend/src/types/icon.ts | 2 +- frontend/src/types/issue.ts | 8 +----- frontend/src/types/milestone.ts | 4 +-- frontend/src/types/modal.ts | 4 +-- frontend/src/types/organization.ts | 2 +- frontend/src/types/project.ts | 24 ++++++++-------- frontend/src/types/pullRequest.ts | 2 +- frontend/src/types/release.ts | 2 +- frontend/src/types/search.ts | 16 +++++------ frontend/src/types/section.ts | 2 +- frontend/src/types/snapshot.ts | 8 +++--- frontend/src/types/user.ts | 14 ++++------ frontend/src/utils/utility.ts | 12 ++++---- 33 files changed, 124 insertions(+), 140 deletions(-) diff --git a/frontend/src/app/about/page.tsx b/frontend/src/app/about/page.tsx index b676ff72f9..de1e5b13f3 100644 --- a/frontend/src/app/about/page.tsx +++ b/frontend/src/app/about/page.tsx @@ -21,7 +21,7 @@ import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_PROJECT_METADATA, GET_TOP_CONTRIBUTORS } from 'server/queries/projectQueries' import { GET_LEADER_DATA } from 'server/queries/userQueries' import type { TopContributors } from 'types/contributor' -import type { ProjectType } from 'types/project' +import type { Project } from 'types/project' import type { User } from 'types/user' import { aboutText, technologies } from 'utils/aboutData' import AnchorTitle from 'components/AnchorTitle' @@ -54,7 +54,7 @@ const About = () => { } ) - const [projectMetadata, setProjectMetadata] = useState(null) + const [projectMetadata, setProjectMetadata] = useState(null) const [topContributors, setTopContributors] = useState([]) useEffect(() => { diff --git a/frontend/src/app/committees/page.tsx b/frontend/src/app/committees/page.tsx index 110d41cb69..e6d59dc054 100644 --- a/frontend/src/app/committees/page.tsx +++ b/frontend/src/app/committees/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import { Committee } from 'types/committee' +import type { Committee } from 'types/committee' import { getFilteredIcons, handleSocialUrls } from 'utils/utility' import Card from 'components/Card' import SearchPageLayout from 'components/SearchPageLayout' diff --git a/frontend/src/app/contribute/page.tsx b/frontend/src/app/contribute/page.tsx index 55361cc6ac..5d07bf3a52 100644 --- a/frontend/src/app/contribute/page.tsx +++ b/frontend/src/app/contribute/page.tsx @@ -4,7 +4,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import React, { useState } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import type { IssueType } from 'types/issue' +import type { Issue } from 'types/issue' import { getFilteredIcons } from 'utils/utility' import Card from 'components/Card' @@ -20,14 +20,14 @@ const ContributePage = () => { searchQuery, handleSearch, handlePageChange, - } = useSearchPage({ + } = useSearchPage({ indexName: 'issues', pageTitle: 'OWASP Issues', }) const [modalOpenIndex, setModalOpenIndex] = useState(null) - const renderContributeCard = (issue: IssueType, index: number) => { + const renderContributeCard = (issue: Issue, index: number) => { const params: string[] = ['createdAt', 'commentsCount'] const filteredIcons = getFilteredIcons(issue, params) diff --git a/frontend/src/app/members/[memberKey]/page.tsx b/frontend/src/app/members/[memberKey]/page.tsx index a37ff6e2fa..2e60a0a1eb 100644 --- a/frontend/src/app/members/[memberKey]/page.tsx +++ b/frontend/src/app/members/[memberKey]/page.tsx @@ -12,11 +12,11 @@ import { useParams } from 'next/navigation' import React, { useState, useEffect, useRef } from 'react' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_USER_DATA } from 'server/queries/userQueries' -import type { IssueType } from 'types/issue' -import type { MilestonesType } from 'types/milestone' +import type { Issue } from 'types/issue' +import type { Milestones } from 'types/milestone' import type { RepositoryCardProps } from 'types/project' -import type { PullRequestType } from 'types/pullRequest' -import type { ReleaseType } from 'types/release' +import type { PullRequest } from 'types/pullRequest' +import type { Release } from 'types/release' import type { UserDetails } from 'types/user' import { formatDate } from 'utils/dateFormatter' import { drawContributions, fetchHeatmapData, HeatmapData } from 'utils/helpers/githubHeatmap' @@ -26,11 +26,11 @@ import LoadingSpinner from 'components/LoadingSpinner' const UserDetailsPage: React.FC = () => { const { memberKey } = useParams() const [user, setUser] = useState() - const [issues, setIssues] = useState([]) + const [issues, setIssues] = useState([]) const [topRepositories, setTopRepositories] = useState([]) - const [milestones, setMilestones] = useState([]) - const [pullRequests, setPullRequests] = useState([]) - const [releases, setReleases] = useState([]) + const [milestones, setMilestones] = useState([]) + const [pullRequests, setPullRequests] = useState([]) + const [releases, setReleases] = useState([]) const [data, setData] = useState({} as HeatmapData) const [isLoading, setIsLoading] = useState(true) const [username, setUsername] = useState('') diff --git a/frontend/src/app/organizations/page.tsx b/frontend/src/app/organizations/page.tsx index 6176fa8b70..d40a0c53c8 100644 --- a/frontend/src/app/organizations/page.tsx +++ b/frontend/src/app/organizations/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import type { OrganizationType } from 'types/organization' +import type { Organization } from 'types/organization' import SearchPageLayout from 'components/SearchPageLayout' import UserCard from 'components/UserCard' @@ -15,7 +15,7 @@ const OrganizationPage = () => { searchQuery, handleSearch, handlePageChange, - } = useSearchPage({ + } = useSearchPage({ indexName: 'organizations', pageTitle: 'GitHub Organizations', hitsPerPage: 24, @@ -23,7 +23,7 @@ const OrganizationPage = () => { const router = useRouter() - const renderOrganizationCard = (organization: OrganizationType) => { + const renderOrganizationCard = (organization: Organization) => { const handleButtonClick = () => { router.push(`/organizations/${organization.login}`) } diff --git a/frontend/src/app/projects/[projectKey]/page.tsx b/frontend/src/app/projects/[projectKey]/page.tsx index 91acd61b6b..d59835e885 100644 --- a/frontend/src/app/projects/[projectKey]/page.tsx +++ b/frontend/src/app/projects/[projectKey]/page.tsx @@ -13,7 +13,7 @@ import { useState, useEffect } from 'react' import { ErrorDisplay, handleAppError } from 'app/global-error' import { GET_PROJECT_DATA } from 'server/queries/projectQueries' import type { TopContributors } from 'types/contributor' -import type { ProjectType } from 'types/project' +import type { Project } from 'types/project' import { capitalize } from 'utils/capitalize' import { formatDate } from 'utils/dateFormatter' import DetailsCard from 'components/CardDetailsPage' @@ -21,7 +21,7 @@ import LoadingSpinner from 'components/LoadingSpinner' const ProjectDetailsPage = () => { const { projectKey } = useParams() const [isLoading, setIsLoading] = useState(true) - const [project, setProject] = useState(null) + const [project, setProject] = useState(null) const [topContributors, setTopContributors] = useState([]) const { data, error: graphQLRequestError } = useQuery(GET_PROJECT_DATA, { variables: { key: projectKey }, diff --git a/frontend/src/app/projects/page.tsx b/frontend/src/app/projects/page.tsx index b019e1a4b5..bc9651ae41 100644 --- a/frontend/src/app/projects/page.tsx +++ b/frontend/src/app/projects/page.tsx @@ -2,7 +2,7 @@ import { useSearchPage } from 'hooks/useSearchPage' import { useRouter } from 'next/navigation' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import type { ProjectType } from 'types/project' +import type { Project } from 'types/project' import { level } from 'utils/data' import { sortOptionsProject } from 'utils/sortingOptions' import { getFilteredIcons } from 'utils/utility' @@ -22,7 +22,7 @@ const ProjectsPage = () => { handlePageChange, handleSortChange, handleOrderChange, - } = useSearchPage({ + } = useSearchPage({ indexName: 'projects', pageTitle: 'OWASP Projects', defaultSortBy: 'default', @@ -30,7 +30,7 @@ const ProjectsPage = () => { }) const router = useRouter() - const renderProjectCard = (project: ProjectType) => { + const renderProjectCard = (project: Project) => { const params: string[] = ['forksCount', 'starsCount', 'contributorsCount'] const filteredIcons = getFilteredIcons(project, params) const handleButtonClick = () => { diff --git a/frontend/src/app/snapshots/[id]/page.tsx b/frontend/src/app/snapshots/[id]/page.tsx index 41bbf29b69..cf5f0b28f4 100644 --- a/frontend/src/app/snapshots/[id]/page.tsx +++ b/frontend/src/app/snapshots/[id]/page.tsx @@ -8,7 +8,7 @@ import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { handleAppError, ErrorDisplay } from 'app/global-error' import { GET_SNAPSHOT_DETAILS } from 'server/queries/snapshotQueries' import type { Chapter } from 'types/chapter' -import type { ProjectType } from 'types/project' +import type { Project } from 'types/project' import type { SnapshotDetailsProps } from 'types/snapshot' import { level } from 'utils/data' import { formatDate } from 'utils/dateFormatter' @@ -38,7 +38,7 @@ const SnapshotDetailsPage: React.FC = () => { } }, [graphQLData, graphQLRequestError, snapshotKey]) - const renderProjectCard = (project: ProjectType) => { + const renderProjectCard = (project: Project) => { const params: string[] = ['forksCount', 'starsCount', 'contributorsCount'] const filteredIcons = getFilteredIcons(project, params) diff --git a/frontend/src/components/DisplayIcon.tsx b/frontend/src/components/DisplayIcon.tsx index 651e24f00b..bb54cfbef1 100644 --- a/frontend/src/components/DisplayIcon.tsx +++ b/frontend/src/components/DisplayIcon.tsx @@ -1,10 +1,10 @@ import { Tooltip } from '@heroui/tooltip' import { millify } from 'millify' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' -import type { IconType } from 'types/icon' +import type { Icon } from 'types/icon' import { IconKeys, Icons } from 'utils/data' -export default function DisplayIcon({ item, icons }: { item: string; icons: IconType }) { +export default function DisplayIcon({ item, icons }: { item: string; icons: Icon }) { // className for the container const containerClassName = [ 'flex flex-row-reverse items-center justify-center gap-1 px-4 pb-1 -ml-2', diff --git a/frontend/src/components/ItemCardList.tsx b/frontend/src/components/ItemCardList.tsx index c3a84f43c7..c2e58e66c4 100644 --- a/frontend/src/components/ItemCardList.tsx +++ b/frontend/src/components/ItemCardList.tsx @@ -3,10 +3,10 @@ import { Tooltip } from '@heroui/tooltip' import Image from 'next/image' import Link from 'next/link' import React, { JSX } from 'react' -import type { IssueType } from 'types/issue' -import type { MilestonesType } from 'types/milestone' -import type { PullRequestType } from 'types/pullRequest' -import type { ReleaseType } from 'types/release' +import type { Issue } from 'types/issue' +import type { Milestones } from 'types/milestone' +import type { PullRequest } from 'types/pullRequest' +import type { Release } from 'types/release' import SecondaryCard from 'components/SecondaryCard' import { TruncatedText } from 'components/TruncatedText' @@ -19,7 +19,7 @@ const ItemCardList = ({ showSingleColumn = true, }: { title: React.ReactNode - data: ReleaseType[] | IssueType[] | PullRequestType[] | MilestonesType[] + data: Release[] | Issue[] | PullRequest[] | Milestones[] icon?: IconProp showAvatar?: boolean showSingleColumn?: boolean diff --git a/frontend/src/components/LogoCarousel.tsx b/frontend/src/components/LogoCarousel.tsx index bcc7bcc178..2376622cc6 100644 --- a/frontend/src/components/LogoCarousel.tsx +++ b/frontend/src/components/LogoCarousel.tsx @@ -1,10 +1,10 @@ import Image from 'next/image' import Link from 'next/link' import { useEffect, useRef } from 'react' -import type { SponsorType } from 'types/home' +import type { Sponsor } from 'types/home' interface MovingLogosProps { - sponsors: SponsorType[] + sponsors: Sponsor[] } export default function MovingLogos({ sponsors }: MovingLogosProps) { diff --git a/frontend/src/components/Milestones.tsx b/frontend/src/components/Milestones.tsx index 23a285d8be..2f7daab1f5 100644 --- a/frontend/src/components/Milestones.tsx +++ b/frontend/src/components/Milestones.tsx @@ -8,7 +8,7 @@ import { import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useRouter } from 'next/navigation' import React from 'react' -import type { MilestonesType } from 'types/milestone' +import type { Milestones as MilestonesType } from 'types/milestone' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import ItemCardList from 'components/ItemCardList' diff --git a/frontend/src/components/MultiSearch.tsx b/frontend/src/components/MultiSearch.tsx index 17cce991cd..bd76a392e3 100644 --- a/frontend/src/components/MultiSearch.tsx +++ b/frontend/src/components/MultiSearch.tsx @@ -15,9 +15,9 @@ import type React from 'react' import { useState, useEffect, useMemo, useCallback, useRef } from 'react' import { fetchAlgoliaData } from 'server/fetchAlgoliaData' import type { Chapter } from 'types/chapter' -import type { EventType } from 'types/event' -import type { OrganizationType } from 'types/organization' -import type { ProjectType } from 'types/project' +import type { Event } from 'types/event' +import type { Organization } from 'types/organization' +import type { Project } from 'types/project' import type { MultiSearchBarProps, Suggestion } from 'types/search' import type { User } from 'types/user' @@ -57,12 +57,7 @@ const MultiSearchBar: React.FC = ({ const data = await fetchAlgoliaData(index, query, pageCount, suggestionCount) return { indexName: index, - hits: data.hits as - | Chapter[] - | EventType[] - | OrganizationType[] - | ProjectType[] - | User[], + hits: data.hits as Chapter[] | Event[] | Organization[] | Project[] | User[], totalPages: data.totalPages || 0, } }) @@ -74,7 +69,7 @@ const MultiSearchBar: React.FC = ({ if (filteredEvents.length > 0) { results.push({ indexName: 'events', - hits: filteredEvents.slice(0, suggestionCount) as EventType[], + hits: filteredEvents.slice(0, suggestionCount) as Event[], totalPages: 1, }) } @@ -95,10 +90,7 @@ const MultiSearchBar: React.FC = ({ }, [debouncedSearch]) const handleSuggestionClick = useCallback( - ( - suggestion: Chapter | ProjectType | User | EventType | OrganizationType, - indexName: string - ) => { + (suggestion: Chapter | Project | User | Event | Organization, indexName: string) => { setSearchQuery(suggestion.name ?? '') setShowSuggestions(false) @@ -107,7 +99,7 @@ const MultiSearchBar: React.FC = ({ router.push(`/chapters/${suggestion.key}`) break case 'events': - window.open((suggestion as EventType).url, '_blank') + window.open((suggestion as Event).url, '_blank') break case 'organizations': // Use type guard to safely access login property @@ -135,7 +127,7 @@ const MultiSearchBar: React.FC = ({ const { index, subIndex } = highlightedIndex const suggestion = suggestions[index].hits[subIndex] handleSuggestionClick( - suggestion as Chapter | OrganizationType | ProjectType | User | EventType, + suggestion as Chapter | Organization | Project | User | Event, suggestions[index].indexName ) } else if (event.key === 'ArrowDown') { diff --git a/frontend/src/components/RecentIssues.tsx b/frontend/src/components/RecentIssues.tsx index bda130cb68..e19064d56b 100644 --- a/frontend/src/components/RecentIssues.tsx +++ b/frontend/src/components/RecentIssues.tsx @@ -2,14 +2,14 @@ import { faCalendar, faFolderOpen, faCircleExclamation } from '@fortawesome/free import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useRouter } from 'next/navigation' import React from 'react' -import type { IssueType } from 'types/issue' +import type { Issue } from 'types/issue' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import ItemCardList from 'components/ItemCardList' import { TruncatedText } from 'components/TruncatedText' interface RecentIssuesProps { - data: IssueType[] + data: Issue[] showAvatar?: boolean } diff --git a/frontend/src/components/RecentPullRequests.tsx b/frontend/src/components/RecentPullRequests.tsx index f2db18a091..7684180dd1 100644 --- a/frontend/src/components/RecentPullRequests.tsx +++ b/frontend/src/components/RecentPullRequests.tsx @@ -2,14 +2,14 @@ import { faCalendar, faCodePullRequest, faFolderOpen } from '@fortawesome/free-s import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useRouter } from 'next/navigation' import React from 'react' -import type { PullRequestType } from 'types/pullRequest' +import type { PullRequest } from 'types/pullRequest' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import ItemCardList from 'components/ItemCardList' import { TruncatedText } from 'components/TruncatedText' interface RecentPullRequestsProps { - data: PullRequestType[] + data: PullRequest[] showAvatar?: boolean } diff --git a/frontend/src/components/RecentReleases.tsx b/frontend/src/components/RecentReleases.tsx index 782e7b04db..e97280838f 100644 --- a/frontend/src/components/RecentReleases.tsx +++ b/frontend/src/components/RecentReleases.tsx @@ -5,14 +5,14 @@ import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/navigation' import React from 'react' -import type { ReleaseType } from 'types/release' +import type { Release } from 'types/release' import { formatDate } from 'utils/dateFormatter' import AnchorTitle from 'components/AnchorTitle' import SecondaryCard from 'components/SecondaryCard' import { TruncatedText } from 'components/TruncatedText' interface RecentReleasesProps { - data: ReleaseType[] + data: Release[] showAvatar?: boolean showSingleColumn?: boolean } diff --git a/frontend/src/types/button.ts b/frontend/src/types/button.ts index c4306dcc04..efc3dc5df0 100644 --- a/frontend/src/types/button.ts +++ b/frontend/src/types/button.ts @@ -1,7 +1,7 @@ import type { IconDefinition } from '@fortawesome/free-solid-svg-icons' import type { JSX } from 'react' -export type ButtonType = { +export type Button = { label: string icon?: JSX.Element onclick?: () => void diff --git a/frontend/src/types/card.ts b/frontend/src/types/card.ts index 669a1986a9..0ccada0921 100644 --- a/frontend/src/types/card.ts +++ b/frontend/src/types/card.ts @@ -1,19 +1,19 @@ import type { IconDefinition } from '@fortawesome/free-solid-svg-icons' import type { JSX } from 'react' -import type { ButtonType } from 'types/button' +import type { Button } from 'types/button' import type { Chapter } from 'types/chapter' import type { TopContributors } from 'types/contributor' -import type { IconType } from 'types/icon' -import type { IssueType } from 'types/issue' +import type { Icon } from 'types/icon' +import type { Issue } from 'types/issue' import type { Level } from 'types/level' -import type { MilestonesType } from 'types/milestone' +import type { Milestones } from 'types/milestone' import type { RepositoryCardProps } from 'types/project' -import type { PullRequestType } from 'types/pullRequest' -import type { ReleaseType } from 'types/release' +import type { PullRequest } from 'types/pullRequest' +import type { Release } from 'types/release' export type CardProps = { - button: ButtonType - icons?: IconType + button: Button + icons?: Icon isActive?: boolean level?: Level projectLink?: string @@ -39,10 +39,10 @@ export interface DetailsCardProps { heatmap?: JSX.Element isActive?: boolean languages?: string[] - pullRequests?: PullRequestType[] - recentIssues?: IssueType[] - recentReleases?: ReleaseType[] - recentMilestones?: MilestonesType[] + pullRequests?: PullRequest[] + recentIssues?: Issue[] + recentReleases?: Release[] + recentMilestones?: Milestones[] repositories?: RepositoryCardProps[] socialLinks?: string[] stats?: stats[] @@ -57,7 +57,7 @@ export interface DetailsCardProps { export interface UserCardProps { avatar: string - button: ButtonType + button: Button className?: string company?: string description?: string @@ -73,5 +73,5 @@ export interface SnapshotCardProps { startAt: string endAt: string title: string - button: ButtonType + button: Button } diff --git a/frontend/src/types/event.ts b/frontend/src/types/event.ts index 225495ae9e..e1bc85a59a 100644 --- a/frontend/src/types/event.ts +++ b/frontend/src/types/event.ts @@ -1,4 +1,4 @@ -export type EventType = { +export type Event = { category: string endDate?: string key: string diff --git a/frontend/src/types/home.ts b/frontend/src/types/home.ts index 6859b768b7..e61946fa30 100644 --- a/frontend/src/types/home.ts +++ b/frontend/src/types/home.ts @@ -1,19 +1,19 @@ import type { Chapter } from 'types/chapter' import type { TopContributors } from 'types/contributor' -import type { EventType } from 'types/event' -import type { IssueType } from 'types/issue' -import type { MilestonesType } from 'types/milestone' -import { ProjectType } from 'types/project' -import type { PullRequestType } from 'types/pullRequest' -import type { ReleaseType } from 'types/release' +import type { Event } from 'types/event' +import type { Issue } from 'types/issue' +import type { Milestones } from 'types/milestone' +import type { Project } from 'types/project' +import type { PullRequest } from 'types/pullRequest' +import type { Release } from 'types/release' export type MainPageData = { topContributors: TopContributors[] - recentIssues: IssueType[] - recentReleases: ReleaseType[] - upcomingEvents: EventType[] - recentPullRequests: PullRequestType[] - recentMilestones: MilestonesType[] + recentIssues: Issue[] + recentReleases: Release[] + upcomingEvents: Event[] + recentPullRequests: PullRequest[] + recentMilestones: Milestones[] recentChapters: Chapter[] recentPosts: { authorName: string @@ -22,8 +22,8 @@ export type MainPageData = { title: string url: string }[] - recentProjects: ProjectType[] - sponsors: SponsorType[] + recentProjects: Project[] + sponsors: Sponsor[] statsOverview: { activeChaptersStats: number activeProjectsStats: number @@ -33,7 +33,7 @@ export type MainPageData = { } } -export type SponsorType = { +export type Sponsor = { imageUrl: string name: string sponsorType: string diff --git a/frontend/src/types/icon.ts b/frontend/src/types/icon.ts index 4518dbdbbd..96b7f95a52 100644 --- a/frontend/src/types/icon.ts +++ b/frontend/src/types/icon.ts @@ -1,3 +1,3 @@ -export type IconType = { +export type Icon = { [key: string]: string | number } diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts index a1e341a048..5bc8e06ec1 100644 --- a/frontend/src/types/issue.ts +++ b/frontend/src/types/issue.ts @@ -1,12 +1,6 @@ import type { RepositoryDetails, User } from 'types/user' -export type IssuesDataType = { - issues: IssueType[] - open_issues_count: number - total_pages: number -} - -export type IssueType = { +export type Issue = { author: User createdAt: number hint: string diff --git a/frontend/src/types/milestone.ts b/frontend/src/types/milestone.ts index f02805a865..ebdcdbfd74 100644 --- a/frontend/src/types/milestone.ts +++ b/frontend/src/types/milestone.ts @@ -1,6 +1,6 @@ -import { User } from 'types/user' +import type { User } from 'types/user' -export type MilestonesType = { +export type Milestones = { author: User body: string closedIssuesCount: number diff --git a/frontend/src/types/modal.ts b/frontend/src/types/modal.ts index 44a8b5bb14..20002bfdc9 100644 --- a/frontend/src/types/modal.ts +++ b/frontend/src/types/modal.ts @@ -1,5 +1,5 @@ import React from 'react' -import type { ButtonType } from 'types/button' +import type { Button } from 'types/button' export type ModalProps = { title: string @@ -7,7 +7,7 @@ export type ModalProps = { hint?: string isOpen: boolean onClose: () => void - button: ButtonType + button: Button children?: React.ReactNode description: string } diff --git a/frontend/src/types/organization.ts b/frontend/src/types/organization.ts index 28608463d3..3502a1f4ac 100644 --- a/frontend/src/types/organization.ts +++ b/frontend/src/types/organization.ts @@ -1,4 +1,4 @@ -export type OrganizationType = { +export type Organization = { avatarUrl: string collaboratorsCount: number company?: string diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts index 79a39c057a..041c4fddfa 100644 --- a/frontend/src/types/project.ts +++ b/frontend/src/types/project.ts @@ -1,11 +1,11 @@ import type { TopContributors } from 'types/contributor' -import type { IssueType } from 'types/issue' -import { MilestonesType } from 'types/milestone' -import { OrganizationType } from 'types/organization' -import { PullRequestType } from 'types/pullRequest' -import type { ReleaseType } from 'types/release' +import type { Issue } from 'types/issue' +import type { Milestones } from 'types/milestone' +import type { Organization } from 'types/organization' +import type { PullRequest } from 'types/pullRequest' +import type { Release } from 'types/release' -export type ProjectStatsType = { +export type ProjectStats = { contributors: number forks: number issues: number @@ -13,7 +13,7 @@ export type ProjectStatsType = { stars: number } -export type ProjectType = { +export type Project = { createdAt?: string contributorsCount: number description: string @@ -35,11 +35,11 @@ export type ProjectType = { type: string updatedAt: number url: string - recentIssues?: IssueType[] - recentPullRequests?: PullRequestType[] - recentReleases?: ReleaseType[] + recentIssues?: Issue[] + recentPullRequests?: PullRequest[] + recentReleases?: Release[] repositories?: RepositoryCardProps[] - recentMilestones?: MilestonesType[] + recentMilestones?: Milestones[] } export type RepositoriesCardProps = { @@ -52,7 +52,7 @@ export type RepositoryCardProps = { key?: string name: string openIssuesCount: number - organization?: OrganizationType + organization?: Organization starsCount: number subscribersCount: number url: string diff --git a/frontend/src/types/pullRequest.ts b/frontend/src/types/pullRequest.ts index 4e52b9c1e3..47c15ad798 100644 --- a/frontend/src/types/pullRequest.ts +++ b/frontend/src/types/pullRequest.ts @@ -1,6 +1,6 @@ import type { User } from 'types/user' -export type PullRequestType = { +export type PullRequest = { author: User createdAt: string organizationName: string diff --git a/frontend/src/types/release.ts b/frontend/src/types/release.ts index 730e85fcd7..296faa5e86 100644 --- a/frontend/src/types/release.ts +++ b/frontend/src/types/release.ts @@ -1,6 +1,6 @@ import type { RepositoryDetails, User } from 'types/user' -export type ReleaseType = { +export type Release = { author: User isPreRelease: boolean name: string diff --git a/frontend/src/types/search.ts b/frontend/src/types/search.ts index 7fdd84508b..2e0e84872e 100644 --- a/frontend/src/types/search.ts +++ b/frontend/src/types/search.ts @@ -1,19 +1,19 @@ -import { Chapter } from 'types/chapter' -import { EventType } from 'types/event' -import { OrganizationType } from 'types/organization' -import { ProjectType } from 'types/project' -import { User } from 'types/user' +import type { Chapter } from 'types/chapter' +import type { Event } from 'types/event' +import type { Organization } from 'types/organization' +import type { Project } from 'types/project' +import type { User } from 'types/user' -export type MultiSearchBarProps = { +export interface MultiSearchBarProps { isLoaded: boolean placeholder: string indexes: string[] initialValue?: string - eventData?: EventType[] + eventData?: Event[] } export type Suggestion = { indexName: string - hits: Chapter[] | EventType[] | OrganizationType[] | ProjectType[] | User[] + hits: Chapter[] | Event[] | Organization[] | Project[] | User[] totalPages: number } diff --git a/frontend/src/types/section.ts b/frontend/src/types/section.ts index 6f9f4a35f8..d38aa61a04 100644 --- a/frontend/src/types/section.ts +++ b/frontend/src/types/section.ts @@ -1,4 +1,4 @@ -import { Link } from 'types/link' +import type { Link } from 'types/link' export type Section = { title: string diff --git a/frontend/src/types/snapshot.ts b/frontend/src/types/snapshot.ts index 11a0feefe7..9c34008570 100644 --- a/frontend/src/types/snapshot.ts +++ b/frontend/src/types/snapshot.ts @@ -1,14 +1,14 @@ import type { Chapter } from 'types/chapter' -import type { ProjectType } from 'types/project' -import { ReleaseType } from 'types/release' +import type { Project } from 'types/project' +import type { Release } from 'types/release' export type SnapshotDetailsProps = { endAt: string key: string startAt: string title: string - newReleases: ReleaseType[] - newProjects: ProjectType[] + newReleases: Release[] + newProjects: Project[] newChapters: Chapter[] } diff --git a/frontend/src/types/user.ts b/frontend/src/types/user.ts index b602b1cea0..976d1ab113 100644 --- a/frontend/src/types/user.ts +++ b/frontend/src/types/user.ts @@ -1,22 +1,22 @@ -import type { IssueType } from 'types/issue' +import type { Issue } from 'types/issue' import type { RepositoryCardProps } from 'types/project' -import type { ReleaseType } from 'types/release' +import type { Release } from 'types/release' export type RepositoryDetails = { key: string ownerKey: string } -export type UserType = { +export type User = { createdAt: T avatarUrl: string followersCount: number followingCount: number - issues?: IssueType[] + issues?: Issue[] key: string login: string publicRepositoriesCount: number - releases?: ReleaseType[] + releases?: Release[] url: string contributionsCount: number issuesCount?: number @@ -29,6 +29,4 @@ export type UserType = { topRepositories?: RepositoryCardProps[] } -export type User = UserType - -export type UserDetails = UserType +export type UserDetails = User diff --git a/frontend/src/utils/utility.ts b/frontend/src/utils/utility.ts index 295b367c09..bafd9a2f48 100644 --- a/frontend/src/utils/utility.ts +++ b/frontend/src/utils/utility.ts @@ -6,9 +6,9 @@ import { fetchCsrfToken } from 'server/fetchCsrfToken' import type { Chapter } from 'types/chapter' import type { Committee } from 'types/committee' -import type { IconType } from 'types/icon' -import type { IssueType } from 'types/issue' -import type { ProjectType } from 'types/project' +import type { Icon } from 'types/icon' +import type { Issue } from 'types/issue' +import type { Project } from 'types/project' import { IconKeys, Icons, urlMappings } from 'utils/data' dayjs.extend(relativeTime) @@ -17,10 +17,10 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } -type projectType = ProjectType | IssueType | Committee | Chapter +type projectType = Project | Issue | Committee | Chapter -export const getFilteredIcons = (project: projectType, params: string[]): IconType => { - const filteredIcons = params.reduce((acc: IconType, key) => { +export const getFilteredIcons = (project: projectType, params: string[]): Icon => { + const filteredIcons = params.reduce((acc: Icon, key) => { if (Icons[key as IconKeys] && project[key as keyof typeof project] !== undefined) { if (key === 'createdAt') { acc[key] = dayjs.unix(project[key as keyof projectType] as unknown as number).fromNow() From afc1821452dd92ac6a75bfed7df14ff00d684c75 Mon Sep 17 00:00:00 2001 From: Abhay Mishra Date: Thu, 12 Jun 2025 22:45:24 +0530 Subject: [PATCH 12/17] fixed code --- frontend/src/app/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 53595ef3f7..9d464f5b31 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -23,7 +23,7 @@ import { fetchAlgoliaData } from 'server/fetchAlgoliaData' import { GET_MAIN_PAGE_DATA } from 'server/queries/homeQueries' import { AlgoliaResponse } from 'types/algolia' import { Chapter } from 'types/chapter' -import { EventType } from 'types/event' +import { Event } from 'types/event' import { MainPageData } from 'types/home' import { capitalize } from 'utils/capitalize' import { formatDate, formatDateRange } from 'utils/dateFormatter' @@ -163,7 +163,7 @@ export default function Home() { className="overflow-hidden" >
- {data.upcomingEvents.map((event: EventType, index: number) => ( + {data.upcomingEvents.map((event: Event, index: number) => (