Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let env: ServerEnv
* Initializes and parses given environment variables using zod
* @returns Initialized env vars
*/
export function initEnv() {
function initEnv() {
// biome-ignore lint/nursery/noProcessEnv: This should be the only place to use process.env directly
const envData = envSchema.safeParse(process.env)

Expand Down
3 changes: 2 additions & 1 deletion app/localization/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { InitOptions } from "i18next"
import { supportedLanguages } from "./resource"

export default {
Expand All @@ -8,4 +9,4 @@ export default {
fallbackLng: "en",
// The default namespace of i18next is "translation", but you can customize it here
defaultNS: "common",
}
} satisfies Omit<InitOptions, "react" | "detection">
9 changes: 9 additions & 0 deletions app/localization/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ export const resources: Record<Language, Resource> = {
common: bosnian,
},
}

declare module "i18next" {
export interface CustomTypeOptions {
defaultNS: "common"
fallbackNS: "common"
// custom resources type
resources: Resource
}
}
20 changes: 18 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,24 @@ export const Layout = ({ children }: { children: React.ReactNode }) => {
export const ErrorBoundary = () => {
const error = useRouteError()
const { t } = useTranslation()

const errorStatusCode = isRouteErrorResponse(error) ? error.status : "500"
// Constrain the generic type so we don't provide a non-existent key
const statusCode = () => {
if (!isRouteErrorResponse(error)) {
return "500"
}
// Supported error code messages
switch (error.status) {
case 200:
return "200"
case 403:
return "403"
case 404:
return "404"
default:
return "500"
}
}
const errorStatusCode = statusCode()

return (
<div className="placeholder-index relative h-full min-h-screen w-screen flex items-center bg-gradient-to-b from-gray-50 to-gray-100 dark:from-blue-950 dark:to-blue-900 justify-center dark:bg-white sm:pb-16 sm:pt-8">
Expand Down
57 changes: 0 additions & 57 deletions app/utils/dates.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion app/utils/dates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTimeZone } from "../services/client-hints"

export function convertTz(date: string | Date, tzString: string) {
function convertTz(date: string | Date, tzString: string) {
const dateToConvert = typeof date === "string" ? new Date(date) : date
// Convert to the target timezone
const convertedDate = new Date(dateToConvert.toLocaleString("en-US", { timeZone: tzString }))
Expand Down