import DATA from './auth.json';

export const getData = function () {
  const myMap1 = new Map();
  const myMap2 = new Map();
  const rowData = DATA.map((item: any) => {
    const data = item.i18n;

    // Map1
    const nameArr1 = item.name.split('/');
    const key1 = nameArr1[0] + '/' + nameArr1[1];
    const title1 = data['zh-TW'].split('/');
    const origin1 = data['en-US'].split('/');
    const type1 = data['zh-CN'].split('/');
    const obj1 = {
      title: title1[1],
      origin: origin1[1],
      type: [type1[0], type1[1]],
    };

    if (!myMap1.has(key1)) {
      myMap1.set(key1, obj1);
    }

    // Map2
    const key2 = nameArr1[0];
    const obj2 = {
      title: title1[0],
      origin: origin1[0],
      type: [type1[0]],
    };

    if (!myMap2.has(key2)) {
      myMap1.set(key2, obj2);
    }

    return {
      title: data['zh-TW'].split('/')[2],
      origin: data['en-US'].split('/')[2],
      type: data['zh-CN'].split('/'),
    };
  });

  for (const value of myMap1.values()) {
    rowData.push(value);
  }
  for (const value of myMap2.values()) {
    rowData.push(value);
  }
  return rowData;
  //   const rowData = [
  //     {
  //       title: '系統設置',
  //       origin: 'System Setting',
  //       type: ['系统设置'],
  //     },
  //     {
  //       title: '用戶管理',
  //       origin: 'User Management',
  //       type: ['系统设置', '用户管理'],
  //     },
  //     {
  //       title: '查看',
  //       origin: 'Read',
  //       type: ['系统设置', '用户管理', '查看'],
  //     },
  //     {
  //       title: '新建',
  //       origin: 'Create',
  //       type: ['系统设置', '用户管理', '新建'],
  //     },
  //   ];
};

export const getData2 = function () {
  const rowData = [
    {
      id: 1,
      filePath: ['Documents'],
    },
    {
      id: 2,
      filePath: ['Documents', 'txt'],
    },
    {
      id: 3,
      filePath: ['Documents', 'txt', 'notes.txt'],
      dateModified: 'May 21 2017 01:50:00 PM',
      size: 14.7,
    },
    {
      id: 4,
      filePath: ['Documents', 'pdf'],
    },
    {
      id: 5,
      filePath: ['Documents', 'pdf', 'book.pdf'],
      dateModified: 'May 20 2017 01:50:00 PM',
      size: 2.1,
    },
    {
      id: 6,
      filePath: ['Documents', 'pdf', 'cv.pdf'],
      dateModified: 'May 20 2016 11:50:00 PM',
      size: 2.4,
    },
    {
      id: 7,
      filePath: ['Documents', 'xls'],
    },
    {
      id: 8,
      filePath: ['Documents', 'xls', 'accounts.xls'],
      dateModified: 'Aug 12 2016 10:50:00 AM',
      size: 4.3,
    },
    {
      id: 9,
      filePath: ['Documents', 'stuff'],
    },
    {
      id: 10,
      filePath: ['Documents', 'stuff', 'xyz.txt'],
      dateModified: 'Jan 17 2016 08:03:00 PM',
      size: 1.1,
    },
    {
      id: 11,
      filePath: ['Music', 'mp3', 'pop'],
      dateModified: 'Sep 11 2016 08:03:00 PM',
      size: 14.3,
    },
    {
      id: 12,
      filePath: ['temp.txt'],
      dateModified: 'Aug 12 2016 10:50:00 PM',
      size: 101,
    },
    {
      id: 13,
      filePath: ['Music', 'mp3', 'pop', 'theme.mp3'],
      dateModified: 'Aug 12 2016 10:50:00 PM',
      size: 101,
    },
    {
      id: 14,
      filePath: ['Music', 'mp3', 'jazz'],
      dateModified: 'Aug 12 2016 10:50:00 PM',
      size: 101,
    },
  ];
  return rowData;
};