From 01fff80c3686f3bd2b7757bc302eac894c858274 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 10 Jul 2024 14:00:03 -0400 Subject: [PATCH 1/2] refactor: introduce type `MeiData` Refs: #105 --- src/Editor/MeiTools.ts | 5 +++-- src/Types.ts | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Editor/MeiTools.ts b/src/Editor/MeiTools.ts index 92231ec..057a796 100644 --- a/src/Editor/MeiTools.ts +++ b/src/Editor/MeiTools.ts @@ -1,9 +1,10 @@ import Handsontable from 'handsontable'; import { updateStatus } from './ValidationTools'; import * as Notification from '../utils/Notification'; +import { MeiData } from '../Types'; export class MeiTools { - private meiData: any[]; + private meiData: MeiData; public validationInProgress = false; public pendingValidations = 0; public hasInvalid = false; @@ -18,7 +19,7 @@ export class MeiTools { const mei = row[inputMeiHeader]; if (mei) { this.meiData.push({ - mei, + mei: mei, row: rowIndex, isValid: null, errorMsg: null, diff --git a/src/Types.ts b/src/Types.ts index 4e47efa..87bcad8 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -74,3 +74,10 @@ export type TableEvent = | 'afterRemoveRow' | 'afterRowMove' | 'afterRowSequenceChange'; + +export type MeiData = { + mei: string; + row: number; + isValid: boolean | null; + errorMsg: string | null; +}[]; From 17b27691678c58a4a830b8139efc9fa5f896ed95 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 10 Jul 2024 14:12:08 -0400 Subject: [PATCH 2/2] style: rename `uploadsInfo` to `UploadsInfo` --- src/Dashboard/Storage.ts | 4 ++-- src/Types.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Dashboard/Storage.ts b/src/Dashboard/Storage.ts index 7aa421c..4087c95 100644 --- a/src/Dashboard/Storage.ts +++ b/src/Dashboard/Storage.ts @@ -1,5 +1,5 @@ import PouchDB from 'pouchdb'; -import { AllDocs, Doc, uploadsInfo } from '../Types'; +import { AllDocs, Doc, UploadsInfo } from '../Types'; import * as Papa from 'papaparse'; import * as mammoth from 'mammoth/mammoth.browser'; @@ -13,7 +13,7 @@ function getAllDocuments(): Promise { }); } -export async function fetchUploads(): Promise { +export async function fetchUploads(): Promise { try { const res = await getAllDocuments(); return res.rows.map((row) => ({ diff --git a/src/Types.ts b/src/Types.ts index 87bcad8..4d03dc3 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -51,7 +51,7 @@ export type Doc = { }; }; -export type uploadsInfo = { +export type UploadsInfo = { id: string; name: string; }[];