Update Hospitals Corporate Bisa Import
This commit is contained in:
@@ -98,7 +98,7 @@ import {
|
||||
// Create Button Menu
|
||||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||
const createMenu = Boolean(anchorEl);
|
||||
const importPlan = useRef<HTMLInputElement>(null);
|
||||
const importDrug = useRef<HTMLInputElement>(null);
|
||||
const [currentImportFileName, setCurrentImportFileName] = useState(null);
|
||||
const [importLoading, setImportLoading] = useState(false);
|
||||
|
||||
@@ -111,19 +111,19 @@ import {
|
||||
};
|
||||
|
||||
const handleImportButton = () => {
|
||||
if (importPlan?.current) {
|
||||
if (importDrug?.current) {
|
||||
handleClose();
|
||||
importPlan.current ? importPlan.current.click() : console.log('No File selected');
|
||||
importDrug.current ? importDrug.current.click() : console.log('No File selected');
|
||||
} else {
|
||||
alert('No file selected');
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelImportButton = () => {
|
||||
if(importPlan.current)
|
||||
if(importDrug.current)
|
||||
{
|
||||
importPlan.current.value = '';
|
||||
importPlan.current.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
importDrug.current.value = '';
|
||||
importDrug.current.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -136,11 +136,11 @@ import {
|
||||
};
|
||||
|
||||
const handleUpload = () => {
|
||||
if(importPlan.current && importPlan.current.files)
|
||||
if(importDrug.current && importDrug.current.files)
|
||||
{
|
||||
if (importPlan.current?.files.length) {
|
||||
if (importDrug.current?.files.length) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', importPlan.current?.files[0]);
|
||||
formData.append('file', importDrug.current?.files[0]);
|
||||
setImportLoading(true);
|
||||
axios
|
||||
.post(`master/drugs/import`, formData)
|
||||
@@ -181,7 +181,7 @@ import {
|
||||
<input
|
||||
type="file"
|
||||
id="file"
|
||||
ref={importPlan}
|
||||
ref={importDrug}
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleImportChange}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
|
||||
|
||||
Reference in New Issue
Block a user