Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CmsPetrolPay
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
11
Issues
11
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
CmsPetrolPay
Commits
6a1f19b5
Commit
6a1f19b5
authored
Jan 25, 2024
by
tdgiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
be49e123
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
346 additions
and
74 deletions
+346
-74
Index.js
src/app/views/Company/Employee/Index.js
+36
-17
Table.js
src/app/views/Company/Employee/Table.js
+6
-6
View.js
src/app/views/Company/Employee/View.js
+86
-12
Create.js
src/app/views/Company/Function/Create.js
+1
-1
Update.js
src/app/views/Company/Function/Update.js
+1
-1
Table.js
src/app/views/Company/GroupRole/Table.js
+3
-2
Index.js
src/app/views/Company/Role/Index.js
+26
-1
Table.js
src/app/views/Company/Role/Table.js
+10
-3
View.js
src/app/views/Company/Role/View.js
+53
-12
Index.js
src/app/views/Merchant/Index.js
+1
-1
Create.js
src/app/views/product/product/Create.js
+1
-1
Index.js
src/app/views/product/product/Index.js
+33
-4
Update.js
src/app/views/product/product/Update.js
+1
-1
View.js
src/app/views/product/product/View.js
+88
-12
No files found.
src/app/views/Company/Employee/Index.js
View file @
6a1f19b5
...
@@ -12,6 +12,10 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
...
@@ -12,6 +12,10 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import
{
toast
}
from
'react-toastify'
import
{
toast
}
from
'react-toastify'
import
useDebounce
from
'app/hooks/useDebounce'
import
useDebounce
from
'app/hooks/useDebounce'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
dropdownDepartment
,
dropdownUserGroup
,
}
from
'app/apis/Functions/dropdown'
const
ToolNotificate
=
(
props
)
=>
{
const
ToolNotificate
=
(
props
)
=>
{
const
[
txtSearch
,
setTxtSearch
]
=
useState
(
''
)
const
[
txtSearch
,
setTxtSearch
]
=
useState
(
''
)
...
@@ -21,29 +25,21 @@ const ToolNotificate = (props) => {
...
@@ -21,29 +25,21 @@ const ToolNotificate = (props) => {
const
[
pageIndex
,
setPageIndex
]
=
useState
(
0
)
const
[
pageIndex
,
setPageIndex
]
=
useState
(
0
)
const
[
pageSize
]
=
useState
(
10
)
const
[
pageSize
]
=
useState
(
10
)
const
[
totalRecords
,
setTotalRecord
]
=
useState
(
0
)
const
[
totalRecords
,
setTotalRecord
]
=
useState
(
0
)
const
[
status
,
setStatus
]
=
useState
()
const
history
=
useHistory
()
const
history
=
useHistory
()
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
[
data
,
setData
]
=
useState
([])
const
[
data
,
setData
]
=
useState
([])
const
[
permissions
,
setPermissions
]
=
useState
([])
const
[
permissions
,
setPermissions
]
=
useState
([])
// useEffect(() => {
const
[
role
,
setRole
]
=
useState
()
// getListPermission();
const
[
listRole
,
setListRole
]
=
useState
([])
// }, []);
// const getListPermission = () => {
useEffect
(()
=>
{
// let temp = localStorage.getItem(KEY.LISTPATH);
getUserGroup
()
// 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
changeStatusEmployee
({
id
,
status_id
})
const
res
=
await
changeStatusEmployee
({
id
:
id
,
status_id
})
props
.
hideLoading
()
props
.
hideLoading
()
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
getData
()
getData
()
...
@@ -64,6 +60,8 @@ const ToolNotificate = (props) => {
...
@@ -64,6 +60,8 @@ const ToolNotificate = (props) => {
full_name
:
searchDebount
,
full_name
:
searchDebount
,
page_no
:
pageIndex
+
1
,
page_no
:
pageIndex
+
1
,
page_size
:
pageSize
,
page_size
:
pageSize
,
status
,
user_group_id
:
role
,
})
})
props
.
hideLoading
()
props
.
hideLoading
()
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
...
@@ -87,7 +85,7 @@ const ToolNotificate = (props) => {
...
@@ -87,7 +85,7 @@ const ToolNotificate = (props) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
getData
()
getData
()
},
[
searchDebount
,
pageIndex
])
},
[
searchDebount
,
pageIndex
,
status
,
role
])
const
removeItem
=
async
(
id
)
=>
{
const
removeItem
=
async
(
id
)
=>
{
props
.
showLoading
()
props
.
showLoading
()
...
@@ -110,6 +108,22 @@ const ToolNotificate = (props) => {
...
@@ -110,6 +108,22 @@ const ToolNotificate = (props) => {
}
}
}
}
const
getUserGroup
=
async
()
=>
{
const
res
=
await
dropdownUserGroup
({})
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
setListRole
(
res
.
data
.
data
)
}
else
if
(
res
.
data
.
code
==
401
)
{
setTimeout
(()
=>
{
history
.
push
(
'/'
)
},
100
)
}
else
{
toast
.
error
(
t
(
res
.
data
.
error
),
{
theme
:
'colored'
,
})
}
}
return
(
return
(
<
ToolUserView
<
ToolUserView
data
=
{
data
}
data
=
{
data
}
...
@@ -124,6 +138,11 @@ const ToolNotificate = (props) => {
...
@@ -124,6 +138,11 @@ const ToolNotificate = (props) => {
handeChangeActive
=
{
handeChangeActive
}
handeChangeActive
=
{
handeChangeActive
}
totalRecords
=
{
totalRecords
}
totalRecords
=
{
totalRecords
}
permissions
=
{
permissions
}
permissions
=
{
permissions
}
status
=
{
status
}
setStatus
=
{
setStatus
}
role
=
{
role
}
setRole
=
{
setRole
}
listRole
=
{
listRole
}
/
>
/
>
)
)
}
}
...
...
src/app/views/Company/Employee/Table.js
View file @
6a1f19b5
...
@@ -55,12 +55,12 @@ const columns = [
...
@@ -55,12 +55,12 @@ const columns = [
align
:
'left'
,
align
:
'left'
,
minWidth
:
'auto'
,
minWidth
:
'auto'
,
},
},
//
{
{
// id: 'phon
e',
id
:
'user_group_nam
e'
,
// label: 'Điện thoại
',
label
:
'Vai trò
'
,
//
align: 'left',
align
:
'left'
,
//
minWidth: 'auto',
minWidth
:
'auto'
,
//
},
},
]
]
function
TableList
(
props
)
{
function
TableList
(
props
)
{
...
...
src/app/views/Company/Employee/View.js
View file @
6a1f19b5
...
@@ -32,6 +32,11 @@ function CustomerView(props) {
...
@@ -32,6 +32,11 @@ function CustomerView(props) {
pageIndex
,
pageIndex
,
totalRecords
,
totalRecords
,
permissions
,
permissions
,
status
,
setStatus
,
role
,
setRole
,
listRole
,
}
=
props
}
=
props
const
handleChange
=
(
event
)
=>
{
const
handleChange
=
(
event
)
=>
{
setAge
(
event
.
target
.
value
)
setAge
(
event
.
target
.
value
)
...
@@ -59,18 +64,87 @@ function CustomerView(props) {
...
@@ -59,18 +64,87 @@ function CustomerView(props) {
container
container
spacing
=
{
3
}
spacing
=
{
3
}
>
>
<
Grid
item
lg
=
{
3
}
md
=
{
3
}
sm
=
{
6
}
xs
=
{
6
}
>
<
Grid
<
TextField
container
variant
=
"outlined"
spacing
=
{
3
}
className
=
"w-full"
item
label
=
"Tên thành viên"
lg
=
{
8
}
onChange
=
{(
e
)
=>
{
md
=
{
8
}
const
text
=
e
.
target
.
value
sm
=
{
8
}
setTimeout
(()
=>
{
xs
=
{
8
}
setTxtSearch
(
text
)
>
},
1000
)
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
4
}
xs
=
{
4
}
>
}}
<
TextField
/
>
variant
=
"outlined"
className
=
"w-full"
label
=
"Tên thành viên"
onChange
=
{(
e
)
=>
{
const
text
=
e
.
target
.
value
setTimeout
(()
=>
{
setTxtSearch
(
text
)
},
1000
)
}}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
4
}
xs
=
{
4
}
>
<
FormControl
variant
=
"outlined"
fullWidth
>
<
InputLabel
htmlFor
=
"outlined-age-native-simple"
>
Vai
tr
ò
<
/InputLabel
>
<
Select
label
=
"Vai trò"
value
=
{
role
}
onChange
=
{(
e
)
=>
setRole
(
e
.
target
.
value
)}
inputProps
=
{{
name
:
'age'
,
id
:
'outlined-age-native-simple'
,
}}
>
<
MenuItem
value
=
""
>
<
em
>
T
ấ
t
c
ả
<
/em
>
<
/MenuItem
>
{
listRole
.
map
((
e
)
=>
(
<
MenuItem
value
=
{
e
.
id
}
>
{
e
.
name
}
<
/MenuItem
>
))}
<
/Select
>
<
/FormControl
>
<
/Grid
>
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
4
}
xs
=
{
4
}
>
<
FormControl
variant
=
"outlined"
fullWidth
>
<
InputLabel
htmlFor
=
"outlined-age-native-simple"
>
Tr
ạ
ng
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
>
T
ấ
t
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
>
<
/Grid
>
{
checkRole
(
user
,
'/employee/create'
)
?
(
{
checkRole
(
user
,
'/employee/create'
)
?
(
<
Link
to
=
"/employee/create"
>
<
Link
to
=
"/employee/create"
>
...
...
src/app/views/Company/Function/Create.js
View file @
6a1f19b5
...
@@ -27,7 +27,7 @@ const SimpleForm = (props) => {
...
@@ -27,7 +27,7 @@ const SimpleForm = (props) => {
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
history
.
push
(
'/function'
)
history
.
push
(
'/function'
)
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
toast
.
success
(
'Tạo
hành độ
ng thành công!'
,
{
toast
.
success
(
'Tạo
chức nă
ng thành công!'
,
{
theme
:
'colored'
,
theme
:
'colored'
,
})
})
}
}
...
...
src/app/views/Company/Function/Update.js
View file @
6a1f19b5
...
@@ -51,7 +51,7 @@ const SimpleForm = (props) => {
...
@@ -51,7 +51,7 @@ const SimpleForm = (props) => {
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
history
.
push
(
'/function'
)
history
.
push
(
'/function'
)
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
chức nă
ng thành công!'
,
{
theme
:
'colored'
,
theme
:
'colored'
,
})
})
}
}
...
...
src/app/views/Company/GroupRole/Table.js
View file @
6a1f19b5
...
@@ -49,6 +49,7 @@ const columns = [
...
@@ -49,6 +49,7 @@ const columns = [
align
:
'left'
,
align
:
'left'
,
minWidth
:
'auto'
,
minWidth
:
'auto'
,
},
},
{
{
id
:
'date_created'
,
id
:
'date_created'
,
label
:
'Ngày tạo'
,
label
:
'Ngày tạo'
,
...
@@ -56,8 +57,8 @@ const columns = [
...
@@ -56,8 +57,8 @@ const columns = [
minWidth
:
'auto'
,
minWidth
:
'auto'
,
},
},
{
{
id
:
'date_
cre
ated'
,
id
:
'date_
upd
ated'
,
label
:
'Ngày
tạo
'
,
label
:
'Ngày
cập nhật
'
,
align
:
'left'
,
align
:
'left'
,
minWidth
:
'auto'
,
minWidth
:
'auto'
,
},
},
...
...
src/app/views/Company/Role/Index.js
View file @
6a1f19b5
...
@@ -12,6 +12,8 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
...
@@ -12,6 +12,8 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import
{
toast
}
from
'react-toastify'
import
{
toast
}
from
'react-toastify'
import
useDebounce
from
'app/hooks/useDebounce'
import
useDebounce
from
'app/hooks/useDebounce'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
getDropFunction
}
from
'app/apis/Functions/dropdown'
const
ToolNotificate
=
(
props
)
=>
{
const
ToolNotificate
=
(
props
)
=>
{
const
[
txtSearch
,
setTxtSearch
]
=
useState
(
''
)
const
[
txtSearch
,
setTxtSearch
]
=
useState
(
''
)
const
[
activeSelected
,
setActiveSeleted
]
=
useState
(
null
)
const
[
activeSelected
,
setActiveSeleted
]
=
useState
(
null
)
...
@@ -21,12 +23,18 @@ const ToolNotificate = (props) => {
...
@@ -21,12 +23,18 @@ const ToolNotificate = (props) => {
const
[
pageIndex
,
setPageIndex
]
=
useState
(
0
)
const
[
pageIndex
,
setPageIndex
]
=
useState
(
0
)
const
[
pageSize
]
=
useState
(
10
)
const
[
pageSize
]
=
useState
(
10
)
const
[
totalRecords
,
setTotalRecord
]
=
useState
(
0
)
const
[
totalRecords
,
setTotalRecord
]
=
useState
(
0
)
const
[
listFunction
,
setListFunction
]
=
useState
([])
const
[
function_id
,
setFunction
]
=
useState
()
const
history
=
useHistory
()
const
history
=
useHistory
()
const
[
data
,
setData
]
=
useState
([])
const
[
data
,
setData
]
=
useState
([])
const
[
permissions
,
setPermissions
]
=
useState
([])
const
[
permissions
,
setPermissions
]
=
useState
([])
useEffect
(()
=>
{
getDropDown
()
},
[])
const
handeChangeActive
=
async
(
id
,
status_id
)
=>
{
const
handeChangeActive
=
async
(
id
,
status_id
)
=>
{
props
.
showLoading
()
props
.
showLoading
()
const
res
=
await
changeStatusAction
({
id
,
status_id
})
const
res
=
await
changeStatusAction
({
id
,
status_id
})
...
@@ -49,6 +57,7 @@ const ToolNotificate = (props) => {
...
@@ -49,6 +57,7 @@ const ToolNotificate = (props) => {
name
:
searchDebount
,
name
:
searchDebount
,
page_no
:
pageIndex
+
1
,
page_no
:
pageIndex
+
1
,
page_size
:
pageSize
,
page_size
:
pageSize
,
function_id
,
})
})
props
.
hideLoading
()
props
.
hideLoading
()
...
@@ -75,7 +84,7 @@ const ToolNotificate = (props) => {
...
@@ -75,7 +84,7 @@ const ToolNotificate = (props) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
getData
()
getData
()
},
[
txtSearch
,
pageIndex
])
},
[
searchDebount
,
pageIndex
,
function_id
])
const
removeItem
=
async
(
id
)
=>
{
const
removeItem
=
async
(
id
)
=>
{
props
.
showLoading
()
props
.
showLoading
()
...
@@ -98,6 +107,19 @@ const ToolNotificate = (props) => {
...
@@ -98,6 +107,19 @@ const ToolNotificate = (props) => {
}
}
}
}
const
getDropDown
=
async
()
=>
{
try
{
const
res
=
await
getDropFunction
()
console
.
log
(
res
)
const
newList
=
res
.
data
.
data
.
map
((
e
)
=>
{
return
{
...
e
}
})
setListFunction
(
newList
)
}
catch
(
err
)
{
//toast.error(t(err))
}
}
return
(
return
(
<
ToolUserView
<
ToolUserView
data
=
{
data
}
data
=
{
data
}
...
@@ -112,6 +134,9 @@ const ToolNotificate = (props) => {
...
@@ -112,6 +134,9 @@ const ToolNotificate = (props) => {
handeChangeActive
=
{
handeChangeActive
}
handeChangeActive
=
{
handeChangeActive
}
totalRecords
=
{
totalRecords
}
totalRecords
=
{
totalRecords
}
permissions
=
{
permissions
}
permissions
=
{
permissions
}
function_id
=
{
function_id
}
setFunction
=
{
setFunction
}
listFunction
=
{
listFunction
}
/
>
/
>
)
)
}
}
...
...
src/app/views/Company/Role/Table.js
View file @
6a1f19b5
...
@@ -36,19 +36,26 @@ const columns = [
...
@@ -36,19 +36,26 @@ const columns = [
align
:
'center'
,
align
:
'center'
,
minWidth
:
50
,
minWidth
:
50
,
},
},
{
id
:
'code'
,
label
:
'Mã code'
,
align
:
'left'
,
minWidth
:
'auto'
,
},
{
{
id
:
'name'
,
id
:
'name'
,
label
:
'Tên
chức nă
ng'
,
label
:
'Tên
hành độ
ng'
,
align
:
'left'
,
align
:
'left'
,
minWidth
:
'auto'
,
minWidth
:
'auto'
,
},
},
{
{
id
:
'
cod
e'
,
id
:
'
function_nam
e'
,
label
:
'
Mã code
'
,
label
:
'
Thuộc chức năng
'
,
align
:
'left'
,
align
:
'left'
,
minWidth
:
'auto'
,
minWidth
:
'auto'
,
},
},
{
{
id
:
'url'
,
id
:
'url'
,
label
:
'Đường dẫn'
,
label
:
'Đường dẫn'
,
...
...
src/app/views/Company/Role/View.js
View file @
6a1f19b5
...
@@ -32,6 +32,9 @@ function CustomerView(props) {
...
@@ -32,6 +32,9 @@ function CustomerView(props) {
pageIndex
,
pageIndex
,
totalRecords
,
totalRecords
,
permissions
,
permissions
,
function_id
,
setFunction
,
listFunction
,
}
=
props
}
=
props
const
{
user
}
=
useAuth
()
const
{
user
}
=
useAuth
()
const
handleChange
=
(
event
)
=>
{
const
handleChange
=
(
event
)
=>
{
...
@@ -61,18 +64,56 @@ function CustomerView(props) {
...
@@ -61,18 +64,56 @@ function CustomerView(props) {
container
container
spacing
=
{
3
}
spacing
=
{
3
}
>
>
<
Grid
item
lg
=
{
3
}
md
=
{
3
}
sm
=
{
6
}
xs
=
{
6
}
>
<
Grid
<
TextField
container
variant
=
"outlined"
item
className
=
"w-full"
spacing
=
{
3
}
label
=
"Tên hành động"
lg
=
{
8
}
onChange
=
{(
e
)
=>
{
md
=
{
8
}
const
text
=
e
.
target
.
value
sm
=
{
8
}
setTimeout
(()
=>
{
xs
=
{
8
}
setTxtSearch
(
text
)
>
},
1000
)
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
6
}
xs
=
{
6
}
>
}}
<
TextField
/
>
variant
=
"outlined"
className
=
"w-full"
label
=
"Tên hành động"
onChange
=
{(
e
)
=>
{
const
text
=
e
.
target
.
value
setTimeout
(()
=>
{
setTxtSearch
(
text
)
},
1000
)
}}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
6
}
xs
=
{
6
}
>
<
FormControl
variant
=
"outlined"
fullWidth
>
<
InputLabel
htmlFor
=
"outlined-age-native-simple"
>
Ch
ứ
c
n
ă
ng
<
/InputLabel
>
<
Select
label
=
"Chức năng"
value
=
{
function_id
}
onChange
=
{(
e
)
=>
setFunction
(
e
.
target
.
value
)
}
inputProps
=
{{
name
:
'age'
,
id
:
'outlined-age-native-simple'
,
}}
>
<
MenuItem
value
=
""
>
<
em
>
T
ấ
t
c
ả
<
/em
>
<
/MenuItem
>
{
listFunction
.
map
((
e
)
=>
(
<
MenuItem
value
=
{
e
.
id
}
>
{
e
.
name
}
<
/MenuItem
>
))}
<
/Select
>
<
/FormControl
>
<
/Grid
>
<
/Grid
>
<
/Grid
>
{
checkRole
(
user
,
'/role/create'
)
?
(
{
checkRole
(
user
,
'/role/create'
)
?
(
<
Link
to
=
"/role/create"
>
<
Link
to
=
"/role/create"
>
...
...
src/app/views/Merchant/Index.js
View file @
6a1f19b5
...
@@ -47,7 +47,7 @@ const ToolNotificate = (props) => {
...
@@ -47,7 +47,7 @@ const ToolNotificate = (props) => {
const
getData
=
async
()
=>
{
const
getData
=
async
()
=>
{
props
.
showLoading
()
props
.
showLoading
()
const
res
=
await
getListMerchants
({
const
res
=
await
getListMerchants
({
name
:
searchDebount
,
text_search
:
searchDebount
,
page_no
:
pageIndex
+
1
,
page_no
:
pageIndex
+
1
,
page_size
:
pageSize
,
page_size
:
pageSize
,
})
})
...
...
src/app/views/product/product/Create.js
View file @
6a1f19b5
...
@@ -119,7 +119,7 @@ const SimpleForm = (props) => {
...
@@ -119,7 +119,7 @@ const SimpleForm = (props) => {
<
Grid
xs
=
{
6
}
sm
=
{
6
}
item
>
<
Grid
xs
=
{
6
}
sm
=
{
6
}
item
>
<
SelectValidator
<
SelectValidator
variant
=
{
'outlined'
}
variant
=
{
'outlined'
}
label
=
{
'Thuộc
chức năng
*'
}
label
=
{
'Thuộc
loại sản phẩm
*'
}
className
=
"mb-4 w-full"
className
=
"mb-4 w-full"
value
=
{
type_id
||
''
}
value
=
{
type_id
||
''
}
displayEmpty
displayEmpty
...
...
src/app/views/product/product/Index.js
View file @
6a1f19b5
...
@@ -12,24 +12,31 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
...
@@ -12,24 +12,31 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import
{
toast
}
from
'react-toastify'
import
{
toast
}
from
'react-toastify'
import
useDebounce
from
'app/hooks/useDebounce'
import
useDebounce
from
'app/hooks/useDebounce'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
dropdownProductType
}
from
'app/apis/Functions/dropdown'
const
ToolNotificate
=
(
props
)
=>
{
const
ToolNotificate
=
(
props
)
=>
{
const
[
txtSearch
,
setTxtSearch
]
=
useState
(
''
)
const
[
txtSearch
,
setTxtSearch
]
=
useState
(
''
)
const
[
activeSelected
,
setActiveSeleted
]
=
useState
(
null
)
const
[
activeSelected
,
setActiveSeleted
]
=
useState
(
null
)
const
[
changeActive
,
setChangeActive
]
=
useState
(
1
)
const
[
changeActive
,
setChangeActive
]
=
useState
(
1
)
const
searchDebount
=
useDebounce
(
txtSearch
,
1000
)
const
searchDebount
=
useDebounce
(
txtSearch
,
1000
)
const
[
status
,
setStatus
]
=
useState
()
const
[
pageIndex
,
setPageIndex
]
=
useState
(
0
)
const
[
pageIndex
,
setPageIndex
]
=
useState
(
0
)
const
[
pageSize
]
=
useState
(
10
)
const
[
pageSize
]
=
useState
(
10
)
const
[
totalRecords
,
setTotalRecord
]
=
useState
(
0
)
const
[
totalRecords
,
setTotalRecord
]
=
useState
(
0
)
const
[
type
,
setType
]
=
useState
()
const
[
listType
,
setListType
]
=
useState
([])
const
history
=
useHistory
()
const
history
=
useHistory
()
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
[
data
,
setData
]
=
useState
([])
const
[
data
,
setData
]
=
useState
([])
const
[
permissions
,
setPermissions
]
=
useState
([])
const
[
permissions
,
setPermissions
]
=
useState
([])
useEffect
(()
=>
{
getListType
()
},
[])
const
handeChangeActive
=
async
(
id
,
status_id
)
=>
{
const
handeChangeActive
=
async
(
id
,
status_id
)
=>
{
props
.
showLoading
()
props
.
showLoading
()
const
res
=
await
changeStatusProduct
({
id
,
status_id
})
const
res
=
await
changeStatusProduct
({
id
Guid
:
id
,
status_id
})
props
.
hideLoading
()
props
.
hideLoading
()
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
getData
()
getData
()
...
@@ -46,9 +53,11 @@ const ToolNotificate = (props) => {
...
@@ -46,9 +53,11 @@ const ToolNotificate = (props) => {
const
getData
=
async
()
=>
{
const
getData
=
async
()
=>
{
props
.
showLoading
()
props
.
showLoading
()
const
res
=
await
getListProduct
({
const
res
=
await
getListProduct
({
nam
e
:
searchDebount
,
cod
e
:
searchDebount
,
page_no
:
pageIndex
+
1
,
page_no
:
pageIndex
+
1
,
page_size
:
pageSize
,
page_size
:
pageSize
,
status
,
type_id
:
type
,
})
})
props
.
hideLoading
()
props
.
hideLoading
()
...
@@ -75,7 +84,7 @@ const ToolNotificate = (props) => {
...
@@ -75,7 +84,7 @@ const ToolNotificate = (props) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
getData
()
getData
()
},
[
txtSearch
,
pageIndex
])
},
[
searchDebount
,
pageIndex
,
status
,
type
])
const
removeItem
=
async
(
id
)
=>
{
const
removeItem
=
async
(
id
)
=>
{
props
.
showLoading
()
props
.
showLoading
()
...
@@ -98,6 +107,21 @@ const ToolNotificate = (props) => {
...
@@ -98,6 +107,21 @@ const ToolNotificate = (props) => {
}
}
}
}
const
getListType
=
async
()
=>
{
const
res
=
await
dropdownProductType
({})
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
const
newList
=
res
.
data
.
data
.
map
((
e
)
=>
{
return
{
name
:
e
.
type_name
,
value
:
e
.
id
,
...
e
}
})
setListType
(
newList
)
}
else
{
toast
.
error
(
t
(
res
.
data
.
error
),
{
theme
:
'colored'
,
})
}
}
return
(
return
(
<
ToolUserView
<
ToolUserView
data
=
{
data
}
data
=
{
data
}
...
@@ -112,6 +136,11 @@ const ToolNotificate = (props) => {
...
@@ -112,6 +136,11 @@ const ToolNotificate = (props) => {
handeChangeActive
=
{
handeChangeActive
}
handeChangeActive
=
{
handeChangeActive
}
totalRecords
=
{
totalRecords
}
totalRecords
=
{
totalRecords
}
permissions
=
{
permissions
}
permissions
=
{
permissions
}
status
=
{
status
}
setStatus
=
{
setStatus
}
listType
=
{
listType
}
type
=
{
type
}
setType
=
{
setType
}
/
>
/
>
)
)
}
}
...
...
src/app/views/product/product/Update.js
View file @
6a1f19b5
...
@@ -127,7 +127,7 @@ const SimpleForm = (props) => {
...
@@ -127,7 +127,7 @@ const SimpleForm = (props) => {
<
Grid
xs
=
{
6
}
sm
=
{
6
}
item
>
<
Grid
xs
=
{
6
}
sm
=
{
6
}
item
>
<
SelectValidator
<
SelectValidator
variant
=
{
'outlined'
}
variant
=
{
'outlined'
}
label
=
{
'Thuộc
chức năng
*'
}
label
=
{
'Thuộc
loại sản phẩm
*'
}
className
=
"mb-4 w-full"
className
=
"mb-4 w-full"
value
=
{
type_id
||
''
}
value
=
{
type_id
||
''
}
disabled
disabled
...
...
src/app/views/product/product/View.js
View file @
6a1f19b5
...
@@ -32,6 +32,11 @@ function CustomerView(props) {
...
@@ -32,6 +32,11 @@ function CustomerView(props) {
pageIndex
,
pageIndex
,
totalRecords
,
totalRecords
,
permissions
,
permissions
,
status
,
setStatus
,
listType
,
type
,
setType
,
}
=
props
}
=
props
const
{
user
}
=
useAuth
()
const
{
user
}
=
useAuth
()
const
handleChange
=
(
event
)
=>
{
const
handleChange
=
(
event
)
=>
{
...
@@ -61,19 +66,90 @@ function CustomerView(props) {
...
@@ -61,19 +66,90 @@ function CustomerView(props) {
container
container
spacing
=
{
3
}
spacing
=
{
3
}
>
>
<
Grid
item
lg
=
{
3
}
md
=
{
3
}
sm
=
{
6
}
xs
=
{
6
}
>
<
Grid
<
TextField
container
variant
=
"outlined"
spacing
=
{
3
}
className
=
"w-full"
item
label
=
"Tên sản phẩm"
lg
=
{
8
}
onChange
=
{(
e
)
=>
{
md
=
{
8
}
const
text
=
e
.
target
.
value
sm
=
{
8
}
setTimeout
(()
=>
{
xs
=
{
8
}
setTxtSearch
(
text
)
>
},
1000
)
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
4
}
xs
=
{
4
}
>
}}
<
TextField
/
>
variant
=
"outlined"
className
=
"w-full"
label
=
"Tìm kiếm"
onChange
=
{(
e
)
=>
{
const
text
=
e
.
target
.
value
setTimeout
(()
=>
{
setTxtSearch
(
text
)
},
1000
)
}}
/
>
<
/Grid
>
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
4
}
xs
=
{
4
}
>
<
FormControl
variant
=
"outlined"
fullWidth
>
<
InputLabel
htmlFor
=
"outlined-age-native-simple"
>
Lo
ạ
i
s
ả
n
ph
ẩ
m
<
/InputLabel
>
<
Select
label
=
"Loại sản phẩm"
value
=
{
type
}
onChange
=
{(
e
)
=>
setType
(
e
.
target
.
value
)}
inputProps
=
{{
name
:
'age'
,
id
:
'outlined-age-native-simple'
,
}}
>
<
MenuItem
value
=
""
>
<
em
>
T
ấ
t
c
ả
<
/em
>
<
/MenuItem
>
{
listType
.
map
((
e
)
=>
(
<
MenuItem
value
=
{
e
.
id
}
>
{
e
.
name
}
<
/MenuItem
>
))}
<
/Select
>
<
/FormControl
>
<
/Grid
>
<
Grid
item
lg
=
{
4
}
md
=
{
4
}
sm
=
{
4
}
xs
=
{
4
}
>
<
FormControl
variant
=
"outlined"
fullWidth
>
<
InputLabel
htmlFor
=
"outlined-age-native-simple"
>
Tr
ạ
ng
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
>
T
ấ
t
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
>
<
/Grid
>
{
checkRole
(
user
,
'/product/create'
)
?
(
{
checkRole
(
user
,
'/product/create'
)
?
(
<
Link
to
=
"/product/create"
>
<
Link
to
=
"/product/create"
>
<
Button
<
Button
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment