Files
tripwithbonus/frontend/lib/utils/pathMapper.ts

16 lines
495 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { SourceType } from '@/app/types'
const pathToSourceMap: Record<string, SourceType> = {
techSupport: 'contact-us', // берем в кавычки значение с дефисом
account: 'account',
}
export const getSourceFromPath = (pathname: string): SourceType => {
const cleanPath = pathname.replace(/^\//, '')
const source = pathToSourceMap[cleanPath] || 'contact-us' // дефолтное значение
// console.log('Final source:', source)
return source
}