Commit 456900c2 by tdgiang

update code

parent 095772d3
...@@ -330,6 +330,8 @@ ...@@ -330,6 +330,8 @@
"ERROR_OCTA_TRANS_FAIL": "ERROR_OCTA_TRANS_FAIL":
"Nạp tiền không thành công, vui lòng kiểm tra lại thông tin", "Nạp tiền không thành công, vui lòng kiểm tra lại thông tin",
"EnterPhoneNumber": "Nhập số điện thoại", "EnterPhoneNumber": "Nhập số điện thoại",
"ERROR_EMAIL_EXIST":"Email đã tồn tại",
"ERROR_PHONE_EXIST":"Số điện thoại đã tồn tại",
"ERROR_STATUS_NOT_APPROVED":"Yêu cầu chưa được phê duyệt", "ERROR_STATUS_NOT_APPROVED":"Yêu cầu chưa được phê duyệt",
"ERROR_USER_NOT_ACTIVE":"Tài khoản của bạn đã bị khoá. Liên hệ với đại lý tổng để được mở khoá" "ERROR_USER_NOT_ACTIVE":"Tài khoản của bạn đã bị khoá. Liên hệ với đại lý tổng để được mở khoá"
......
...@@ -24,6 +24,7 @@ const ToolNotificate = (props) => { ...@@ -24,6 +24,7 @@ const ToolNotificate = (props) => {
const [listModule, setListModule] = useState([]) const [listModule, setListModule] = useState([])
const [listMerchant, setListMerchant] = useState([]) const [listMerchant, setListMerchant] = useState([])
const [merchant, setMerchant] = useState() const [merchant, setMerchant] = useState()
const [status, setStatus] = useState()
const [module, setModule] = useState(null) const [module, setModule] = useState(null)
...@@ -80,7 +81,7 @@ const ToolNotificate = (props) => { ...@@ -80,7 +81,7 @@ const ToolNotificate = (props) => {
to_date: endDate ? convertDate(endDate) : null, to_date: endDate ? convertDate(endDate) : null,
store_id: module, store_id: module,
merchant_id: merchant, merchant_id: merchant,
status: null, status: status,
}) })
props.hideLoading() props.hideLoading()
console.log('res.data.data', res.data.data) console.log('res.data.data', res.data.data)
...@@ -105,7 +106,7 @@ const ToolNotificate = (props) => { ...@@ -105,7 +106,7 @@ const ToolNotificate = (props) => {
useEffect(() => { useEffect(() => {
getData() getData()
}, [searchDebount, pageIndex, startDate, module, merchant]) }, [searchDebount, pageIndex, startDate, module, merchant, status])
return ( return (
<LogAuth <LogAuth
...@@ -125,6 +126,8 @@ const ToolNotificate = (props) => { ...@@ -125,6 +126,8 @@ const ToolNotificate = (props) => {
listMerchant={listMerchant} listMerchant={listMerchant}
merchant={merchant} merchant={merchant}
setMerchant={setMerchant} setMerchant={setMerchant}
status={status}
setStatus={setStatus}
/> />
) )
} }
......
...@@ -41,6 +41,8 @@ function CustomerView(props) { ...@@ -41,6 +41,8 @@ function CustomerView(props) {
listMerchant, listMerchant,
merchant, merchant,
setMerchant, setMerchant,
status,
setStatus,
} = props } = props
const handleChange = (event) => { const handleChange = (event) => {
...@@ -99,6 +101,41 @@ function CustomerView(props) { ...@@ -99,6 +101,41 @@ function CustomerView(props) {
<Grid item lg={3} md={3} sm={3} xs={3}> <Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth> <FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple"> <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: 'Chờ thanh toán',
},
{
id: 2,
name: 'Đã thanh toán',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Pháp nhân Pháp nhân
</InputLabel> </InputLabel>
<Select <Select
......
...@@ -162,7 +162,7 @@ const SimpleForm = (props) => { ...@@ -162,7 +162,7 @@ const SimpleForm = (props) => {
].concat(e.gas_olines), ].concat(e.gas_olines),
} }
} else { } else {
toast.warning('Tên vòi xăng đã tồn tại', { toast.warning(' vòi xăng đã tồn tại', {
theme: 'colored', theme: 'colored',
}) })
return { return {
...@@ -383,11 +383,10 @@ const SimpleForm = (props) => { ...@@ -383,11 +383,10 @@ const SimpleForm = (props) => {
> >
<div> <div>
<Typography variant="subtitle1"> <Typography variant="subtitle1">
S lượng vòi mi tr:{' '} S lượng tr: {listField.length}
{listField.length}
</Typography> </Typography>
<Typography variant="subtitle1"> <Typography variant="subtitle1">
S lượng tr: {countFountain()} S lượng vòi: {countFountain()}
</Typography> </Typography>
</div> </div>
<Button <Button
......
...@@ -202,7 +202,7 @@ const SimpleForm = (props) => { ...@@ -202,7 +202,7 @@ const SimpleForm = (props) => {
].concat(e.gas_olines), ].concat(e.gas_olines),
} }
} else { } else {
toast.warning('Tên vòi xăng đã tồn tại', { toast.warning(' vòi xăng đã tồn tại', {
theme: 'colored', theme: 'colored',
}) })
return { return {
......
...@@ -18,7 +18,7 @@ const ToolNotificate = (props) => { ...@@ -18,7 +18,7 @@ const ToolNotificate = (props) => {
const [activeSelected, setActiveSeleted] = useState(null) const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1) const [changeActive, setChangeActive] = useState(1)
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)
...@@ -50,6 +50,7 @@ const ToolNotificate = (props) => { ...@@ -50,6 +50,7 @@ const ToolNotificate = (props) => {
text_search: searchDebount, text_search: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
status,
}) })
props.hideLoading() props.hideLoading()
...@@ -72,11 +73,11 @@ const ToolNotificate = (props) => { ...@@ -72,11 +73,11 @@ const ToolNotificate = (props) => {
useEffect(() => { useEffect(() => {
getData() getData()
}, [searchDebount, pageIndex]) }, [searchDebount, pageIndex, status])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
const res = await deleteMerchant({ id }) const res = await deleteMerchant({ idGuid: id })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData()
...@@ -104,6 +105,8 @@ const ToolNotificate = (props) => { ...@@ -104,6 +105,8 @@ const ToolNotificate = (props) => {
handeChangeActive={handeChangeActive} handeChangeActive={handeChangeActive}
totalRecords={totalRecords} totalRecords={totalRecords}
permissions={permissions} permissions={permissions}
status={status}
setStatus={setStatus}
/> />
) )
} }
......
...@@ -88,7 +88,7 @@ const SimpleForm = (props) => { ...@@ -88,7 +88,7 @@ const SimpleForm = (props) => {
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/merchant') history.push('/merchant')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Tạo pháp nhân thành công!', { toast.success('Cập nhật pháp nhân thành công!', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -31,6 +31,8 @@ function CustomerView(props) { ...@@ -31,6 +31,8 @@ function CustomerView(props) {
pageIndex, pageIndex,
totalRecords, totalRecords,
permissions, permissions,
status,
setStatus,
} = props } = props
const [age, setAge] = React.useState('') const [age, setAge] = React.useState('')
const { user } = useAuth() const { user } = useAuth()
...@@ -62,18 +64,62 @@ function CustomerView(props) { ...@@ -62,18 +64,62 @@ 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 pháp nhân" lg={8}
onChange={(e) => { md={8}
const text = e.target.value sm={8}
setTimeout(() => { xs={8}
setTxtSearch(text) >
}, 1000) <Grid item lg={5} md={5} sm={5} xs={5}>
}} <TextField
/> variant="outlined"
className="w-full"
label="Tên pháp nhân"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
<Grid item lg={5} md={5} sm={5} xs={5}>
<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> </Grid>
{checkRole(user, '/merchant/create') ? ( {checkRole(user, '/merchant/create') ? (
<Link to="/merchant/create"> <Link to="/merchant/create">
......
...@@ -8,6 +8,8 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' ...@@ -8,6 +8,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 { dropdownMerchant, dropdownStore } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const [applications, setApplications] = useState('') const [applications, setApplications] = useState('')
...@@ -20,6 +22,16 @@ const ToolNotificate = (props) => { ...@@ -20,6 +22,16 @@ const ToolNotificate = (props) => {
const [endDate, setEndDate] = useState() const [endDate, setEndDate] = useState()
const { t } = useTranslation() const { t } = useTranslation()
const [data, setData] = useState([]) const [data, setData] = useState([])
const [type, setType] = useState()
const [listType, setListType] = useState([])
const [merchant, setMerchant] = useState()
const [listMerchant, setListMerchant] = useState([])
const [store, setStore] = useState()
const [listStore, setListStore] = useState([])
useEffect(() => {
getDataMerchant()
}, [])
const changeDateRange = (start, end) => { const changeDateRange = (start, end) => {
setStartDate(start) setStartDate(start)
...@@ -35,6 +47,10 @@ const ToolNotificate = (props) => { ...@@ -35,6 +47,10 @@ 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,
type_code: type,
merchant_id: merchant,
store_id: store,
// gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9', // gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
}) })
props.hideLoading() props.hideLoading()
...@@ -57,7 +73,45 @@ const ToolNotificate = (props) => { ...@@ -57,7 +73,45 @@ const ToolNotificate = (props) => {
useEffect(() => { useEffect(() => {
getData() getData()
}, [searchDebount, pageIndex, startDate]) }, [searchDebount, pageIndex, startDate, type, merchant, store])
useEffect(() => {
if (merchant) {
getDropdownStore(merchant)
}
setStore()
}, [merchant])
const getDataMerchant = async () => {
const res = await dropdownMerchant({})
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { ...e, name: e.merchant_name }
})
setListMerchant(newList)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const getDropdownStore = async (id) => {
const res = await dropdownStore(id)
if (res.data.code == 200 && res.data.data) {
console.log('res.data.data', res.data.data)
const newList = res.data.data.map((e) => {
return { ...e, name: e.store_name }
})
setListStore(newList)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
return ( return (
<LogAuth <LogAuth
...@@ -70,6 +124,15 @@ const ToolNotificate = (props) => { ...@@ -70,6 +124,15 @@ const ToolNotificate = (props) => {
applications={applications} applications={applications}
startDate={startDate} startDate={startDate}
changeDateRange={changeDateRange} changeDateRange={changeDateRange}
type={type}
setType={setType}
listType={listType}
merchant={merchant}
setMerchant={setMerchant}
listMerchant={listMerchant}
store={store}
setStore={setStore}
listStore={listStore}
/> />
) )
} }
......
...@@ -33,6 +33,15 @@ function CustomerView(props) { ...@@ -33,6 +33,15 @@ function CustomerView(props) {
applications, applications,
startDate, startDate,
changeDateRange, changeDateRange,
type,
setType,
listType,
listMerchant,
setMerchant,
merchant,
store,
setStore,
listStore,
} = props } = props
const handleChange = (event) => { const handleChange = (event) => {
...@@ -57,37 +66,110 @@ function CustomerView(props) { ...@@ -57,37 +66,110 @@ function CustomerView(props) {
padding: 10, padding: 10,
marginBottom: 20, marginBottom: 20,
}} }}
justify={'space-between'} //justify={'space-between'}
alignItems={'center'} alignItems={'center'}
container container
spacing={3} spacing={3}
> >
<Grid <Grid item lg={3} md={3} sm={3} xs={3}>
container <TextField
spacing={2} variant="outlined"
item className="w-full"
lg={6} label="Tìm kiếm"
md={6} onChange={(e) => {
sm={6} const text = e.target.value
xs={6} setTxtSearch(text)
> }}
<Grid item> />
<TextField </Grid>
variant="outlined"
className="w-full" <Grid item lg={3} md={3} sm={3} xs={3}>
label="Tìm kiếm" <FormControl variant="outlined" fullWidth>
onChange={(e) => { <InputLabel htmlFor="outlined-age-native-simple">
const text = e.target.value Phương thc thanh toán
setTxtSearch(text) </InputLabel>
<Select
label="Phương thức thanh toán"
value={type}
onChange={(e) => setType(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{[
{
id: 'QR',
name: 'QR',
},
{
id: 'CASH',
name: 'Tiền mặt',
},
{
id: 'DEBT',
name: 'Công nợ',
},
].map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Pháp nhân
</InputLabel>
<Select
label="Pháp nhân"
value={merchant}
onChange={(e) => setMerchant(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}} }}
/> >
</Grid> <MenuItem value="">
<Grid item> <em>Tt c</em>
<DateRange </MenuItem>
date={startDate} {listMerchant.map((e) => (
changeDateRange={changeDateRange} <MenuItem value={e.id}>{e.name}</MenuItem>
/> ))}
</Grid> </Select>
</FormControl>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Cây xăng
</InputLabel>
<Select
label="Cây xăng"
value={store}
onChange={(e) => setStore(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listStore.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<DateRange
date={startDate}
changeDateRange={changeDateRange}
/>
</Grid> </Grid>
</Grid> </Grid>
......
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