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 @@ -111,9 +111,10 @@ const BOMTab = ({ project }: { project: Project }) => {
111111 setBomConfirmOpen ( false ) ;
112112 } }
113113 onSuccess = { ( ) => { } }
114- materialsCount = { 1 }
114+ materialIds = { materials . map ( ( m ) => m . materialId ) } // Test: right now, it just copies everything to itself
115115 sourceProjectName = { 'Source Project' }
116116 currentProjectName = { 'Target Project' }
117+ destinationWbsNum = { '0.7.0' } // Or any project to copy to
117118 > </ BOMCopyConfirmModal >
118119 < Box display = "flex" gap = "20px" alignItems = "center" >
119120 < Box sx = { { backgroundColor : theme . palette . background . paper , padding : '8px 14px 8px 14px' , borderRadius : '6px' } } >
You can’t perform that action at this time.
0 commit comments