File tree Expand file tree Collapse file tree
src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import NERModal from '../../../../../components/NERModal' ;
2+ import { useCopyMaterialsToProject } from '../../../../../hooks/bom.hooks' ;
23
34export interface BOMCopyConfirmModalProps {
45 open : boolean ;
56 onHide : ( ) => void ;
6- onSuccess ? : ( ) => void ;
7- materialsCount : number ;
7+ onSuccess : ( ) => void ;
8+ materialIds : string [ ] ;
89 sourceProjectName : string ;
910 currentProjectName : string ;
11+ destinationWbsNum : string ;
1012}
1113
1214const BOMCopyConfirmModal = ( {
1315 open,
1416 onHide,
1517 onSuccess,
16- materialsCount ,
18+ materialIds ,
1719 sourceProjectName,
18- currentProjectName
20+ currentProjectName,
21+ destinationWbsNum
1922} : BOMCopyConfirmModalProps ) => {
20- const message = `Are you sure you want to copy ${ materialsCount } materials from ${ sourceProjectName } to ${ currentProjectName } ?` ;
23+ const copyMaterials = useCopyMaterialsToProject ( ) ;
24+
25+ const handleConfirm = ( ) => {
26+ copyMaterials . mutate (
27+ {
28+ materialIds,
29+ destinationWbsNum
30+ } ,
31+ {
32+ onSuccess : ( ) => {
33+ onSuccess ( ) ;
34+ onHide ( ) ;
35+ }
36+ }
37+ ) ;
38+ } ;
39+
40+ const message = `Are you sure you want to copy ${ materialIds . length } materials from ${ sourceProjectName } to ${ currentProjectName } ?` ;
2141 return (
22- < NERModal open = { open } onHide = { onHide } onSubmit = { onSuccess } title = "Confirm Copy" >
42+ < NERModal open = { open } onHide = { onHide } onSubmit = { handleConfirm } title = "Confirm Copy" >
2343 < p > { message } </ p >
2444 </ NERModal >
2545 ) ;
Original file line number Diff line number Diff line change 22 Accordion ,
33 AccordionDetails ,
44 AccordionSummary ,
5- Button ,
65 FormControl ,
76 FormHelperText ,
87 FormLabel ,
Original file line number Diff line number Diff line change @@ -150,16 +150,17 @@ const BOMTab = ({ project }: { project: Project }) => {
150150 Copy Existing BOM
151151 </ NERButton >
152152 </ Box >
153- < BOMCopyConfirmModal
153+ { /* <BOMCopyConfirmModal
154154 open={bomConfirmOpen}
155155 onHide={() => {
156156 setBomConfirmOpen(false);
157157 }}
158158 onSuccess={() => {}}
159- materialsCount = { 1 }
160- sourceProjectName = { 'Source Project' }
161- currentProjectName = { 'Target Project' }
162- > </ BOMCopyConfirmModal >
159+ materialIds={materials.map((m) => m.materialId)} // Test: right now, it just copies everything to destination
160+ sourceProjectName={'This Project'}
161+ currentProjectName={'0.7.0 - Laser Cannon Prototype'}
162+ destinationWbsNum={'0.7.0'}
163+ ></BOMCopyConfirmModal> */ }
163164 < Box display = "flex" gap = "20px" alignItems = "center" >
164165 < Box sx = { { backgroundColor : theme . palette . background . paper , padding : '8px 14px 8px 14px' , borderRadius : '6px' } } >
165166 Budget: ${ project . budget }
You can’t perform that action at this time.
0 commit comments