import { graphql } from '@assets/interfaces/gqlApi/gql';
import { gql } from '@apollo/client';

export const MENU_FIELDS = graphql(`
   fragment MenuFields on MenuItem {
      id,
      url,
      name,
      nameShort,
      parent {
         id
      },
      children {
         id,
         name,
         nameShort,
         url,
         hasChildren
         photo {
            id
            source
         },
         isVirtual
      },
      photo {
         id
         source
      },
      isVirtual
   }
`);

export const GET_SECTIONS = graphql(`
   query getMenu($id: Int){
      menu(id: $id) {
         ...MenuFields
      }
   }
`);

export const GET_SECTIONS_ROOT = graphql(`
   query getMenuRoot {
      menu {
         id,
         name,
         nameShort,
         url,
         hasChildren
         photo {
            id
            source
         },
         isVirtual
      }
   }
`);

export const PAGE_FIELDS = graphql(`
   fragment PageFields on Page {
      id
      name
      url
      target
   }
`);

export const PAGE_ITEM = graphql(`
   fragment PageItem on Page {
      ...PageFields
      children {
         ...PageFields
      }
   }
`);

export const GET_PAGES = graphql(`
   query getPages($label: String!) {
      pages(label: $label) {
         ...PageItem
      }
   }
`);

export const GET_MENU_CONTENT = graphql(`
   query getMenuContent {
      header: menuHeader
      footer: menuFooter
   }
`);

export const GET_MENU_ADDITIONAL_CONTENT = graphql(`
    query getMenuAdditionalContent ($id: Int!) {
       content: menuAdditionalContent (id: $id)
    }
`);

export const GET_MENU_ADDITIONAL_CONTENT_SIDE = graphql(`
   query getMenuAdditionalContentSide ($id: Int!) {
      content: menuAdditionalContentSide (id: $id)
   }
`);


export const GET_SECTIONS_USER_CURRENCY = graphql(`
   query get_currency_user_sections {
      menuRoot: menu {
         id,
         name
         nameShort
      },
      currency {
         code,
         active
      }
      user: me{
         userName
      }
   }
`);


export const GET_SECTIONS_USER_CURRENCY_ELNINO = graphql(`
   query get_currency_user_sections_elnino($id: Int) {
        menu(id: $id) {
        parents{
        id
        },
        ...MenuFields
      },
     menuRoot: menu {
        id,
        url,
        name,
      },
      currency {
         id: code,
         active
      }
      contexts {
         languages {
            code
            name
            isActive
         }
      }
      user: me {
         userName
      }
   }
`);

