import {toast} from "vue3-toastify";

export const signInWithGoogle = async () => {
    try {
        const response = await $axios.get(`/auth/google/url`)
        window.location.href = response.data.url
    } catch (error) {
        console.error('Error getting Google auth URL:', error)
        // @ts-ignore
        toast.error((useNuxtApp()?.$t || useNuxtApp()?.$i18n?.t)('Register failed'))
        throw error
    }
}

export const signInWithFacebook = async () => {
    try {
        const response = await $axios.get(`/auth/facebook/url`)
        window.location.href = response.data.url
        // @ts-ignore
        toast.error((useNuxtApp()?.$t || useNuxtApp()?.$i18n?.t)('Register failed'))
    } catch (error) {
        console.error('Error getting Facebook auth URL:', error)
        throw error
    }
}