from typing import Any, Dict, Optional, Tuple, List
from app.core.security import generate_new_access_token


# Refreshes the Access token if the Refresh token is still valid
def refresh_access_token_service(
        refresh_token: str) -> Tuple[Dict[str, Any], List[int], Optional[Dict[str, Any]]]:
    if not refresh_token:
        return ({'error': 'Nije dohvaćen refresh token'}, [401], None)

    response, status_codes, tokens = generate_new_access_token(
        refresh_token=refresh_token)

    return (response, status_codes, tokens)
