Change Plan, Benefit Import to Plan-Benefit Import
This commit is contained in:
@@ -17,6 +17,7 @@ export default function PlanList() {
|
|||||||
const { themeStretch } = useSettings();
|
const { themeStretch } = useSettings();
|
||||||
const { corporate_id } = useParams();
|
const { corporate_id } = useParams();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const [importResult, setImportResult] = useState(null);
|
||||||
|
|
||||||
function SearchInput(props: any) {
|
function SearchInput(props: any) {
|
||||||
// SEARCH
|
// SEARCH
|
||||||
@@ -87,11 +88,12 @@ export default function PlanList() {
|
|||||||
if (importPlan.current?.files.length) {
|
if (importPlan.current?.files.length) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", importPlan.current?.files[0])
|
formData.append("file", importPlan.current?.files[0])
|
||||||
axios.post(`corporates/${corporate_id}/benefits/import`, formData )
|
axios.post(`corporates/${corporate_id}/import-plan-benefit`, formData )
|
||||||
.then(response => {
|
.then(response => {
|
||||||
handleCancelImportButton();
|
handleCancelImportButton();
|
||||||
loadDataTableData();
|
loadDataTableData();
|
||||||
alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
|
setImportResult(response.data)
|
||||||
|
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
|
||||||
})
|
})
|
||||||
.catch(response => {
|
.catch(response => {
|
||||||
alert('Looks like something went wrong. Please check your data and try again. ' + response.message)
|
alert('Looks like something went wrong. Please check your data and try again. ' + response.message)
|
||||||
@@ -149,6 +151,11 @@ export default function PlanList() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
{( importResult &&
|
||||||
|
<Stack direction={'row'} sx={{ px: 2, pb: 2 }}>
|
||||||
|
<Box sx={{ color: "text.secondary" }}>Last Import Result Report : <a href={importResult.result_file?.url ?? "#"}>{importResult.result_file?.name ?? "-"}</a></Box>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export default function CorporatePlanList() {
|
|||||||
const { themeStretch } = useSettings();
|
const { themeStretch } = useSettings();
|
||||||
const { corporate_id } = useParams();
|
const { corporate_id } = useParams();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const [importResult, setImportResult] = useState(null);
|
||||||
|
|
||||||
function SearchInput(props: any) {
|
function SearchInput(props: any) {
|
||||||
// SEARCH
|
// SEARCH
|
||||||
@@ -88,11 +89,12 @@ export default function CorporatePlanList() {
|
|||||||
if (importPlan.current?.files.length) {
|
if (importPlan.current?.files.length) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", importPlan.current?.files[0])
|
formData.append("file", importPlan.current?.files[0])
|
||||||
axios.post(`corporates/${corporate_id}/plans/import`, formData )
|
axios.post(`corporates/${corporate_id}/import-plan-benefit`, formData )
|
||||||
.then(response => {
|
.then(response => {
|
||||||
handleCancelImportButton();
|
handleCancelImportButton();
|
||||||
loadDataTableData();
|
loadDataTableData();
|
||||||
alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
|
setImportResult(response.data)
|
||||||
|
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
|
||||||
})
|
})
|
||||||
.catch(response => {
|
.catch(response => {
|
||||||
alert('Looks like something went wrong. Please check your data and try again. ' + response.message)
|
alert('Looks like something went wrong. Please check your data and try again. ' + response.message)
|
||||||
@@ -150,6 +152,11 @@ export default function CorporatePlanList() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
{( importResult &&
|
||||||
|
<Stack direction={'row'} sx={{ px: 2, pb: 2 }}>
|
||||||
|
<Box sx={{ color: "text.secondary" }}>Last Import Result Report : <a href={importResult.result_file?.url ?? "#"}>{importResult.result_file?.name ?? "-"}</a></Box>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -179,7 +186,7 @@ export default function CorporatePlanList() {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="left">{row.service_code}</TableCell>
|
<TableCell align="left">{row.service_code}</TableCell>
|
||||||
<TableCell align="left">{row.corporate_plan?.code}</TableCell>
|
<TableCell align="left">{row.corporate_plan_id}</TableCell>
|
||||||
<TableCell align="left">{row.code}</TableCell>
|
<TableCell align="left">{row.code}</TableCell>
|
||||||
<TableCell align="left">{row.type}</TableCell>
|
<TableCell align="left">{row.type}</TableCell>
|
||||||
<TableCell align="left">{row.start}</TableCell>
|
<TableCell align="left">{row.start}</TableCell>
|
||||||
|
|||||||
Reference in New Issue
Block a user