chore: move toApiLang util to hotel trpc folder

This commit is contained in:
Chuma McPhoy
2024-07-04 15:05:02 +02:00
parent 74993f6c3c
commit f89d17cd7f
3 changed files with 27 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
import { Lang } from "@/constants/languages"
const langMap: { [key in Lang]: string } = {
[Lang.en]: "En",
[Lang.sv]: "Sv",
[Lang.no]: "No",
[Lang.fi]: "Fi",
[Lang.da]: "Da",
[Lang.de]: "De",
}
/**
* Helper function to convert Lang enum to uppercase
* Needed for the Hotel endpoint.
*/
export const toApiLang = (lang: Lang): string => {
const result = langMap[lang]
if (!result) {
throw new Error("Invalid language")
}
return result
}