export const defaultModel = {
  type: 'section',
  label: 'General',
  noCreate: true,
  fields: [
    { type: 'text', label: 'Id', name: '_id', noUpdate: true, noMutation: true, noCreate: true },
    {
      type: 'date',
      label: 'createdAt',
      name: 'createdAt',
      noCreate: true,
      noUpdate: true,
      noMutation: true,
    },
    {
      type: 'date',
      label: 'updatedAt',
      name: 'updatedAt',
      noCreate: true,
      noUpdate: true,
      noMutation: true,
    },
  ],
};

export const SEOModel = {
  type: 'section',
  label: 'SEO',
  side: true,
  fields: [
    { type: 'multi', label: 'title', name: 'seo.title' },
    { type: 'multiarea', label: 'description', name: 'seo.description' },
    { type: 'multi', label: 'keywords', name: 'seo.keywords' },
  ],
};

export const categoriesModel = {
  type: 'section',
  label: 'Categories',
  fields: [
    {
      type: 'select',
      label: 'Categories',
      name: 'categoryIds',
      noDetail: true,
      multiple: true,
      api: {
        resource: 'articleCategories',
      },
      modelValues: {
        value: '_id',
        text: { value: 'title', translatable: true },
      },
      noFilterApi: true,
    },
    {
      noUpdate: true,
      noCreate: true,
      type: 'list',
      label: 'Categories',
      name: 'getCategories',
      fields: [
        {
          noMargin: true,
          type: 'multi',
          name: 'title',
          label: 'title',
        },
      ],
    },
  ],
};

export const contentModule = [
  {
    type: 'section',
    label: 'Options',
    side: true,
    fields: [
      { type: 'multi', label: 'URLS', name: 'urls' },
      {
        type: 'bool',
        label: 'Published',
        name: 'published',
        noUpdate: true,
        noCreate: true,
      },
      {
        type: 'date',
        label: 'publication date',
        name: 'publicationDate',
        noUpdate: true,
        noCreate: true,
      },
      { type: 'separator', label: 'SEO' },
      { type: 'multi', label: 'title', name: 'seo.title' },
      { type: 'multi', label: 'description', name: 'seo.description' },
      { type: 'multi', label: 'keywords', name: 'seo.keywords' },
    ],
  },
  {
    type: 'section',
    label: 'Content',
    fields: [
      { type: 'multi', label: 'Title', name: 'title' },
      { type: 'multiarea', label: 'Teaser', name: 'teaser' },
      { type: 'multiwysiwyg', label: 'Content', name: 'content' },
      {
        type: 'picture',
        displayValue: 'large',
        apollo: true,
        asObject: true,
        label: 'Cover',
        name: 'cover',
      },
      {
        type: 'picture',
        displayValue: 'large',
        apollo: true,
        asObject: true,
        label: 'Thumbnail',
        name: 'thumbnail',
      },
    ],
  },
  // categoriesModel,
  // {
  //   type: 'section',
  //   fields: [
  //     {
  //       type: 'list',
  //       label: 'Downloadable File',
  //       name: 'downloadableRessources',
  //       fields: [
  //         {
  //           type: 'picture',
  //           displayValue: 'large',
  //           apollo: true,
  //           asObject: true,
  //           label: 'file',
  //           name: 'file',
  //         },
  //       ],
  //     },
  //     {
  //       type: 'list',
  //       label: 'Extra Image',
  //       name: 'extraImages',
  //       fields: [
  //         {
  //           type: 'picture',
  //           displayValue: 'large',
  //           apollo: true,
  //           asObject: true,
  //           label: 'image',
  //           name: 'image',
  //         },
  //       ],
  //     },
  //   ],
  // },
];

export function addressModel(base) {
  return [
    { type: 'string', label: 'number', name: `${base ? `${base}.` : null}address.number` },
    { type: 'string', label: 'street', name: `${base ? `${base}.` : null}address.street` },
    { type: 'string', label: 'zip', name: `${base ? `${base}.` : null}address.zip` },
    { type: 'string', label: 'state', name: `${base ? `${base}.` : null}address.state` },
    { type: 'string', label: 'city', name: `${base ? `${base}.` : null}address.city` },
    { type: 'string', label: 'country', name: `${base ? `${base}.` : null}address.country` },
  ];
}
