<script lang="ts">
    import '../style/style.scss'
    import { setContext } from 'svelte'
    import '$utils/polyfills'
    // Components
    import Footer from '$components/organisms/Footer.svelte'

    export let data: any

    // Set global data
    setContext('global', data)

    // console.log(data)
</script>

<slot />

<Footer />

<script context="module" lang="ts">
    import { fetchAPI } from '$utils/api'

    export async function load ({ page, session, fetch, context }) {
        const res = await fetchAPI(`
            query {
                location {
                    name
                    slug
                    country {
                        name
                        slug
                        flag {
                            id
                        }
                    }
                    date_updated
                }

                country {
                    name
                    slug
                    flag {
                        id
                    }
                }

                continent {
                    name
                    slug
                }

                settings {
                    seo_name
                    seo_title
                    seo_description
                    instagram
                    footer_links
                }
            }
        `)

        const { data } = res

        return {
            props: {
                data,
            }
        }
    }
</script>