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 { ...@@ -62,6 +62,15 @@ export default {
urlDetailProduct: `${root}/product`, urlDetailProduct: `${root}/product`,
changeStatusProduct: `${root}/product/changeStatus`, changeStatusProduct: `${root}/product/changeStatus`,
listTransaction: `${root}/paymentTrans/list`, 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 //Log
logAuth: `${root}/logging/listLogin`, logAuth: `${root}/logging/listLogin`,
logApi: `${root}/logging/listCallApi`, logApi: `${root}/logging/listCallApi`,
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import ToolUserView from './View' import ToolUserView from './View'
import { import {
getListFunction, getListMerchants,
deleteFunction, deleteMerchant,
changeStatusFunction, changeStatusMerchant,
} from 'app/apis/Functions/function' } from 'app/apis/Functions/merchant'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import KEY from '../../assets/Key' import KEY from '../../assets/Key'
import { connect } from 'react-redux' import { connect } from 'react-redux'
...@@ -27,24 +27,10 @@ const ToolNotificate = (props) => { ...@@ -27,24 +27,10 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([]) const [data, setData] = useState([])
const [permissions, setPermissions] = 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) => { const handeChangeActive = async (id, status_id) => {
props.showLoading() props.showLoading()
const res = await changeStatusFunction({ id, status_id }) const res = await changeStatusMerchant({ id, status_id })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData()
...@@ -60,13 +46,14 @@ const ToolNotificate = (props) => { ...@@ -60,13 +46,14 @@ const ToolNotificate = (props) => {
const getData = async () => { const getData = async () => {
props.showLoading() props.showLoading()
const res = await getListFunction({ const res = await getListMerchants({
name: searchDebount, name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
props.hideLoading() props.hideLoading()
console.log('res', res)
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
console.log(res.data) console.log(res.data)
...@@ -92,7 +79,7 @@ const ToolNotificate = (props) => { ...@@ -92,7 +79,7 @@ const ToolNotificate = (props) => {
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
const res = await deleteFunction({ id }) const res = await deleteMerchant({ id })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData()
......
...@@ -39,34 +39,46 @@ const columns = [ ...@@ -39,34 +39,46 @@ const columns = [
}, },
{ {
id: 'name', id: 'merchant_name',
label: 'Tên chức năng', label: 'Pháp nhân',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'code', id: 'tax_code',
label: 'Mã code', label: 'Mã số thuế',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'url', id: 'address',
label: ường dẫn', label: ịa chỉ',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'description', id: 'email',
label: 'Mô tả', label: 'Email',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'date_created', id: 'representative',
label: 'Ngày tạo', 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', align: 'left',
minWidth: 'auto', minWidth: 'auto',
}, },
......
...@@ -47,7 +47,7 @@ const SimpleForm = (props) => { ...@@ -47,7 +47,7 @@ const SimpleForm = (props) => {
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/function') history.push('/merchant')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Cập nhật hành động thành công!', { toast.success('Cập nhật hành động thành công!', {
theme: 'colored', theme: 'colored',
...@@ -81,10 +81,10 @@ const SimpleForm = (props) => { ...@@ -81,10 +81,10 @@ const SimpleForm = (props) => {
<Breadcrumb <Breadcrumb
routeSegments={[ routeSegments={[
{ {
name: 'Danh sách chức năng', name: 'Danh sách pháp nhân',
path: '/function', path: '/merchant',
}, },
{ name: 'Cập nhật chức năng' }, { name: 'Cập nhật pháp nhân' },
]} ]}
/> />
</div> </div>
...@@ -95,7 +95,7 @@ const SimpleForm = (props) => { ...@@ -95,7 +95,7 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Tên chức năng *" label="Tên pháp nhân *"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="name" name="name"
...@@ -154,7 +154,7 @@ const SimpleForm = (props) => { ...@@ -154,7 +154,7 @@ const SimpleForm = (props) => {
</Grid> </Grid>
</Grid> </Grid>
<Grid container justify={'flex-end'}> <Grid container justify={'flex-end'}>
<Link to="function"> <Link to="merchant">
<Button <Button
style={{ style={{
marginRight: 20, marginRight: 20,
......
...@@ -45,8 +45,8 @@ function CustomerView(props) { ...@@ -45,8 +45,8 @@ function CustomerView(props) {
<Breadcrumb <Breadcrumb
routeSegments={[ routeSegments={[
{ {
name: 'Danh sách chức năng', name: 'Danh sách pháp nhân',
path: '/function', path: '/merchant',
}, },
]} ]}
/> />
...@@ -66,7 +66,7 @@ function CustomerView(props) { ...@@ -66,7 +66,7 @@ function CustomerView(props) {
<TextField <TextField
variant="outlined" variant="outlined"
className="w-full" className="w-full"
label="Tên chức năng" label="Tên pháp nhân"
onChange={(e) => { onChange={(e) => {
const text = e.target.value const text = e.target.value
setTimeout(() => { setTimeout(() => {
...@@ -75,8 +75,8 @@ function CustomerView(props) { ...@@ -75,8 +75,8 @@ function CustomerView(props) {
}} }}
/> />
</Grid> </Grid>
{checkRole(user, '/function/create') ? ( {checkRole(user, '/merchant/create') ? (
<Link to="/function/create"> <Link to="/merchant/create">
<Button <Button
variant="contained" variant="contained"
className={'bg-light-primary'} className={'bg-light-primary'}
......
...@@ -35,7 +35,7 @@ const ToolNotificate = (props) => { ...@@ -35,7 +35,7 @@ const ToolNotificate = (props) => {
page_size: pageSize, page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null, from_date: startDate ? convertDate(startDate) : null,
to_date: endDate ? convertDate(endDate) : null, to_date: endDate ? convertDate(endDate) : null,
gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9', // gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { 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