export function isTokenExpired(token: string): boolean {
  try {
    const payload = JSON.parse(atob(token.split('.')[1])) as { exp?: number }
    if (!payload || !payload.exp) {
        return true
    }

    const currentTime = Math.floor(Date.now() / 1000)
    const isExpired = payload.exp < currentTime
    return isExpired
  } catch (error) {
    return true
  }
}

export function clearExpiredToken(): void {
  const token = localStorage.getItem('authToken')
  if (token && isTokenExpired(token)) {
    localStorage.removeItem('authToken')
  } else if (token) {
  } else {
  }
}