import { cacheFor } from '@/request/api/index';
import HTTP         from '../alova';


export function copyrightMethod(value = '/copyright') {
  return HTTP.Post(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
    cacheFor,
    params: { t: 'process', k: value },
    transform(data: any, headers) {
      return [ data?.partner, data?.technicalSupporter ].filter(Boolean).join('<br>');
    },
  });
}

export function processMethod(value = '/screen') {
  const routes: Record<string, string> = {
    'patient_file': '/register',
    'tongueface_upload': '/camera',
    'tongueface_analysis': '/questionnaire',
    'health_analysis': '/report',
  };
  return HTTP.Post(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
    cacheFor,
    params: { t: 'process', k: value },
    transform(data: any, headers) {
      const options = data?.tabletProcessModules ?? [];
      const ref = new Map<string, string>();
      for ( let i = 0; i < options.length; i++ ) {
        const route = routes[ options[ i ] ];
        if ( !route ) continue;
        if ( !i ) ref.set('/screen', route);
        ref.set(route, routes[ options[ i + 1 ] ] ?? '');
      }
      return ref.get(value);
    },
  });
}

