Skip to content

Commit dff1d28

Browse files
committed
feat: page now refreshes when private shape is edited
1 parent 254c9d5 commit dff1d28

3 files changed

Lines changed: 29 additions & 13 deletions

File tree

components/core/App.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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
);

components/core/CreateShape.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff 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({

components/utils/ShapeList.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)