/** * Copyright (c) 2026-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type JSX, useCallback, useState } from 'react'; import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, List, ListItemButton, ListItemText, Radio, Typography, } from '@mui/material'; import type { TraderProfile, TraderProfileItem, } from '@finos/legend-server-marketplace'; import { observer } from 'mobx-react-lite'; import { formatItemPrice, OrderProfileLabel } from './orderProfileUtils.js'; export const OrderProfileMultiselectModal = observer( (props: { profile: TraderProfile; open: boolean; onClose: () => void; onConfirm: (selectedTerminals: TraderProfileItem[]) => void; }): JSX.Element => { const { profile, open, onClose, onConfirm } = props; const terminalItems = profile.items.filter( (item) => item.isTerminal && !item.isOwned, ); const [selectedId, setSelectedId] = useState(null); const handleConfirm = useCallback((): void => { const selectedItem = terminalItems.find((item) => item.id === selectedId); onConfirm(selectedItem ? [selectedItem] : []); }, [terminalItems, selectedId, onConfirm]); return ( {OrderProfileLabel.SELECT_TERMINAL_TITLE} Choose one terminal to include from{' '} {profile.productName}.{' '} {OrderProfileLabel.SELECT_TERMINAL_DESCRIPTION} {terminalItems.map((item) => ( setSelectedId(item.id)} selected={selectedId === item.id} className={`order-profile-multiselect-modal__list-item ${selectedId === item.id ? 'order-profile-multiselect-modal__list-item--selected' : ''}`} > setSelectedId(item.id)} size="small" className="order-profile-multiselect-modal__radio" inputProps={{ 'aria-labelledby': `terminal-item-${item.id}` }} /> {item.productName} {formatItemPrice(item.price)} } secondary={ item.model !== null && item.model !== undefined ? ( {OrderProfileLabel.MODEL_PREFIX} {item.model} ) : undefined } /> ))} ); }, );