소스 검색

update upload csv column length check

tumao 4 년 전
부모
커밋
4348384181
2개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      client/src/components/insert/Container.tsx
  2. 4 0
      client/src/components/insert/Types.ts

+ 7 - 2
client/src/components/insert/Container.tsx

@@ -19,6 +19,7 @@ import {
   InsertContentProps,
   InsertStatusEnum,
   InsertStepperEnum,
+  SchemaOption,
 } from './Types';
 import { Option } from '../customSelector/Types';
 import { parse } from 'papaparse';
@@ -203,19 +204,23 @@ const InsertContainer: FC<InsertContentProps> = ({
     [collections, defaultSelectedCollection]
   );
 
-  const schemaOptions: Option[] = useMemo(() => {
+  const schemaOptions: SchemaOption[] = useMemo(() => {
     const list =
       schema && schema.length > 0
         ? schema
         : collections.find(c => c._name === collectionValue)?._fields;
+
     return (list || []).map(s => ({
       label: s._fieldName,
       value: s._fieldId,
+      isPrimaryKey: s._isPrimaryKey,
     }));
   }, [schema, collectionValue, collections]);
 
   const checkUploadFileValidation = (fieldNamesLength: number): boolean => {
-    return schemaOptions.length === fieldNamesLength;
+    return (
+      schemaOptions.filter(s => !s.isPrimaryKey).length === fieldNamesLength
+    );
   };
 
   const handleUploadedData = (csv: string, uploader: HTMLFormElement) => {

+ 4 - 0
client/src/components/insert/Types.ts

@@ -75,3 +75,7 @@ export interface InsertStatusProps {
   status: InsertStatusEnum;
   failMsg: string;
 }
+
+export interface SchemaOption extends Option {
+  isPrimaryKey: boolean;
+}