From 9e869fc772c82e546eea60ac6354910114047565 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Tue, 19 Sep 2023 10:12:49 +0700 Subject: [PATCH] add form edit --- .../SimproV2/CreatedProyek/DialogFormGantt.js | 297 ++++++++++-------- 1 file changed, 174 insertions(+), 123 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/DialogFormGantt.js b/src/views/SimproV2/CreatedProyek/DialogFormGantt.js index 4161422..96e00a1 100644 --- a/src/views/SimproV2/CreatedProyek/DialogFormGantt.js +++ b/src/views/SimproV2/CreatedProyek/DialogFormGantt.js @@ -1,123 +1,174 @@ -import React, { useEffect, useState } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; -import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; -import axios from "../../../const/interceptorApi"; -import { VERSION_GANTT_ADD } from '../../../const/ApiConst'; -import { Select } from 'antd'; -import 'antd/dist/antd.css'; - -const DialogFormGantt = ({ openDialog, closeDialog, toggleDialog, idTask, parentId }) => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - const [id, setId] = useState(0) - const [name, setName] = useState("") - const [description, setDesctription] = useState("") - const [calculationType, setCalculationType] = useState("detail") - const handleCLearData = () => { - setId(0) - setName("") - setDesctription("") - } - - useEffect(() => { - handleCLearData() - }, [openDialog]) - - const handleSave = () => { - saveVersionGantt() - handleCLearData() - } - - const saveVersionGantt = async () => { - - const formData = { - name_version: name, - description, - calculation_type: calculationType, - proyek_id: idTask, - hierarchy_ftth_id: parentId - - } - const result = await axios - .post(VERSION_GANTT_ADD, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.status == 200) { - closeDialog('success') - } else { - closeDialog('failed') - } - } - - const handleCancel = () => { - closeDialog('cancel') - handleCLearData() - } - - const renderForm = () => { - return ( -
- - - setName(e.target.value)} placeholder='' /> - - - - setDesctription(e.target.value)} placeholder='' /> - - - -
- setName(e.target.value)}/> + + + + setDesctription(e.target.value)}/> + + + +
+