|
1 | 1 | import React, { useState, useEffect } from "react"; |
2 | 2 |
|
| 3 | +// axios |
| 4 | +import axios from "axios"; |
| 5 | + |
3 | 6 | // Bootstrap |
4 | 7 | import Container from "react-bootstrap/Container"; |
5 | 8 | import Row from "react-bootstrap/Row"; |
@@ -302,34 +305,28 @@ const CreateShape = (props) => { |
302 | 305 | // Editing Shape |
303 | 306 | if (props.edit) { |
304 | 307 |
|
305 | | - const editShape = await harperFetch({ |
306 | | - operation: "sql", |
307 | | - sql: ` |
308 | | - UPDATE tryshape.shapes |
309 | | - SET |
310 | | - name = '${shapeInformation.name}', |
311 | | - formula = '${shapeInformation.formula}', |
312 | | - vertices = '${shapeInformation.vertices}', |
313 | | - private = '${shapeInformation.private}', |
314 | | - edges = '${shapeInformation.edges}', |
315 | | - notes = '${shapeInformation.notes}', |
316 | | - type = '${shapeInformation.clipPathType}', |
317 | | - backgroundColor = '${shapeInformation.backgroundColor}' |
318 | | - WHERE |
319 | | - shape_id === '${props.shape.shape_id}' |
320 | | - ` |
| 308 | + const updateShapeResponse = await axios.post('/api/PUT/shape', { |
| 309 | + shapeId: props.shape.shape_id, |
| 310 | + name: shapeInformation.name, |
| 311 | + formula: shapeInformation.formula, |
| 312 | + vertices: shapeInformation.vertices, |
| 313 | + visibility: shapeInformation.private, |
| 314 | + edges: shapeInformation.edges, |
| 315 | + notes: shapeInformation.notes, |
| 316 | + type: shapeInformation.clipPathType, |
| 317 | + backgroundColor: shapeInformation.backgroundColor |
321 | 318 | }); |
| 319 | + const editShape = updateShapeResponse.data; |
| 320 | + console.log({editShape}); |
322 | 321 |
|
323 | | - console.log(editShape); |
324 | | - |
325 | | - if (editShape["update_hashes"].length > 0) { |
| 322 | + if (editShape.data["update_hashes"].length > 0) { |
326 | 323 | props.handleClose(); |
327 | 324 | toast.success(`Shape ${shapeInformation.name} edited successfully.`); |
328 | 325 | props.setShapeAction({ |
329 | 326 | ...props.shapeAction, |
330 | 327 | "action": "edit", |
331 | 328 | "payload": { |
332 | | - "shape_id": editShape['update_hashes'] |
| 329 | + "shape_id": editShape.data['update_hashes'] |
333 | 330 | } |
334 | 331 | }); |
335 | 332 | } else { |
|
0 commit comments