Skip to content

Commit 8bf3cf8

Browse files
committed
#3301: deleting products in edit reimbursement request no longer overwrites items below
1 parent 7849791 commit 8bf3cf8

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/frontend/src/pages/FinancePage/ReimbursementRequestForm/ReimbursementProductTable.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import ErrorPage from '../../ErrorPage';
4141
import { formatReasonName } from '../../../utils/reimbursement-request.utils';
4242

4343
interface ReimbursementProductTableProps {
44-
reimbursementProducts: ReimbursementProductFormArgs[];
44+
reimbursementProducts: (ReimbursementProductFormArgs & { id: string })[];
4545
removeProduct: (index: number) => void;
4646
appendProduct: (args: ReimbursementProductFormArgs) => void;
4747
wbsElementAutocompleteOptions: {
@@ -85,6 +85,7 @@ const ReimbursementProductTable: React.FC<ReimbursementProductTableProps> = ({
8585
name: string;
8686
cost: number;
8787
index: number;
88+
id: string;
8889
}[]
8990
>();
9091

@@ -104,9 +105,9 @@ const ReimbursementProductTable: React.FC<ReimbursementProductTableProps> = ({
104105
const productReason = hasWbsNum ? wbsPipe(product.reason as WbsNumber) : (product.reason as OtherProductReason).name;
105106
if (uniqueWbsElementsWithProducts.has(productReason)) {
106107
const products = uniqueWbsElementsWithProducts.get(productReason);
107-
products?.push({ ...product, index });
108+
products?.push({ ...product, index, id: product.id });
108109
} else {
109-
uniqueWbsElementsWithProducts.set(productReason, [{ ...product, index }]);
110+
uniqueWbsElementsWithProducts.set(productReason, [{ ...product, index, id: product.id }]);
110111
}
111112
});
112113

@@ -442,7 +443,7 @@ const ReimbursementProductTable: React.FC<ReimbursementProductTableProps> = ({
442443
)}
443444
</Box>
444445
{uniqueWbsElementsWithProducts.get(key)?.map((product) => (
445-
<ListItem key={product.index}>
446+
<ListItem key={product.id}>
446447
<Box sx={{ display: 'flex' }}>
447448
<Box
448449
sx={{

0 commit comments

Comments
 (0)