Commit 58add8ae by tdgiang

update code

parent 10a4a988
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../helpers'
import url from '../url'
export const getListMerchants = async (body) =>
PostData(url.urlGetListMerchant, body)
.then((res) => res)
.catch((err) => null)
export const createMerchant = async (body) =>
PostData(url.urlCreateMerchant, body)
.then((res) => res)
.catch((err) => null)
export const updateMerchant = async (body) =>
PostData(url.urlUpdateMerchant, body)
.then((res) => res)
.catch((err) => null)
export const detailMerchant = async (id, body) =>
GetURL(`${url.urlDetailMerchant}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteMerchant = async (body) =>
PostData(url.urlDeleteMerchant, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusMerchant = async (body) =>
PostData(url.changeStatusMerchant, body)
.then((res) => res)
.catch((err) => null)
......@@ -62,6 +62,15 @@ export default {
urlDetailProduct: `${root}/product`,
changeStatusProduct: `${root}/product/changeStatus`,
listTransaction: `${root}/paymentTrans/list`,
//merchant:
urlGetListMerchant: `${root}/merchant/list`,
urlCreateMerchant: `${root}/merchant/create`,
urlUpdateMerchant: `${root}/merchant/update`,
urlDeleteMerchant: `${root}/merchant/delete`,
urlDetailMerchant: `${root}/merchant`,
changeStatusMerchant: `${root}/merchant/changeStatus`,
//Log
logAuth: `${root}/logging/listLogin`,
logApi: `${root}/logging/listCallApi`,
......
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListFunction,
deleteFunction,
changeStatusFunction,
} from 'app/apis/Functions/function'
getListMerchants,
deleteMerchant,
changeStatusMerchant,
} from 'app/apis/Functions/merchant'
import { useHistory } from 'react-router-dom'
import KEY from '../../assets/Key'
import { connect } from 'react-redux'
......@@ -27,24 +27,10 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([])
const [permissions, setPermissions] = useState([])
// useEffect(() => {
// getListPermission();
// }, []);
// const getListPermission = () => {
// let temp = localStorage.getItem(KEY.LISTPATH);
// let listPath = JSON.parse(temp);
// if (listPath) {
// const newlist = listPath.map((e) => {
// if (e.function_code) return e.function_code;
// return e.action_code;
// });
// setPermissions(newlist);
// }
// };
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusFunction({ id, status_id })
const res = await changeStatusMerchant({ id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
......@@ -60,13 +46,14 @@ const ToolNotificate = (props) => {
const getData = async () => {
props.showLoading()
const res = await getListFunction({
const res = await getListMerchants({
name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
})
props.hideLoading()
console.log('res', res)
if (res.data.code == 200 && res.data.data) {
console.log(res.data)
......@@ -92,7 +79,7 @@ const ToolNotificate = (props) => {
const removeItem = async (id) => {
props.showLoading()
const res = await deleteFunction({ id })
const res = await deleteMerchant({ id })
props.hideLoading()
if (res.data.code == 200) {
getData()
......
......@@ -39,34 +39,46 @@ const columns = [
},
{
id: 'name',
label: 'Tên chức năng',
id: 'merchant_name',
label: 'Pháp nhân',
align: 'left',
minWidth: 'auto',
},
{
id: 'code',
label: 'Mã code',
id: 'tax_code',
label: 'Mã số thuế',
align: 'left',
minWidth: 'auto',
},
{
id: 'url',
label: ường dẫn',
id: 'address',
label: ịa chỉ',
align: 'left',
minWidth: 'auto',
},
{
id: 'description',
label: 'Mô tả',
id: 'email',
label: 'Email',
align: 'left',
minWidth: 'auto',
},
{
id: 'date_created',
label: 'Ngày tạo',
id: 'representative',
label: 'Người đại diện',
align: 'left',
minWidth: 'auto',
},
{
id: 'phone_number',
label: 'SĐT liên hệ',
align: 'left',
minWidth: 'auto',
},
{
id: 'total_store',
label: 'Số cây xăng',
align: 'left',
minWidth: 'auto',
},
......
......@@ -47,7 +47,7 @@ const SimpleForm = (props) => {
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/function')
history.push('/merchant')
if (res.data.code == 200) {
toast.success('Cập nhật hành động thành công!', {
theme: 'colored',
......@@ -81,10 +81,10 @@ const SimpleForm = (props) => {
<Breadcrumb
routeSegments={[
{
name: 'Danh sách chức năng',
path: '/function',
name: 'Danh sách pháp nhân',
path: '/merchant',
},
{ name: 'Cập nhật chức năng' },
{ name: 'Cập nhật pháp nhân' },
]}
/>
</div>
......@@ -95,7 +95,7 @@ const SimpleForm = (props) => {
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên chức năng *"
label="Tên pháp nhân *"
onChange={handleChange}
type="text"
name="name"
......@@ -154,7 +154,7 @@ const SimpleForm = (props) => {
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Link to="function">
<Link to="merchant">
<Button
style={{
marginRight: 20,
......
......@@ -45,8 +45,8 @@ function CustomerView(props) {
<Breadcrumb
routeSegments={[
{
name: 'Danh sách chức năng',
path: '/function',
name: 'Danh sách pháp nhân',
path: '/merchant',
},
]}
/>
......@@ -66,7 +66,7 @@ function CustomerView(props) {
<TextField
variant="outlined"
className="w-full"
label="Tên chức năng"
label="Tên pháp nhân"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
......@@ -75,8 +75,8 @@ function CustomerView(props) {
}}
/>
</Grid>
{checkRole(user, '/function/create') ? (
<Link to="/function/create">
{checkRole(user, '/merchant/create') ? (
<Link to="/merchant/create">
<Button
variant="contained"
className={'bg-light-primary'}
......
......@@ -35,7 +35,7 @@ const ToolNotificate = (props) => {
page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null,
to_date: endDate ? convertDate(endDate) : null,
gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
// gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment