Skip to content

Commit

Permalink
errors #96
Browse files Browse the repository at this point in the history
  • Loading branch information
djobbo committed Jan 10, 2024
1 parent a9b9198 commit 9677b95
Show file tree
Hide file tree
Showing 37 changed files with 1,899 additions and 916 deletions.
2 changes: 1 addition & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
- [ ] migrate providers to zustand
- [ ] sitemap
- [ ] replace icons with lucide.dev icons
- [ ] remove axios
- [x] remove axios
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { ErrorDisplay } from "@/app/[locale]/_layout/ErrorDisplay"
import { msg } from "@lingui/macro"
import { useLingui } from "@lingui/react"

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
const { _ } = useLingui()

return (
<ErrorDisplay
reset={reset}
title={_(msg`Failed to load the clan rankings :(`)}
error={error}
/>
)
}
23 changes: 23 additions & 0 deletions app/app/[locale]/(rankings)/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { ErrorDisplay } from "../_layout/ErrorDisplay"
import { msg } from "@lingui/macro"
import { useLingui } from "@lingui/react"

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
const { _ } = useLingui()

return (
<ErrorDisplay
reset={reset}
title={_(msg`An unknown error occured :(`)}
error={error}
/>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { ErrorDisplay } from "@/app/[locale]/_layout/ErrorDisplay"
import { msg } from "@lingui/macro"
import { useLingui } from "@lingui/react"

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
const { _ } = useLingui()

return (
<ErrorDisplay
reset={reset}
title={_(msg`Failed to load the power rankings :(`)}
error={error}
/>
)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export default function RankingsRotatingPage() {
throw new Error("Not implemented")

return <>Power rankings Coming soon™</>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { ErrorDisplay } from "@/app/[locale]/_layout/ErrorDisplay"
import { msg } from "@lingui/macro"
import { useLingui } from "@lingui/react"

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
const { _ } = useLingui()

return (
<ErrorDisplay
reset={reset}
title={_(msg`Failed to load the rankings :(`)}
error={error}
/>
)
}
23 changes: 23 additions & 0 deletions app/app/[locale]/(rankings)/ranked/queue/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { ErrorDisplay } from "@/app/[locale]/_layout/ErrorDisplay"
import { msg } from "@lingui/macro"
import { useLingui } from "@lingui/react"

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
const { _ } = useLingui()

return (
<ErrorDisplay
reset={reset}
title={_(msg`Failed to load the ranked queue :(`)}
error={error}
/>
)
}
12 changes: 7 additions & 5 deletions app/app/[locale]/(stats)/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { ErrorDisplay } from "../_layout/ErrorDisplay"
import { msg } from "@lingui/macro"
import { useEffect } from "react"
import { useLingui } from "@lingui/react"

export default function Error({
Expand All @@ -13,9 +12,12 @@ export default function Error({
reset: () => void
}) {
const { _ } = useLingui()
useEffect(() => {
// TODO: Log the error to an error reporting service
}, [error])

return <ErrorDisplay reset={reset} title={_(msg`Failed to fetch stats`)} />
return (
<ErrorDisplay
reset={reset}
title={_(msg`Failed to fetch stats`)}
error={error}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const rankedBannerClassName = css({
opacity: 0.08,
transform: "translateX(25%) rotate(15deg)",
zIndex: -1,
})()
})().className

export const TeamCard = ({ playerId, team }: TeamCardProps) => {
const { playerName, teammate } = getPlayerTeam(playerId, team)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const tabClassName = cn(
borderColor: theme.colors.text,
color: theme.colors.text,
},
})(),
})().className,
)

export const PlayerStatsTabs = () => {
Expand Down
2 changes: 1 addition & 1 deletion app/app/[locale]/(stats)/player/[playerId]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { type ReactNode, cache } from "react"
import { getPlayerRanked, getPlayerStats } from "bhapi"
import { supabaseService } from "db/supabase/service"

type PlayerStatsLayoutProps = {
export type PlayerStatsLayoutProps = {
children: ReactNode
params: {
playerId: string
Expand Down
8 changes: 8 additions & 0 deletions app/app/[locale]/_layout/ErrorDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ import { Button } from "ui/base/Button"
import { DiscordIcon, GithubIcon } from "ui/icons"
import { SectionTitle } from "@/components/layout/SectionTitle"
import { Trans } from "@lingui/macro"
import { useEffect } from "react"

type ErrorDisplayProps = {
title?: string
reset: () => void
error: Error & { digest?: string }
}

export const ErrorDisplay = ({
title = "Oops, something went wrong",
reset,
error,
}: ErrorDisplayProps) => {
useEffect(() => {
console.log("error", error)

Check failure on line 19 in app/app/[locale]/_layout/ErrorDisplay.tsx

View workflow job for this annotation

GitHub Actions / Analyze (Check Lint, pnpm ci:lint)

Unexpected console statement
// TODO: Log the error to an error reporting service
}, [error])

return (
<div>
<SectionTitle className="text-center">{title}</SectionTitle>
Expand Down
2 changes: 1 addition & 1 deletion app/app/[locale]/_layout/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const sideNavIconClassName = css({
top: "-0.375rem",
right: "-0.375rem",
},
})()
})().className

const SideNavIcon = ({
className,
Expand Down
23 changes: 23 additions & 0 deletions app/app/[locale]/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { ErrorDisplay } from "./_layout/ErrorDisplay"
import { msg } from "@lingui/macro"
import { useLingui } from "@lingui/react"

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
const { _ } = useLingui()

return (
<ErrorDisplay
reset={reset}
title={_(msg`An unknown error occured :(`)}
error={error}
/>
)
}
Loading

0 comments on commit 9677b95

Please sign in to comment.