Commit 8ab6c443 by tdgiang

update code

parent 8e228715
......@@ -55,7 +55,7 @@ const DialogActions = withStyles((theme) => ({
}))(MuiDialogActions)
const CustomizedDialogs = (props) => {
const { onSelectCustomer, cusomterSelect } = props
const { onSelectCustomer, cusomterSelect, idPaymentPartner } = props
const [open, setOpen] = useState(false)
const handleClickOpen = () => {
......@@ -70,6 +70,7 @@ const CustomizedDialogs = (props) => {
onSelectCustomer(item)
setOpen(false)
}
console.log('idPaymentPartner dialog', idPaymentPartner)
return (
<div style={{ marginRight: 10 }}>
......@@ -102,6 +103,8 @@ const CustomizedDialogs = (props) => {
<CustomerList
customSelect={customSelect}
handleClose={handleClose}
idPaymentPartner={idPaymentPartner}
open={open}
/>
</DialogContent>
</Dialog>
......
......@@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next'
import { dropdownMerchant, dropdownStore } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => {
const { customSelect, handleClose } = props
const { customSelect, handleClose, idPaymentPartner } = props
const [listSelected, setListSelected] = useState([])
const [txtSearch, setTxtSearch] = useState('')
const [applications, setApplications] = useState('')
......@@ -26,112 +26,58 @@ const ToolNotificate = (props) => {
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)
setEndDate(end)
}
console.log('idPaymentPartner index', idPaymentPartner)
const getData = async (init) => {
props.showLoading()
let res
if (init) {
setPageIndex(0)
res = await listTransReconciliation({
page_no: 0,
page_size: pageSize,
date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null,
product_code: null,
payment_gate_code: null,
statusReconciliation: 0,
type_payment: null,
})
} else {
res = await listTransReconciliation({
page_no: pageIndex + 1,
page_size: pageSize,
if (props?.idPaymentPartner) {
console.log('props?.idPaymentPartner', props?.idPaymentPartner)
props.showLoading()
const res = await listTransReconciliation({
date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null,
product_code: null,
payment_gate_code: null,
statusReconciliation: 0,
type_payment: null,
statusReconciliation: 1,
payment_gate_code: props?.idPaymentPartner,
order_code: searchDebount,
type_payment: type || type,
})
}
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(' res.data.data', 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) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
console.log('res.data', res.data)
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log('idPaymentPartner', 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) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
}
useEffect(() => {
getData(false)
}, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount, 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',
})
console.log('props?.open', props?.open)
console.log('props?.open', props?.idPaymentPartner)
if (props?.open) {
console.log('run')
getData(true)
}
}
const getDropdownStore = async (id) => {
const res = await dropdownStore(id)
}, [searchDebount, startDate, type, props])
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',
})
}
}
const onAdd = () => {
console.log('listSelected', listSelected)
}
......@@ -150,12 +96,6 @@ const ToolNotificate = (props) => {
type={type}
setType={setType}
listType={listType}
merchant={merchant}
setMerchant={setMerchant}
listMerchant={listMerchant}
store={store}
setStore={setStore}
listStore={listStore}
customSelect={customSelect}
handleClose={handleClose}
listSelected={listSelected}
......
......@@ -69,7 +69,7 @@ function CustomerView(props) {
<TextField
variant="outlined"
className="w-full"
label="Tìm kiếm"
label="Nhập mã giao dịch"
onChange={(e) => {
const text = e.target.value
setTxtSearch(text)
......@@ -113,52 +113,7 @@ function CustomerView(props) {
</Select>
</FormControl>
</Grid>
<Grid item lg={2} md={2} 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',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listMerchant.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={2} md={2} 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={2} md={2} sm={3} xs={3}>
<DateRange
date={startDate}
......
......@@ -38,6 +38,8 @@ const ToolNotificate = (props) => {
setEndDate(end)
}
console.log('props?.idReconciliation', props?.idReconciliation)
const getData = async (init) => {
if (props?.idReconciliation) {
props.showLoading()
......@@ -158,6 +160,7 @@ const ToolNotificate = (props) => {
setStore={setStore}
listStore={listStore}
isDetail={props.isDetail}
idPaymentPartner={props?.idPaymentPartner}
/>
)
}
......
......@@ -45,6 +45,7 @@ function CustomerView(props) {
setStore,
listStore,
isDetail,
idPaymentPartner,
} = props
const handleChange = (event) => {
......@@ -93,7 +94,7 @@ function CustomerView(props) {
Chọn giao dịch
</Button> */}
<DialogTrans />
<DialogTrans idPaymentPartner={idPaymentPartner} />
</Grid>
) : null}
......
......@@ -203,7 +203,7 @@ function TableList(props) {
history.push({
pathname:
'/reconciliation/sheet/update',
state: row.id,
state: { ...row },
})
}}
className={classes.button}
......
......@@ -57,7 +57,7 @@ const SimpleForm = (props) => {
const getDataDefault = async () => {
props.showLoading()
try {
const res = await detailSheetReconciliation(location.state, {})
const res = await detailSheetReconciliation(location.state?.id, {})
if (res.data.data) {
setState({ ...res.data.data })
}
......@@ -102,6 +102,10 @@ const SimpleForm = (props) => {
}
console.log('state', state)
const { code, idPaymentPartner, note } = state
console.log(
'location.state?.idPaymentPartner',
location.state?.idPaymentPartner
)
return (
<div className="m-sm-30">
<div className="mb-sm-30">
......@@ -211,7 +215,10 @@ const SimpleForm = (props) => {
>
<ListTrans
isDetail={false}
idReconciliation={location.state}
idReconciliation={location.state?.id}
idPaymentPartner={
location.state?.idPaymentPartner
}
/>
</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