From 7a26ea29ee43bdd625e4b693818a359035482a08 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Tue, 3 Oct 2023 09:14:57 +0700 Subject: [PATCH] fix parent menu --- src/views/Master/MasterMenu/index.js | 29 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/views/Master/MasterMenu/index.js b/src/views/Master/MasterMenu/index.js index 3c78402..7c0e9bc 100644 --- a/src/views/Master/MasterMenu/index.js +++ b/src/views/Master/MasterMenu/index.js @@ -5,7 +5,7 @@ import SweetAlert from 'react-bootstrap-sweetalert'; import axios from 'axios'; import { Button } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; -import { MENU_ADD, MENU_SEARCH, MENU_EDIT, MENU_DELETE } from '../../../const/ApiConst.js'; +import { MENU_ADD, MENU_SEARCH, MENU_EDIT, MENU_DELETE, MENU_LIST } from '../../../const/ApiConst.js'; import { NotificationContainer, NotificationManager } from 'react-notifications'; import { Pagination, Tooltip, Table } from 'antd'; import { useTranslation } from 'react-i18next'; @@ -67,23 +67,21 @@ const Index = ({ params }) => { }; const getDataAllMenu = async () => { - const payload = { - "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": "", "operator": "AND" } - ], - "joins": [], - "orders": { "columns": ["id"], "ascending": false } - } const result = await axios - .post(MENU_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); + .get(MENU_LIST, config) + .then(res => res) + .catch((error) => error.response); if (result && result.data && result.data.code == 200) { - setAllDataMenu(result.data.data); - } else { - } + let arr = [] + let dataRes = result.data.data; + for (const v in dataRes) { + arr.push(dataRes[v]) + } + setAllDataMenu(arr); + }else { + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } } const getDataMenu = async () => { @@ -123,6 +121,7 @@ const Index = ({ params }) => { const handleOpenDialog = async (type) => { await setTypeDialog(type) + getDataAllMenu(); setOpenDialog(true) }