Commit 456900c2 by tdgiang

update code

parent 095772d3
......@@ -330,6 +330,8 @@
"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",
"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_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) => {
const [listModule, setListModule] = useState([])
const [listMerchant, setListMerchant] = useState([])
const [merchant, setMerchant] = useState()
const [status, setStatus] = useState()
const [module, setModule] = useState(null)
......@@ -80,7 +81,7 @@ const ToolNotificate = (props) => {
to_date: endDate ? convertDate(endDate) : null,
store_id: module,
merchant_id: merchant,
status: null,
status: status,
})
props.hideLoading()
console.log('res.data.data', res.data.data)
......@@ -105,7 +106,7 @@ const ToolNotificate = (props) => {
useEffect(() => {
getData()
}, [searchDebount, pageIndex, startDate, module, merchant])
}, [searchDebount, pageIndex, startDate, module, merchant, status])
return (
<LogAuth
......@@ -125,6 +126,8 @@ const ToolNotificate = (props) => {
listMerchant={listMerchant}
merchant={merchant}
setMerchant={setMerchant}
status={status}
setStatus={setStatus}
/>
)
}
......
......@@ -41,6 +41,8 @@ function CustomerView(props) {
listMerchant,
merchant,
setMerchant,
status,
setStatus,
} = props
const handleChange = (event) => {
......@@ -99,6 +101,41 @@ function CustomerView(props) {
<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: '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
</InputLabel>
<Select
......
......@@ -162,7 +162,7 @@ const SimpleForm = (props) => {
].concat(e.gas_olines),
}
} 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',
})
return {
......@@ -383,11 +383,10 @@ const SimpleForm = (props) => {
>
<div>
<Typography variant="subtitle1">
S lượng vòi mi tr:{' '}
{listField.length}
S lượng tr: {listField.length}
</Typography>
<Typography variant="subtitle1">
S lượng tr: {countFountain()}
S lượng vòi: {countFountain()}
</Typography>
</div>
<Button
......
......@@ -202,7 +202,7 @@ const SimpleForm = (props) => {
].concat(e.gas_olines),
}
} 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',
})
return {
......
......@@ -18,7 +18,7 @@ const ToolNotificate = (props) => {
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const [status, setStatus] = useState()
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
......@@ -50,6 +50,7 @@ const ToolNotificate = (props) => {
text_search: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
})
props.hideLoading()
......@@ -72,11 +73,11 @@ const ToolNotificate = (props) => {
useEffect(() => {
getData()
}, [searchDebount, pageIndex])
}, [searchDebount, pageIndex, status])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteMerchant({ id })
const res = await deleteMerchant({ idGuid: id })
props.hideLoading()
if (res.data.code == 200) {
getData()
......@@ -104,6 +105,8 @@ const ToolNotificate = (props) => {
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
permissions={permissions}
status={status}
setStatus={setStatus}
/>
)
}
......
......@@ -88,7 +88,7 @@ const SimpleForm = (props) => {
if (res.data.code == 200) {
history.push('/merchant')
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',
})
}
......
......@@ -31,6 +31,8 @@ function CustomerView(props) {
pageIndex,
totalRecords,
permissions,
status,
setStatus,
} = props
const [age, setAge] = React.useState('')
const { user } = useAuth()
......@@ -62,18 +64,62 @@ function CustomerView(props) {
container
spacing={3}
>
<Grid item lg={3} md={3} sm={6} xs={6}>
<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
container
spacing={3}
item
lg={8}
md={8}
sm={8}
xs={8}
>
<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>
{checkRole(user, '/merchant/create') ? (
<Link to="/merchant/create">
......
......@@ -8,6 +8,8 @@ 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 { dropdownMerchant, dropdownStore } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const [applications, setApplications] = useState('')
......@@ -20,6 +22,16 @@ const ToolNotificate = (props) => {
const [endDate, setEndDate] = useState()
const { t } = useTranslation()
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) => {
setStartDate(start)
......@@ -35,6 +47,10 @@ const ToolNotificate = (props) => {
page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null,
to_date: endDate ? convertDate(endDate) : null,
type_code: type,
merchant_id: merchant,
store_id: store,
// gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
})
props.hideLoading()
......@@ -57,7 +73,45 @@ const ToolNotificate = (props) => {
useEffect(() => {
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 (
<LogAuth
......@@ -70,6 +124,15 @@ const ToolNotificate = (props) => {
applications={applications}
startDate={startDate}
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) {
applications,
startDate,
changeDateRange,
type,
setType,
listType,
listMerchant,
setMerchant,
merchant,
store,
setStore,
listStore,
} = props
const handleChange = (event) => {
......@@ -57,37 +66,110 @@ function CustomerView(props) {
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
//justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid
container
spacing={2}
item
lg={6}
md={6}
sm={6}
xs={6}
>
<Grid item>
<TextField
variant="outlined"
className="w-full"
label="Tìm kiếm"
onChange={(e) => {
const text = e.target.value
setTxtSearch(text)
<Grid item lg={3} md={3} sm={3} xs={3}>
<TextField
variant="outlined"
className="w-full"
label="Tìm kiếm"
onChange={(e) => {
const text = e.target.value
setTxtSearch(text)
}}
/>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Phương thc thanh toán
</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>
<Grid item>
<DateRange
date={startDate}
changeDateRange={changeDateRange}
/>
</Grid>
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listMerchant.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">
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>
......
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