diff --git a/app/occurrences/[occurrence_id]/page.tsx b/app/occurrences/[occurrence_id]/page.tsx index fbbcaaf2..6447a2ed 100644 --- a/app/occurrences/[occurrence_id]/page.tsx +++ b/app/occurrences/[occurrence_id]/page.tsx @@ -16,7 +16,7 @@ import { authOptions } from '@/lib/auth'; import classNames from '@/lib/classNames'; import { checkOccurrenceBookmarkExistence } from '@/lib/queries/occurrenceBookmarks'; import { getOccurrenceById } from '@/lib/queries/occurrences'; -import type { OccurrenceTabKeys, OccurrenceTabsArray } from '@/types/airbroke'; +import type { OccurrenceTabKeys, OccurrenceTabs } from '@/types/airbroke'; import type { Metadata, Route } from 'next'; import { getServerSession } from 'next-auth'; import Link from 'next/link'; @@ -50,7 +50,7 @@ export default async function Occurrence({ params, searchParams }: ComponentProp ? (searchParams.tab as OccurrenceTabKeys) : 'backtrace'; - const tabs: OccurrenceTabsArray = { + const tabs: OccurrenceTabs = { backtrace: { id: 'backtrace', name: 'Backtrace', diff --git a/app/projects/[project_id]/edit/page.tsx b/app/projects/[project_id]/edit/page.tsx index 4fd37aca..4288250e 100644 --- a/app/projects/[project_id]/edit/page.tsx +++ b/app/projects/[project_id]/edit/page.tsx @@ -8,18 +8,18 @@ import Overview from '@/components/project/Overview'; import classNames from '@/lib/classNames'; import { jsclientTemplate, rubyTemplate } from '@/lib/configTemplates'; import { getProjectById } from '@/lib/queries/projects'; +import type { ProjectTabs } from '@/types/airbroke'; import type { Route } from 'next'; import Link from 'next/link'; import { redirect } from 'next/navigation'; import { SlPencil, SlSettings, SlWrench } from 'react-icons/sl'; -export default async function Project({ - params, - searchParams, -}: { +type ComponentProps = { params: { project_id: string }; searchParams: Record; -}) { +}; + +export default async function Project({ params, searchParams }: ComponentProps) { const currentTab = searchParams.tab ?? 'overview'; const currentErrorMessage = searchParams.errorMessage; @@ -31,14 +31,29 @@ export default async function Project({ REPLACE_PROJECT_KEY: project.api_key, }; - const tabs = [ - { id: 'overview', name: 'Overview', current: currentTab === 'overview', icon: SlSettings }, - { id: 'integrations', name: 'Integrations', current: currentTab === 'integrations', icon: SlWrench }, - { id: 'edit', name: 'Edit', current: currentTab === 'edit', icon: SlPencil }, - ].map((tab) => ({ - ...tab, - href: `/projects/${project.id}/edit?tab=${tab.id}` as Route, - })); + const tabs: ProjectTabs = { + overview: { + id: 'overview', + name: 'Overview', + current: currentTab === 'overview', + icon: SlSettings, + href: `/projects/${project.id}/edit?tab=overview` as Route, + }, + integrations: { + id: 'integrations', + name: 'Integrations', + current: currentTab === 'integrations', + icon: SlWrench, + href: `/projects/${project.id}/edit?tab=integrations` as Route, + }, + edit: { + id: 'edit', + name: 'Edit', + current: currentTab === 'edit', + icon: SlPencil, + href: `/projects/${project.id}/edit?tab=edit` as Route, + }, + }; const breadcrumbs = [ { @@ -47,7 +62,7 @@ export default async function Project({ current: false, }, { - name: tabs.find((tab) => tab.current)?.name || 'Overview', + name: Object.values(tabs).find((tab) => tab.current)?.name || 'Overview', href: `/projects/${project.id}/edit` as Route, current: true, }, @@ -76,24 +91,10 @@ export default async function Project({
-
- - -
-
-
-
diff --git a/types/airbroke.d.ts b/types/airbroke.d.ts index 7f77552a..368d2ead 100644 --- a/types/airbroke.d.ts +++ b/types/airbroke.d.ts @@ -21,8 +21,13 @@ export type Tab = { href: Route; }; -export type OccurrenceTabsArray = { + +export type OccurrenceTabKeys = 'backtrace' | 'context' | 'environment' | 'session' | 'params' | 'chart' | 'toolbox'; +export type OccurrenceTabs = { [K in OccurrenceTabKeys]: Tab | undefined; }; -export type OccurrenceTabKeys = 'backtrace' | 'context' | 'environment' | 'session' | 'params' | 'chart' | 'toolbox'; +export type ProjectTabKeys = 'overview' | 'integrations' | 'edit'; +export type ProjectTabs = { + [K in ProjectTabKeys]: Tab; +};