All files / src/pages/flowsheet-page/multi-steady-state ExportMSSResultsCommand.tsx

70% Statements 7/10
50% Branches 3/6
50% Functions 1/2
77.77% Lines 7/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                    33x     3761x 3761x 3761x   3761x 3610x     151x                                    
import { defineCommand } from "just-search-it";
import {
  useLazyMssDownloadResultsRetrieveQuery,
  useMssDownloadResultsRetrieveQuery,
} from "../../../api/apiStore.gen";
import { useProjectId } from "../../../hooks/project";
import { useSearchParam } from "../../../hooks/searchParams";
import { RegisterCommand } from "../../../commands/CommandProvider";
import { Download } from "lucide-react";
 
export const ExportMSSResults = defineCommand<[], void>("exportMSSResults");
 
export function ExportMSSRResultsCommand() {
  const [export_data] = useLazyMssDownloadResultsRetrieveQuery();
  const [scenario_id] = useSearchParam("scenario");
  const flowsheet_id = useProjectId();
 
  if (!flowsheet_id || !scenario_id) {
    return null;
  }
 
  return (
    <RegisterCommand
      command={ExportMSSResults}
      args={[]}
      name="Export MSS Results"
      description="Download the results data for the current multi-steady-state scenario as a CSV file"
      group="Export"
      icon={<Download />}
      action={async () => {
        Iif (!flowsheet_id || !scenario_id) return;
        export_data({
          flowsheet: flowsheet_id,
          scenario: Number(scenario_id),
        })
      }}
    />
  );
}