const splitRoutePath = (routePath: string): string[] => {
    const routeParts = routePath.split('/').filter((part) => part !== '')

    const routeArray: string[] = []
    let currentRoute = ''

    for (const part of routeParts) {
        currentRoute += `/${part}`
        routeArray.push(currentRoute)
    }

    return routeArray
}

const formatNumber = (number: number): string => {
    return new Intl.NumberFormat('id-ID').format(number)
}

const formatPercentage = (number: string | number): string => {
    const value = parseFloat(number.toString())
    const result = `${value.toFixed(2)}`
    if (result.includes('.00')) {
        return `${result.replace('.00', '')}%`
    } else {
        return `${result}%`
    }
}

const isNumber = (value: any): boolean => {
    return !isNaN(value)
}

export {
    splitRoutePath,
    formatNumber,
    formatPercentage,
    isNumber
}