From a0db9029a6543e002cd3400fae024650ae39e388 Mon Sep 17 00:00:00 2001 From: koji Date: Mon, 21 Oct 2024 11:50:33 -0400 Subject: [PATCH] fix check-js and lint-js errors --- .../src/components/EditModules.tsx | 14 ++++---- .../CreateNewProtocolWizard/SelectModules.tsx | 34 +++---------------- .../pages/CreateNewProtocolWizard/utils.tsx | 23 ++++++------- 3 files changed, 22 insertions(+), 49 deletions(-) diff --git a/protocol-designer/src/components/EditModules.tsx b/protocol-designer/src/components/EditModules.tsx index 6ed7c8a6054..49707bb6030 100644 --- a/protocol-designer/src/components/EditModules.tsx +++ b/protocol-designer/src/components/EditModules.tsx @@ -17,12 +17,12 @@ import { EditMultipleModulesModal } from './modals/EditModulesModal/EditMultiple import { useBlockingHint } from './Hints/useBlockingHint' import { MagneticModuleWarningModalContent } from './modals/EditModulesModal/MagneticModuleWarningModalContent' import { EditModulesModal } from './modals/EditModulesModal' -import type { ModuleModel, ModuleType } from '@opentrons/shared-data' +import type { ModuleModel, } from '@opentrons/shared-data' export interface EditModulesProps { moduleToEdit: { moduleId?: string | null - moduleType: ModuleType + : } onCloseClick: () => void } @@ -35,16 +35,16 @@ export interface ModelModuleInfo { export const EditModules = (props: EditModulesProps): JSX.Element => { const { onCloseClick, moduleToEdit } = props const enableMoam = useSelector(getEnableMoam) - const { moduleId, moduleType } = moduleToEdit + const { moduleId, } = moduleToEdit const _initialDeckSetup = useSelector(stepFormSelectors.getInitialDeckSetup) const robotType = useSelector(getRobotType) - const MOAM_MODULE_TYPES: ModuleType[] = enableMoam + const MOAM_MODULE_TYPES: [] = enableMoam ? [TEMPERATURE_MODULE_TYPE, HEATERSHAKER_MODULE_TYPE, MAGNETIC_BLOCK_TYPE] : [TEMPERATURE_MODULE_TYPE] const showMultipleModuleModal = - robotType === FLEX_ROBOT_TYPE && MOAM_MODULE_TYPES.includes(moduleType) + robotType === FLEX_ROBOT_TYPE && MOAM_MODULE_TYPES.includes() const moduleOnDeck = moduleId ? _initialDeckSetup.modules[moduleId] : null const [ @@ -94,7 +94,7 @@ export const EditModules = (props: EditModulesProps): JSX.Element => { let modal = ( { ) } diff --git a/protocol-designer/src/pages/CreateNewProtocolWizard/SelectModules.tsx b/protocol-designer/src/pages/CreateNewProtocolWizard/SelectModules.tsx index 577687ae765..5a9b7610acc 100644 --- a/protocol-designer/src/pages/CreateNewProtocolWizard/SelectModules.tsx +++ b/protocol-designer/src/pages/CreateNewProtocolWizard/SelectModules.tsx @@ -39,7 +39,7 @@ import { OT2_SUPPORTED_MODULE_MODELS, } from './constants' import { - getNumOptions, + getNumOptionsForModules, getNumSlotsAvailable, getModuleDistribution, getAvailableSlots, @@ -53,7 +53,6 @@ import type { FormModule, FormModules } from '../../step-forms' import type { WizardTileProps } from './types' const MAX_MAGNETIC_BLOCKS = 4 -// const MAGNETIC_BLOCKS_ADJUSTMENT = 3 export function SelectModules(props: WizardTileProps): JSX.Element | null { const { goBack, proceed, watch, setValue } = props @@ -98,25 +97,6 @@ export function SelectModules(props: WizardTileProps): JSX.Element | null { ? [TEMPERATURE_MODULE_TYPE, HEATERSHAKER_MODULE_TYPE, MAGNETIC_BLOCK_TYPE] : [TEMPERATURE_MODULE_TYPE] - // const handleAddModule = (moduleModel: ModuleModel): void => { - // // Need to fix since this condition isn't quite right - // if (hasNoAvailableSlots) { - // makeSnackbar(t('slots_limit_reached') as string) - // } else { - // setValue('modules', { - // ...modules, - // [uuid()]: { - // model: moduleModel, - // type: getModuleType(moduleModel), - // slot: - // robotType === FLEX_ROBOT_TYPE - // ? DEFAULT_SLOT_MAP_FLEX[moduleModel] - // : DEFAULT_SLOT_MAP_OT2[getModuleType(moduleModel)], - // }, - // }) - // } - // } - const handleAddModule = (moduleModel: ModuleModel): void => { const moduleType = getModuleType(moduleModel) const distribution = getModuleDistribution(modules) @@ -289,14 +269,10 @@ export function SelectModules(props: WizardTileProps): JSX.Element | null { ) }, dropdownType: 'neutral' as DropdownBorder, - // filterOptions: getNumOptions( - // module.model === 'magneticBlockV1' - // ? numSlotsAvailable + - // MAGNETIC_BLOCKS_ADJUSTMENT + - // module.count - // : numSlotsAvailable + module.count - // ), - filterOptions: getNumOptions(module.type, distribution), + filterOptions: getNumOptionsForModules( + module.type, + distribution + ), } return ( diff --git a/protocol-designer/src/pages/CreateNewProtocolWizard/utils.tsx b/protocol-designer/src/pages/CreateNewProtocolWizard/utils.tsx index af8be0c20a3..750272c6ae0 100644 --- a/protocol-designer/src/pages/CreateNewProtocolWizard/utils.tsx +++ b/protocol-designer/src/pages/CreateNewProtocolWizard/utils.tsx @@ -26,14 +26,14 @@ import type { FormModules } from '../../step-forms' const TOTAL_MODULE_SLOTS = 8 const MIDDLE_SLOT_NUM = 4 -// export const getNumOptions = (length: number): DropdownOption[] => { -// return Array.from({ length }, (_, i) => ({ -// name: `${i + 1}`, -// value: `${i + 1}`, -// })) -// } - -export const getNumOptions = ( +export const getNumOptions = (length: number): DropdownOption[] => { + return Array.from({ length }, (_, i) => ({ + name: `${i + 1}`, + value: `${i + 1}`, + })) +} + +export const getNumOptionsForModules = ( moduleType: ModuleType, distribution: ModuleDistribution ): DropdownOption[] => { @@ -95,7 +95,7 @@ export const getNumSlotsAvailable = ( filteredModuleLength = filteredModuleLength + 1 } if (magneticBlocks.length > 0) { - // once blocks exceed 4, then we dont' want to subtract the amount available + // once blocks exceed 4, then we don't want to subtract the amount available // because block can go into the center slots where all other modules/trashes can not const numBlocks = magneticBlocks.length > 4 ? MIDDLE_SLOT_NUM : magneticBlocks.length @@ -334,11 +334,7 @@ export const getAvailableSlots = ( if (distribution === null) return { regular: TOTAL_SLOTS_WITHOUT_TWO_COL, magnetic: TWO_COL_SLOTS } const { tc, hs, mb, tm } = distribution - - // マグネティックブロック用のスロット const availableMagneticSlots = 11 - (tc * 2 + hs + tm + mb) - - // 通常のモジュール用のスロット const availableRegularSlots = 7 - (hs + tm + (tc > 0 ? 2 : 0)) return { @@ -352,6 +348,7 @@ export const getCanAddModule = ( distribution: ModuleDistribution ): boolean => { const availableSlots = getAvailableSlots(distribution) + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { tc, hs, mb, tm } = distribution switch (moduleType) {