All files / src/form/cells UpdatedIdsDetail.tsx

100% Statements 12/12
75% Branches 3/4
100% Functions 4/4
100% Lines 12/12

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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56            66x 3x 3x 3x     3x 3x 3x 1x   1x   1x   3x                                           3x                        
import React, { ReactElement, useEffect, useState } from "react";
import { DetailPanelProps } from "@props/RecordProps";
import { fetchCurrentValue } from "@utils/FetchUtils";
import { LargeSpin } from '../../components';
import ImportRecordComponent, { ImportRecordProps } from './ImportRecord';
 
const UpdatedIdsDetail = (props: DetailPanelProps): ReactElement => {
  const { record, zIndex } = props;
  const [domainName, setDomainName] = useState<string>("");
  const [loading, setLoading] = useState<boolean>(true);
  //eslint-disable-next-line @typescript-eslint/ban-ts-comment
  //@ts-ignore
  const { domainClass: domainClassId } = record;
  const id = typeof domainClassId === "number" ? domainClassId : domainClassId?.id;
  useEffect(() => {
    fetchCurrentValue("DomainClass", id)
      .then(json => {
        setDomainName(json.shortName);
      })
      .finally(() => setLoading(false));
  }, [id]);
  const importProps = {
    insertedIds: record?.updatedIds?.insertedIds,
    updatedIds: record?.updatedIds?.updatedIds,
    deletedIds: record?.updatedIds?.deletedIds,
    noUpdateIds: record?.updatedIds?.noUpdateIds,
    conflictIds: record?.updatedIds?.conflictIds,
    dbUpdatedCsvNoUpdateIds: record?.updatedIds?.dbUpdatedCsvNoUpdateIds,
    failedLines: record?.failedLines,
    skippedLines: record?.skippedLines,
    conflictLines: record?.conflictLines,
    dbUpdatedCsvNoUpdateLines: record?.dbUpdatedCsvNoUpdateLines,
    logs: record?.logs,
    status: record?.status,
    insertedRecord: record?.insertedRecord,
    failedRecord: record?.failedRecord,
    noUpdateRecord: record?.noUpdateRecord,
    skippedRecord: record?.skippedRecord,
    updatedRecord: record?.updatedRecord,
    deletedRecord: record?.deletedRecord,
    conflictRecord: record?.conflictRecord,
    dbUpdatedCsvNoUpdateRecord: record?.dbUpdatedCsvNoUpdateRecord,
  } as ImportRecordProps;
  return loading ? <LargeSpin /> : (
    <ImportRecordComponent
      domainName={domainName}
      importRecord={importProps}
      uploaded={true}
      defaultMaxWidth="100%"
      zIndex={zIndex}
    />
  );
};
 
export default UpdatedIdsDetail;