Merge branch 'staging' of itcorp.primaya.id:rajif/aso into staging

This commit is contained in:
2023-10-20 08:58:09 +07:00
6 changed files with 221 additions and 102 deletions

View File

@@ -18,6 +18,8 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Modules\Internal\Services\ExclusionService; use Modules\Internal\Services\ExclusionService;
use Modules\Internal\Transformers\DiagnosisExclusionResource; use Modules\Internal\Transformers\DiagnosisExclusionResource;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
class DiagnosisExclusionController extends Controller class DiagnosisExclusionController extends Controller
{ {
@@ -327,4 +329,19 @@ class DiagnosisExclusionController extends Controller
// return $exclusions; // return $exclusions;
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions)); return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
} }
public function updateActivation(Request $request)
{
// validation rule
$validator = Validator::make($request->all(),[
'id' => 'required|exists:exclusions',
'active' => 'required|in:0,1',
],$this->messages());
// validation error
if ($validator->fails()) {
return response()->json($validator->getMessageBag(),400);
}
}
} }

View File

@@ -107,6 +107,7 @@ Route::prefix('internal')->group(function () {
Route::get('corporates/{corporate_id}/diagnosis-exclusions', [DiagnosisExclusionController::class, 'index']); Route::get('corporates/{corporate_id}/diagnosis-exclusions', [DiagnosisExclusionController::class, 'index']);
Route::post('corporates/{corporate_id}/diagnosis-exclusions/store', [DiagnosisExclusionController::class, 'storeExclusion']); Route::post('corporates/{corporate_id}/diagnosis-exclusions/store', [DiagnosisExclusionController::class, 'storeExclusion']);
Route::put('corporates/diagnosis-exclusions/update_activation', [DiagnosisExclusionController::class, 'updateActivation']);
Route::delete('diagnosis-exclusions/{id}', [DiagnosisExclusionController::class, 'destroy']); Route::delete('diagnosis-exclusions/{id}', [DiagnosisExclusionController::class, 'destroy']);
Route::post('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']); Route::post('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']);

View File

@@ -38,13 +38,13 @@ import {
} from '@mui/material'; } from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add'; import GetApp from '@mui/icons-material/GetApp';
import UploadIcon from '@mui/icons-material/Upload'; import UploadIcon from '@mui/icons-material/Upload';
import CancelIcon from '@mui/icons-material/Cancel'; import CancelIcon from '@mui/icons-material/Cancel';
// hooks // hooks
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react'; import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
import useSettings from '../../../hooks/useSettings'; import useSettings from '../../../hooks/useSettings';
import { Link, useParams, useSearchParams } from 'react-router-dom'; import { Link, useParams, useSearchParams, useNavigate } from 'react-router-dom';
// components // components
import axios from '../../../utils/axios'; import axios from '../../../utils/axios';
import { LaravelPaginatedData } from '../../../@types/paginated-data'; import { LaravelPaginatedData } from '../../../@types/paginated-data';
@@ -54,6 +54,11 @@ import { enqueueSnackbar } from 'notistack';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import { LoadingButton } from '@mui/lab'; import { LoadingButton } from '@mui/lab';
import HistoryIcon from '@mui/icons-material/History'; import HistoryIcon from '@mui/icons-material/History';
import CachedIcon from '@mui/icons-material/Cached';
import TableMoreMenu from '@/components/table/TableMoreMenu';
import { EditOutlined, FindInPageOutlined } from '@mui/icons-material';
import Label from '@/components/Label';
import { display } from '@mui/system';
export default function List(props: any) { export default function List(props: any) {
const { themeStretch } = useSettings(); const { themeStretch } = useSettings();
@@ -82,7 +87,7 @@ export default function List(props: any) {
}, [searchParams]); }, [searchParams]);
return ( return (
<form onSubmit={handleSearchSubmit} style={{ width: '100%' }}> <form onSubmit={handleSearchSubmit} style={{ width: '90%' }}>
<TextField <TextField
id="search-input" id="search-input"
ref={searchInput} ref={searchInput}
@@ -191,17 +196,19 @@ export default function List(props: any) {
<SearchInput onSearch={applyFilter} /> <SearchInput onSearch={applyFilter} />
{/* <h1>kjasndkjandskjasndkjansdkjansd</h1> */} {/* <h1>kjasndkjandskjasndkjansdkjansd</h1> */}
<Button <Button
id="import-button" id="import-button"
variant="outlined" variant="contained"
startIcon={<AddIcon />} startIcon={<GetApp />}
sx={{ p: 1.8 }} sx={{ p: 1.8,width: '200px' }}
aria-controls={createMenu ? 'basic-menu' : undefined} aria-controls={createMenu ? 'basic-menu' : undefined}
aria-haspopup="true" aria-haspopup="true"
aria-expanded={createMenu ? 'true' : undefined} aria-expanded={createMenu ? 'true' : undefined}
onClick={handleClick} onClick={handleClick}
color='primary'
> >
Import Import
</Button> </Button>
<Menu <Menu
id="import-button" id="import-button"
anchorEl={anchorEl} anchorEl={anchorEl}
@@ -462,80 +469,171 @@ export default function List(props: any) {
console.log('exclusions', exclusions); console.log('exclusions', exclusions);
const handleActivate = (row: any) => {
axios
.put(`/corporates/diagnosis-exclusions/update_activation`, {
id: row.id,
active: row.active == 1 ? 0 : 1,
})
.then((res) => {
// setDataTableData({
// ...dataTableData,
// data: dataTableData.data.map((model) => {
// let updatedModel = model;
// if (row.id == model.id) {
// updatedModel.active = res.data.corporate.active;
// }
// return updatedModel;
// }),
// });
})
.catch((error) => {
enqueueSnackbar(
error.response.data.message ?? error.message ?? 'Failed Processing Request',
{ variant: 'error' }
);
});
};
return ( return (
<React.Fragment> <React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}> <TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
<TableCell> <TableCell align="left" onClick={() => {if(open==true) setOpen(!open)}}/>
<IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}> <TableCell align="left" onClick={() => {if(open==true) setOpen(!open)}}>
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />} {row.service_code}
</IconButton> </TableCell>
</TableCell> <TableCell align="left" onClick={() => {if(open==true) setOpen(!open)}}>
<TableCell align="left">{row.service_code}</TableCell> {row.code}
<TableCell align="left">{row.code}</TableCell> </TableCell>
<TableCell align="left">{row.name}</TableCell> <TableCell align="left" onClick={() => {if(open==true) setOpen(!open)}}>
<TableCell align="left">{Object.keys(row.rules).length ? 'With Rules' : 'All'}</TableCell> {row.name}
<TableCell align="left">{row.active ? 'Active' : 'Inactive'}</TableCell> </TableCell>
<TableCell align="left" onClick={() => {if(open==true) setOpen(!open)}}>
<TableCell align="center"> {Object.keys(row.rules).length ? 'With Rules' : 'All'}
<Stack direction={'row'} spacing={1} sx={{ mb: 1 }}> </TableCell>
{openEdit ? ( <TableCell align="left" onClick={() => {if(open==true) setOpen(!open)}}>
<Button {row.active == 1 && (
variant="contained" <Label
color="success" variant="outlined"
size="small" color="success"
sx={{ size="small"
color: '#fff', >
}} Active
onClick={(event) => { </Label>
setOpenEdit(!openEdit); )}
if (open == false) { {row.active != 1 && (
setOpen(true); <Label
} variant="outlined"
handleConfigExclusion(event, row, '', 'one_row'); color="error"
}} size="small"
> >
Save Inactive
</Button> </Label>
) : ( )}
<Button </TableCell>
variant="outlined"
color="success"
size="small"
onClick={() => {
setOpenEdit(true);
setOpen(true);
}}
>
Edit
</Button>
)}
{/* <Button
variant="outlined"
color="error"
size="small"
sx={{ ml: 2 }}
onClick={() => {
setOpenDelete(true);
}}
>
Delete
</Button> */}
{/* <Link to={`/corporate/${corporate_id}/diagnosis-exclusions/${row.id}/history`}>
<HistoryIcon />
</Link> */}
</Stack>
<TableCell align="left">
<TableMoreMenu actions={
<>
<MenuItem onClick={() => setOpen(!open)}>
<FindInPageOutlined />
Detail
</MenuItem>
<MenuItem onClick={() => navigate(`/corporates/${corporate_id}/diagnosis-exclusions/history`)} >
<EditOutlined />
Edit
</MenuItem>
<MenuItem onClick={() => handleActivate(row)}>
<CachedIcon />
Update Status
</MenuItem>
</>
} />
</TableCell> </TableCell>
</TableRow> </TableRow>
{/* COLLAPSIBLE ROW */} {/* COLLAPSIBLE ROW */}
<TableRow> <TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}> <TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}>
<Collapse in={open} timeout="auto" unmountOnExit> <Collapse in={open} timeout="auto" unmountOnExit>
{open == true ? ( {open == true ? (
<Box sx={{ padding: '24px' }}>
<Card sx={{ padding: '24px' }}>
<Grid container spacing={6}>
<Grid item xs={8}>
<Typography variant="body1" sx={{ fontWeight: 'bold'}}>
Excluded Only for :
</Typography>
</Grid>
<Grid item xs={12}>
<Grid container spacing={2}>
<Grid item xs={3}>
<Typography variant="body1" component="div" color={'GrayText'}>
MSC :
</Typography>
</Grid>
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
{row?.rules?.msc && row?.rules?.msc[0] ? (
row?.rules?.msc[0].split(',').map((text,i) => {
return (
<Typography key={i} component="div">
<Label>{text}</Label>
</Typography>
)
})
) : '-'}
</Grid>
<Grid item xs={3}>
<Typography variant="body1" component="div" color={'GrayText'}>
Gender :
</Typography>
</Grid>
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
{row?.rules?.gender && row?.rules?.gender[0] ? (
<Typography component="div">
<Label>{row?.rules?.gender[0]}</Label>
</Typography>
) : '-'}
</Grid>
<Grid item xs={3}>
<Typography variant="body1" component="div" color={'GrayText'}>
Min Age :
</Typography>
</Grid>
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
<Typography component="div">
{row?.rules?.min_age && row?.rules?.min_age[0] ? row?.rules?.min_age[0] : '-'}
</Typography>
</Grid>
<Grid item xs={3}>
<Typography variant="body1" component="div" color={'GrayText'}>
Max Age :
</Typography>
</Grid>
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
<Typography component="div">
{row?.rules?.max_age && row?.rules?.max_age[0] ? row?.rules?.max_age[0] : '-'}
</Typography>
</Grid>
<Grid item xs={3}>
<Typography variant="body1" component="div" color={'GrayText'}>
Play :
</Typography>
</Grid>
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
<Typography component="div">
{row?.rules?.plan && row?.rules?.plan[0] ? row?.rules?.plan[0] : '-'}
</Typography>
</Grid>
</Grid>
</Grid>
</Grid>
</Card>
</Box>
) : null }
{/* {open == true ? (
openEdit == false ? ( openEdit == false ? (
<Box sx={{ borderBottom: 1 }}> <Box sx={{ borderBottom: 1 }}>
{Object.keys(row.rules).length ? ( <div>
<div>
<Typography variant="body" sx={{ fontWeight: 'bold' }}> <Typography variant="body" sx={{ fontWeight: 'bold' }}>
Excluded Only for : Excluded Only for :
</Typography> </Typography>
@@ -560,12 +658,7 @@ export default function List(props: any) {
Plan : {row.rules.plan.join(', ') ?? '-'} Plan : {row.rules.plan.join(', ') ?? '-'}
</Typography> </Typography>
)} )}
</div> </div>
) : (
<Typography variant="body2" gutterBottom component="div">
Excluded for All
</Typography>
)}
</Box> </Box>
) : ( ) : (
// <CollapseEdit row={row} index={index} plans={plans} /> // <CollapseEdit row={row} index={index} plans={plans} />
@@ -752,7 +845,7 @@ export default function List(props: any) {
</Stack> </Stack>
</Box> </Box>
) )
) : null} ) : null} */}
</Collapse> </Collapse>
</TableCell> </TableCell>
</TableRow> </TableRow>
@@ -866,6 +959,8 @@ export default function List(props: any) {
loadDataTableData(); loadDataTableData();
}, []); }, []);
const navigate = useNavigate()
return ( return (
<Stack> <Stack>
<ImportForm /> <ImportForm />
@@ -874,9 +969,9 @@ export default function List(props: any) {
{/* The Main Table */} {/* The Main Table */}
<TableContainer component={Paper}> <TableContainer component={Paper}>
<Table aria-label="collapsible table"> <Table aria-label="collapsible table">
<TableBody> <TableHead>
<TableRow> <TableRow>
<TableCell style={headStyle} align="left" /> <TableCell align="left" width={50} />
<TableCell style={headStyle} align="left"> <TableCell style={headStyle} align="left">
Service Service
</TableCell> </TableCell>
@@ -893,15 +988,17 @@ export default function List(props: any) {
Status Status
</TableCell> </TableCell>
<TableCell style={headStyle} align="left"> <TableCell style={headStyle} align="left">
Action <TableMoreMenu actions={
</TableCell> <>
<TableCell style={headStyle} align="left"> <MenuItem onClick={() => navigate(`/corporates/${corporate_id}/diagnosis-exclusions/history`)}>
<Link to={`/corporate/${corporate_id}/diagnosis-exclusions/history`}> <HistoryIcon />
<HistoryIcon /> History
</Link> </MenuItem>
</>
} />
</TableCell> </TableCell>
</TableRow> </TableRow>
</TableBody> </TableHead>
{dataTableIsLoading ? ( {dataTableIsLoading ? (
<TableBody> <TableBody>
<TableRow> <TableRow>

View File

@@ -297,7 +297,11 @@ export default function Corporates() {
Import Import
</Button> */} </Button> */}
<Link to={'/corporates/create'}> <Link to={'/corporates/create'}>
<<<<<<< HEAD
<Button variant="contained" startIcon={<AddIcon sx={{}} />} sx={{ p: 1.8, typography: 'subtitle2' }}> <Button variant="contained" startIcon={<AddIcon sx={{}} />} sx={{ p: 1.8, typography: 'subtitle2' }}>
=======
<Button variant="contained" startIcon={<AddIcon sx={{}} />} sx={{ p: 1.8, typography: 'subtitle2', backgroundColor: '#19BBBB' }}>
>>>>>>> 8a3b0f3d1185955685128bc197a50193b837ddc1
New Corporate New Corporate
</Button> </Button>
</Link> </Link>