Commit 2c5d250a by tdgiang

update build

parent 691ab984
......@@ -21,6 +21,7 @@ import InvoiceSupplier from './views/InvoiceSupplier/routes'
import Package from './views/package/routers'
import NccRouter from './views/Ncc/router'
import LandingpageRouter from './views/landingpage/router'
import PaymentSupplier from './views/PaymentSupplier/routes'
const redirectRoute = [
{
......@@ -37,6 +38,7 @@ const errorRoute = [
]
const routes = [
...PaymentSupplier,
...LandingpageRouter,
...NccRouter,
// ...Package,
......
......@@ -243,6 +243,35 @@ export const navigationsAdmin = [
},
{
name: 'Nhà cung cấp',
icon: 'wb_iridescent',
hide: false,
children: [
{
name: 'NCC thiết bị',
iconText: 'IV',
path: '/ncc',
hide: false,
id: 'INVOICE',
},
{
name: 'NCC hoá đơn',
iconText: 'IV',
path: '/invoice-supplier',
hide: false,
id: 'INVOICE_SUPPLIER',
},
{
name: 'Đối tác thanh toán',
iconText: 'IV',
path: '/payment-supplier',
hide: false,
id: 'INVOICE_SUPPLIER',
},
],
},
{
name: 'Quản lý hệ thống',
icon: 'wb_iridescent',
hide: false,
......@@ -276,21 +305,6 @@ export const navigationsAdmin = [
hide: false,
id: 'GROUP_ROLE',
},
{
name: 'NCC thiết bị',
iconText: 'IV',
path: '/ncc',
hide: false,
id: 'INVOICE',
},
{
name: 'NCC hoá đơn',
iconText: 'IV',
path: '/invoice-supplier',
hide: false,
id: 'INVOICE_SUPPLIER',
},
{
name: 'Log login,logout',
......
......@@ -6,45 +6,55 @@ import {
} from 'react-material-ui-form-validator'
import {
Button,
Icon,
Grid,
Radio,
RadioGroup,
MenuItem,
FormControlLabel,
Checkbox,
TextField,
Typography,
MenuItem,
Select,
InputLabel,
} from '@material-ui/core'
import { createFunction } from 'app/apis/Functions/function'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { toast } from 'react-toastify'
import { trimObject, toPriceVndInput } from 'app/config/Function'
import { trimObject, encryString, convertDate } from 'app/config/Function'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { createInvoiceSupp } from 'app/apis/Functions/supplierInvoice'
import { KeyboardDatePicker } from '@material-ui/pickers'
import {
dropdownDepartment,
dropdownUserGroup,
dropdownStore,
} from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage'
import { createSupplier } from 'app/apis/Functions/supplier'
import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const history = useHistory()
const [listAction, setListAction] = useState([])
const { user } = useAuth()
const { t } = useTranslation()
const history = useHistory()
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createInvoiceSupp({
const res = await createSupplier({
...newValue,
type: '1',
status: 1,
})
console.log(res)
props.hideLoading()
if (res.data.code == 200) {
history.push('/invoice-supplier')
if (res.data.code == 200) {
toast.success('Tạo đơn vị cung cấp hoá đơn thành công!', {
toast.success('Tạo nhà cung cấp hoá đơn thành công!', {
theme: 'colored',
})
}
......@@ -57,33 +67,13 @@ const SimpleForm = (props) => {
const handleChange = (event) => {
event.persist()
if (event.target.name === 'price_default') {
if (event.target.value !== null)
setState({
...state,
[event.target.name]: event.target.value.split('.').join(''),
})
} else
setState({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const {
supplier_name,
supplier_code,
address,
email,
phone,
representative,
} = state
const { provider_code, provider_name, phone, email, address } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
......@@ -91,10 +81,10 @@ const SimpleForm = (props) => {
<Breadcrumb
routeSegments={[
{
name: 'NCC hoá đơn',
name: 'Danh sách nhà cung cấp hoá đơn',
path: '/invoice-supplier',
},
{ name: 'Thêm mới NCC hoá đơn' },
{ name: 'Thêm mới' },
]}
/>
</div>
......@@ -105,11 +95,11 @@ const SimpleForm = (props) => {
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên đơn vị hoá đơn*"
label="Mã nhà cung cấp *"
onChange={handleChange}
type="text"
name="supplier_name"
value={supplier_name || ''}
name="provider_code"
value={provider_code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
......@@ -120,11 +110,11 @@ const SimpleForm = (props) => {
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã đơn vị *"
label="Tên nhà cung cấp *"
onChange={handleChange}
type="text"
name="supplier_code"
value={supplier_code || ''}
name="provider_name"
value={provider_name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
......@@ -135,29 +125,22 @@ const SimpleForm = (props) => {
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Địa chỉ *"
label="Số điện thoại *"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
name="phone"
value={phone || ''}
validators={[
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Người đại diện *"
onChange={handleChange}
type="text"
name="representative"
value={representative || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]}
/>
</Grid>
......@@ -182,23 +165,11 @@ const SimpleForm = (props) => {
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Số điện thoại *"
label="Địa chỉ"
onChange={handleChange}
type="text"
name="phone"
value={phone || ''}
validators={[
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
]}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]}
name="address"
value={address || ''}
/>
</Grid>
</Grid>
......@@ -229,6 +200,7 @@ const SimpleForm = (props) => {
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
......
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListInvoiceSupp,
changeStatusInvoiceSupp,
deleteInvoiceSupp,
} from 'app/apis/Functions/supplierInvoice'
getListSupplier,
deleteSupplier,
changeStatusSupplier,
} from 'app/apis/Functions/supplier'
import { useHistory } from 'react-router-dom'
import KEY from 'app/assets/Key'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
import useAuth from 'app/hooks/useAuth'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000)
const [status, setStatus] = useState()
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const [type, setType] = useState()
const [listType, setListType] = useState([])
const [status, setStatus] = useState()
const [listDrop, setListDrop] = useState([])
const [store, setStore] = useState()
const history = useHistory()
const { t } = useTranslation()
const [data, setData] = useState([])
const [permissions, setPermissions] = useState([])
const [listGroup, setListGroup] = useState([])
const [group, setGroup] = useState()
const { user } = useAuth()
useEffect(() => {}, [])
const [data, setData] = useState([])
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusInvoiceSupp({ id, status_id })
const res = await changeStatusSupplier({ id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
......@@ -42,41 +41,39 @@ const ToolNotificate = (props) => {
theme: 'colored',
})
} else {
toast.error(t(res.data.error), {
toast.error('Thay đổi trạng thái thất bại!', {
theme: 'colored',
})
}
}
const getData = async (init) => {
const getData = async (isInit) => {
props.showLoading()
let res
if (init) {
if (isInit) {
setPageIndex(0)
res = await getListInvoiceSupp({
supplier_code: searchDebount,
res = await getListSupplier({
provider_name: searchDebount,
page_no: 0,
page_size: pageSize,
status,
type_id: type,
type: 1,
})
} else {
res = await getListInvoiceSupp({
supplier_code: searchDebount,
res = await getListSupplier({
provider_name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
type_id: type,
type: 1,
})
}
props.hideLoading()
console.log(res.data)
if (res.data.code == 200 && res.data.data) {
console.log(res.data)
const newList = res.data.data.data.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
......@@ -85,26 +82,23 @@ const ToolNotificate = (props) => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
// enqueueSnackbar('Error!', { variant: 'error' })
}
}
useEffect(() => {
getData(false)
}, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount, status, type])
}, [searchDebount, status, store, group])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteInvoiceSupp({ id })
const res = await deleteSupplier({ id })
props.hideLoading()
if (res.data.code == 200) {
getData()
getData(true)
toast.success('Xoá bản ghi thành công!', {
theme: 'colored',
})
......@@ -114,7 +108,7 @@ const ToolNotificate = (props) => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
toast.error('Xoá bản ghi thất bại!', {
theme: 'colored',
})
}
......@@ -133,12 +127,14 @@ const ToolNotificate = (props) => {
activeSelected={activeSelected}
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
permissions={permissions}
status={status}
setStatus={setStatus}
listType={listType}
type={type}
setType={setType}
listDrop={listDrop}
store={store}
setStore={setStore}
listGroup={listGroup}
group={group}
setGroup={setGroup}
/>
)
}
......
......@@ -29,6 +29,7 @@ import DialogTransition from 'app/components/dialog/DialogTransition'
import { useHistory } from 'react-router-dom'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
const columns = [
{
id: 'index',
......@@ -36,42 +37,39 @@ const columns = [
align: 'center',
minWidth: 50,
},
{
id: 'supplier_name',
label: 'Tên NCC hoá đơn',
align: 'left',
minWidth: 'auto',
id: 'provider_code',
label: 'Mã nhà cung cấp',
align: 'center',
minWidth: 150,
},
{
id: 'supplier_code',
label: 'Mã đơn vị',
id: 'provider_name',
label: 'Tên nhà cung cấp',
align: 'left',
minWidth: 'auto',
minWidth: 200,
},
{
id: 'address',
label: 'Địa chỉ',
id: 'phone',
label: 'Số điện thoại',
align: 'left',
minWidth: 'auto',
minWidth: 100,
},
{
id: 'email',
label: 'Email',
align: 'left',
minWidth: 'auto',
minWidth: 150,
},
{
id: 'representative',
label: 'Người đại diện',
align: 'left',
minWidth: 'auto',
},
{
id: 'phone',
label: 'Số điện thoại',
id: 'address',
label: 'Địa chỉ',
align: 'left',
minWidth: 'auto',
minWidth: 250,
},
]
......@@ -107,6 +105,7 @@ function TableList(props) {
const handleClose = () => {
setOpen(false)
}
const { user } = useAuth()
return (
......@@ -127,16 +126,15 @@ function TableList(props) {
{column.label}
</TableCell>
))}
{checkRole(user, '/product/changeStatus') && (
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 125,
width: 145,
}}
>
Trạng thái
</TableCell>
)}
<TableCell
style={{
......@@ -180,10 +178,7 @@ function TableList(props) {
</TableCell>
)
})}
{checkRole(
user,
'/invoice-supplier/changeStatus'
) && (
<TableCell className={classes.border}>
<Select
variant={'outlined'}
......@@ -202,12 +197,9 @@ function TableList(props) {
<MenuItem value={1}>
Hot động
</MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
<MenuItem value={2}>Khóa</MenuItem>
</Select>
</TableCell>
)}
<TableCell>
{checkRole(
user,
......@@ -219,7 +211,7 @@ function TableList(props) {
setSelected({
...row,
title: 'Xóa NCC hoá đơn',
content: `Bạn có muốn xóa NCC hoá đơn ${row.supplier_name} hay không?`,
content: `Bạn có muốn xóa NCC hoá đơn ${row.provider_name} hay không?`,
})
setOpen(true)
}}
......@@ -232,6 +224,7 @@ function TableList(props) {
</IconButton>
</Tooltip>
) : null}
{checkRole(
user,
'/invoice-supplier/update'
......
......@@ -31,17 +31,21 @@ function CustomerView(props) {
setPageIndex,
pageIndex,
totalRecords,
permissions,
status,
setStatus,
listType,
type,
setType,
store,
setStore,
listDrop,
listGroup,
group,
setGroup,
} = props
const { user } = useAuth()
const handleChange = (event) => {
setAge(event.target.value)
}
const { user } = useAuth()
return (
<Fragment>
<div className="m-sm-30">
......@@ -49,7 +53,7 @@ function CustomerView(props) {
<Breadcrumb
routeSegments={[
{
name: 'NCC hoá đơn',
name: 'Danh sách nhà cung cấp hoá đơn',
path: '/invoice-supplier',
},
]}
......@@ -67,19 +71,19 @@ function CustomerView(props) {
spacing={3}
>
<Grid
container
spacing={3}
container
item
lg={8}
md={8}
sm={8}
xs={8}
>
<Grid item lg={4} md={4} sm={4} xs={4}>
<Grid item lg={3} md={3} sm={3} xs={3}>
<TextField
variant="outlined"
className="w-full"
label="Tìm kiếm"
label="Nhập từ khoá"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
......@@ -89,7 +93,7 @@ function CustomerView(props) {
/>
</Grid>
<Grid item lg={4} md={4} sm={4} xs={4}>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Trng thái
......@@ -124,7 +128,6 @@ function CustomerView(props) {
</FormControl>
</Grid>
</Grid>
{checkRole(user, '/invoice-supplier/create') ? (
<Link to="/invoice-supplier/create">
<Button
......@@ -147,7 +150,6 @@ function CustomerView(props) {
pageIndex={pageIndex}
setPageIndex={setPageIndex}
totalRecords={totalRecords}
permissions={permissions}
/>
</div>
</Fragment>
......
......@@ -46,15 +46,15 @@ const SimpleForm = (props) => {
props.showLoading()
const res = await createSupplier({
...newValue,
type: parseInt(newValue?.type),
type: '3',
status: 1,
})
console.log(res)
props.hideLoading()
if (res.data.code == 200) {
history.push('/ncc')
if (res.data.code == 200) {
toast.success('Tạo nhân viên thành công!', {
toast.success('Tạo nhà cung cấp thiết bị thành công!', {
theme: 'colored',
})
}
......@@ -73,7 +73,7 @@ const SimpleForm = (props) => {
})
}
const { provider_code, provider_name, phone, email, address, type } = state
const { provider_code, provider_name, phone, email, address } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
......@@ -91,45 +91,6 @@ const SimpleForm = (props) => {
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Loại nhà cung cấp *'}
className="mb-4 w-full"
value={type || ''}
displayEmpty
name="type"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{[
{
id: '0',
name: 'Cổng thanh toán',
},
{
id: '1',
name: 'Hoá đơn',
},
{
id: '2',
name: 'Nhiên liệu',
},
{
id: '3',
name: 'Thiết bị',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
......
......@@ -54,17 +54,19 @@ const ToolNotificate = (props) => {
if (isInit) {
setPageIndex(0)
res = await getListSupplier({
supp_name: searchDebount,
provider_name: searchDebount,
page_no: 0,
page_size: pageSize,
status,
type: 3,
})
} else {
res = await getListSupplier({
supp_name: searchDebount,
provider_name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
type: 3,
})
}
......
......@@ -207,7 +207,7 @@ function TableList(props) {
onClick={() => {
setSelected({
...row,
title: 'Xóa NCC',
title: 'Xóa NCC thiết bị',
content: `Bạn có muốn xóa NCC thiết bị ${row.provider_name} hay không?`,
})
setOpen(true)
......
......@@ -45,7 +45,7 @@ const SimpleForm = (props) => {
props.showLoading()
try {
const res = await detailSupplier(location.state, {})
setState({ ...res.data.data, type: `${res.data.data.type}` })
setState({ ...res.data.data })
} catch (err) {
toast.error(t(err), {
theme: 'colored',
......@@ -60,14 +60,12 @@ const SimpleForm = (props) => {
props.showLoading()
const res = await updateSupplier({
...newValue,
type: parseInt(newValue?.type),
})
console.log(res)
props.hideLoading()
if (res.data.code == 200) {
history.push('/ncc')
if (res.data.code == 200) {
toast.success('Cập nhật nhân viên thành công!', {
toast.success('Cập nhật nhà cung cấp thiết bị thành công!', {
theme: 'colored',
})
}
......@@ -86,7 +84,7 @@ const SimpleForm = (props) => {
})
}
const { provider_code, provider_name, phone, email, address, type } = state
const { provider_code, provider_name, phone, email, address } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
......@@ -104,45 +102,6 @@ const SimpleForm = (props) => {
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Loại nhà cung cấp *'}
className="mb-4 w-full"
value={type || ''}
displayEmpty
name="type"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{[
{
id: '0',
name: 'Cổng thanh toán',
},
{
id: '1',
name: 'Hoá đơn',
},
{
id: '2',
name: 'Nhiên liệu',
},
{
id: '3',
name: 'Thiết bị',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
......
......@@ -52,7 +52,10 @@ function CustomerView(props) {
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{ name: 'Danh sách nhà cung cấp', path: '/ncc' },
{
name: 'Danh sách nhà cung cấp thiết bị',
path: '/ncc',
},
]}
/>
</div>
......
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import {
Button,
Grid,
MenuItem,
FormControlLabel,
Checkbox,
Typography,
} from '@material-ui/core'
import { createFunction } from 'app/apis/Functions/function'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject, encryString, convertDate } from 'app/config/Function'
import { connect } from 'react-redux'
import { KeyboardDatePicker } from '@material-ui/pickers'
import {
dropdownDepartment,
dropdownUserGroup,
dropdownStore,
} from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage'
import { createSupplier } from 'app/apis/Functions/supplier'
import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const [listAction, setListAction] = useState([])
const { user } = useAuth()
const { t } = useTranslation()
const history = useHistory()
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createSupplier({
...newValue,
type: 0,
status: 1,
})
console.log(res)
props.hideLoading()
if (res.data.code == 200) {
history.push('/payment-supplier')
if (res.data.code == 200) {
toast.success('Tạo nhà đối tác thanh toán thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const { provider_code, provider_name, phone, email, address } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Đối tác thanh toán',
path: '/payment-supplier',
},
{ name: 'Thêm mới' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã đối tác *"
onChange={handleChange}
type="text"
name="provider_code"
value={provider_code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên đối tác *"
onChange={handleChange}
type="text"
name="provider_name"
value={provider_name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Số điện thoại *"
onChange={handleChange}
type="text"
name="phone"
value={phone || ''}
validators={[
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
]}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Email *"
onChange={handleChange}
type="text"
name="email"
value={email || ''}
validators={['required', 'isEmail']}
errorMessages={[
'Không được để trống trường này',
'Email không hợp lệ',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Địa chỉ"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
/>
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Link to="/invoice-supplier">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Thêm mi</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListSupplier,
deleteSupplier,
changeStatusSupplier,
} from 'app/apis/Functions/supplier'
import { useHistory } from 'react-router-dom'
import KEY from 'app/assets/Key'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
import useAuth from 'app/hooks/useAuth'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000)
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const [status, setStatus] = useState()
const [listDrop, setListDrop] = useState([])
const [store, setStore] = useState()
const history = useHistory()
const [listGroup, setListGroup] = useState([])
const [group, setGroup] = useState()
const { user } = useAuth()
const [data, setData] = useState([])
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusSupplier({ id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Thay đổi trạng thái thành công!', {
theme: 'colored',
})
} else {
toast.error('Thay đổi trạng thái thất bại!', {
theme: 'colored',
})
}
}
const getData = async (isInit) => {
props.showLoading()
let res
if (isInit) {
setPageIndex(0)
res = await getListSupplier({
provider_name: searchDebount,
page_no: 0,
page_size: pageSize,
status,
type: 0,
})
} else {
res = await getListSupplier({
provider_name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
type: 0,
})
}
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.data.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
// enqueueSnackbar('Error!', { variant: 'error' })
}
}
useEffect(() => {
getData(false)
}, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount, status, store, group])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteSupplier({ id })
props.hideLoading()
if (res.data.code == 200) {
getData(true)
toast.success('Xoá bản ghi thành công!', {
theme: 'colored',
})
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Xoá bản ghi thất bại!', {
theme: 'colored',
})
}
}
return (
<ToolUserView
data={data}
removeItem={removeItem}
setTxtSearch={setTxtSearch}
setActiveSeleted={setActiveSeleted}
pageIndex={pageIndex}
changeActive={changeActive}
setChangeActive={setChangeActive}
setPageIndex={setPageIndex}
activeSelected={activeSelected}
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
status={status}
setStatus={setStatus}
listDrop={listDrop}
store={store}
setStore={setStore}
listGroup={listGroup}
group={group}
setGroup={setGroup}
/>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
ToolNotificate
)
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import {
Button,
Grid,
MenuItem,
FormControlLabel,
Checkbox,
Typography,
} from '@material-ui/core'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import {
trimObject,
encryString,
convertDate,
convertTimeApi,
} from 'app/config/Function'
import { connect } from 'react-redux'
import { detailSupplier, updateSupplier } from 'app/apis/Functions/supplier'
import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const location = useLocation()
const [image, setImage] = useState()
const { user } = useAuth()
const [date, setDate] = useState(null)
const { t } = useTranslation()
useEffect(() => {
getDataDefault()
}, [])
const history = useHistory()
const getDataDefault = async () => {
props.showLoading()
try {
const res = await detailSupplier(location.state, {})
setState({ ...res.data.data })
} catch (err) {
toast.error(t(err), {
theme: 'colored',
})
}
props.hideLoading()
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await updateSupplier({
...newValue,
})
console.log(res)
props.hideLoading()
if (res.data.code == 200) {
history.push('/payment-supplier')
if (res.data.code == 200) {
toast.success('Cập nhật đối tác thanh toán thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const { provider_code, provider_name, phone, email, address } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Đối tác thanh toán',
path: '/payment-supplier',
},
{ name: 'Cập nhật' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã đối tác *"
onChange={handleChange}
type="text"
name="provider_code"
disabled={true}
value={provider_code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên đối tác *"
onChange={handleChange}
type="text"
name="provider_name"
value={provider_name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Số điện thoại *"
onChange={handleChange}
type="text"
name="phone"
value={phone || ''}
validators={[
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
]}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Email *"
onChange={handleChange}
type="text"
name="email"
value={email || ''}
validators={['required', 'isEmail']}
errorMessages={[
'Không được để trống trường này',
'Email không hợp lệ',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Địa chỉ"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
/>
</Grid>
</Grid>
<Grid
style={{ marginTop: 20 }}
container
justify={'flex-end'}
>
<Link to="/invoice-supplier">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Cp nht</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { Fragment, useState, useEffect } from 'react'
import {
TextField,
Icon,
Button,
StepLabel,
Step,
Stepper,
Grid,
FormControl,
InputLabel,
Select,
MenuItem,
} from '@material-ui/core'
import Table from './Table'
import { Breadcrumb } from 'app/components'
import { Link } from 'react-router-dom'
import { Autocomplete, createFilterOptions } from '@material-ui/lab'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
function CustomerView(props) {
const [age, setAge] = React.useState('')
const {
data,
updateItem,
removeItem,
setTxtSearch,
changeActive,
setChangeActive,
handeChangeActive,
setPageIndex,
pageIndex,
totalRecords,
status,
setStatus,
store,
setStore,
listDrop,
listGroup,
group,
setGroup,
} = props
const handleChange = (event) => {
setAge(event.target.value)
}
const { user } = useAuth()
return (
<Fragment>
<div className="m-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Đối tác thanh toán',
path: '/payment-supplier',
},
]}
/>
</div>
<Grid
style={{
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid
spacing={3}
container
item
lg={8}
md={8}
sm={8}
xs={8}
>
<Grid item lg={3} md={3} sm={3} xs={3}>
<TextField
variant="outlined"
className="w-full"
label="Nhập từ khoá"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Trng thái
</InputLabel>
<Select
label="Trạng thái"
value={status}
onChange={(e) => setStatus(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{[
{
id: 1,
name: 'Hoạt động',
},
{
id: 2,
name: 'Khoá',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid>
{checkRole(user, '/payment-supplier/create') ? (
<Link to="/payment-supplier/create">
<Button
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>Thêm mi</span>
</Button>
</Link>
) : null}
</Grid>
<Table
data={data}
changeActive={changeActive}
setChangeActive={setChangeActive}
handeChangeActive={handeChangeActive}
updateItem={updateItem}
removeItem={removeItem}
pageIndex={pageIndex}
setPageIndex={setPageIndex}
totalRecords={totalRecords}
/>
</div>
</Fragment>
)
}
export default CustomerView
import React from 'react'
const routes = [
{
path: '/payment-supplier/update',
component: React.lazy(() => import('./Update')),
},
{
path: '/payment-supplier/create',
component: React.lazy(() => import('./Create')),
},
{
path: '/payment-supplier',
component: React.lazy(() => import('./Index')),
},
]
export default routes
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