Files
medusa-store/packages/admin-next/dashboard/src/lib/format-provider.ts
2024-04-09 18:46:53 +02:00

19 lines
480 B
TypeScript

/**
* Providers only have an ID to identify them. This function formats the ID
* into a human-readable string.
*
* Format example: pp_stripe-blik_dkk
*
* @param id - The ID of the provider
* @returns A formatted string
*/
export const formatProvider = (id: string) => {
const [_, name, type] = id.split("_")
return (
name
.split("-")
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
.join(" ") + (type ? ` (${type.toUpperCase()})` : "")
)
}