Skip to content

Commit d7db50b

Browse files
authored
Merge pull request #3794 from Northeastern-Electric-Racing/adding-other-reason-rr-bug
keep track of reasons when adding products
2 parents f3ade65 + d685620 commit d7db50b

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const ReimbursementProductTable: React.FC<ReimbursementProductTableProps> = ({
8686
cost: number;
8787
index: number;
8888
id?: string;
89+
reason: WbsNumber | OtherProductReason;
8990
}[]
9091
>();
9192

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

@@ -705,12 +706,15 @@ const ReimbursementProductTable: React.FC<ReimbursementProductTableProps> = ({
705706
/>
706707
}
707708
onClick={(e) => {
708-
appendProduct({
709-
reason: key.includes('.') ? validateWBS(key) : ({ name: key } as OtherProductReason),
710-
name: '',
711-
cost: 0,
712-
refundSources: []
713-
});
709+
const existingProducts = uniqueWbsElementsWithProducts.get(key);
710+
if (existingProducts && existingProducts.length > 0) {
711+
appendProduct({
712+
reason: existingProducts[0].reason,
713+
name: '',
714+
cost: 0,
715+
refundSources: []
716+
});
717+
}
714718
e.currentTarget.blur();
715719
}}
716720
>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const schema = yup.object().shape({
9999
.of(
100100
yup.object().shape({
101101
name: yup.string().required('Description is required'),
102+
reason: yup.mixed().required(),
102103
refundSources: yup.array().of(
103104
yup.object({
104105
amount: yup

0 commit comments

Comments
 (0)