chore: move toApiLang util to hotel trpc folder
This commit is contained in:
22
server/routers/hotels/utils.ts
Normal file
22
server/routers/hotels/utils.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user