import HTTP              from '@/request/alova';
import { processMethod } from '@/request/api/flow.api';
import { useVisitor }    from '@/stores';


export function uploadFileMethod(file: File) {
  const formData = new FormData();
  formData.append('file', file);
  return HTTP.Post<{ name: string; url: string }>(`/file/upload`, formData, {});
}

export function saveFileMethod(params: Record<string, string>) {
  const Visitor = useVisitor();
  params.patientId = Visitor.patientId!;
  return HTTP.Get(`/fdhb-tablet/patientInfoManage/saveTonguefaceImg`, {
    params,
    async transform(data: string, headers) {
      Visitor.resultId = data;
      const path = await processMethod();
      return {
        resultId: data,
        route: { path },
      };
    },
  });
}
