File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,7 +112,14 @@ const App = (props) => {
112112 width = { 300 }
113113 />
114114 ) : (
115- < ShapeList { ...props } data = { data } searchTerm = { searchTerm } sort = { sort } />
115+ < ShapeList
116+ { ...props }
117+ data = { data }
118+ searchTerm = { searchTerm }
119+ sort = { sort }
120+ shapeAction = { shapeAction }
121+ setShapeAction = { setShapeAction }
122+ />
116123 ) }
117124 </ >
118125 ) ;
Original file line number Diff line number Diff line change @@ -297,6 +297,7 @@ const CreateShape = (props) => {
297297
298298 console . log ( shapeInformation ) ;
299299
300+ // Editing Shape
300301 if ( props . edit ) {
301302
302303 const editShape = await harperFetch ( {
@@ -319,17 +320,21 @@ const CreateShape = (props) => {
319320
320321 console . log ( editShape ) ;
321322
322- props . handleClose ( ) ;
323- toast . success ( `Shape ${ shapeInformation . name } edited successfully.` ) ;
324- // props.setShapeAction({
325- // ...props.shapeAction,
326- // "action": "add",
327- // "payload": {
328- // "shape_id": insertShape['inserted_hashes']
329- // }
330- // });
331-
332- } else {
323+ if ( editShape [ "update_hashes" ] . length > 0 ) {
324+ props . handleClose ( ) ;
325+ toast . success ( `Shape ${ shapeInformation . name } edited successfully.` ) ;
326+ props . setShapeAction ( {
327+ ...props . shapeAction ,
328+ "action" : "edit" ,
329+ "payload" : {
330+ "shape_id" : editShape [ 'update_hashes' ]
331+ }
332+ } ) ;
333+ } else {
334+ toast . error ( 'OOPS!! We hit a bummer. Please try again.' ) ;
335+ }
336+
337+ } else { // Creating Shape
333338
334339 // Create the shape in the DB
335340 const insertShape = await harperFetch ( {
Original file line number Diff line number Diff line change @@ -200,7 +200,9 @@ const ShapeList = (
200200 user,
201201 data,
202202 searchTerm,
203- sort
203+ sort,
204+ shapeAction,
205+ setShapeAction
204206 } ) => {
205207
206208 const filterShape = ( shapes , searchTerm ) => {
@@ -389,6 +391,8 @@ const ShapeList = (
389391 show = { showEditModal }
390392 handleClose = { closeEditModal }
391393 shape = { shapeToEdit }
394+ shapeAction = { shapeAction }
395+ setShapeAction = { setShapeAction }
392396 edit = { true } />
393397 }
394398
You can’t perform that action at this time.
0 commit comments