import { useBaseConnector } from '@/UI-kit/composables';
import { ICountry, IRegion } from '@/configs/type';
import { useUiKitConfigStore } from '@/configs/store';
import { storeToRefs } from 'pinia';

export default function (authToken = '') {
    const configStore = useUiKitConfigStore();
    const { userAuthToken } = storeToRefs(configStore);

    const baseConnector = useBaseConnector(userAuthToken.value || authToken);
    const getCountryList = async (): Promise<ICountry[]> =>
        baseConnector.get<ICountry[]>('/api/config/country');

    const getRegionList = async (): Promise<IRegion[]> =>
        baseConnector.get<IRegion[]>('/api/rosmigrant/config/directory/region');

    return {
        getCountryList,
        getRegionList,
    };
}
