backend filter plan
This commit is contained in:
@@ -25,6 +25,31 @@ class CorporatePlanController extends Controller
|
||||
return $benefits;
|
||||
}
|
||||
|
||||
public function filter(Request $request, $corporate_id){
|
||||
|
||||
$benefits = CorporatePlan::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id);
|
||||
// ->where('type', $request->type)
|
||||
// ->where('code', $request->code);
|
||||
|
||||
if ($request->has('service_code') && is_array($request->service_code) && count($request->service_code) > 0) {
|
||||
$benefits->whereIn('service_code', $request->service_code);
|
||||
}
|
||||
if ($request->has('type') && is_array($request->type) && count($request->type) > 0) {
|
||||
$benefits->whereIn('type', $request->type);
|
||||
}
|
||||
if ($request->has('code') && is_array($request->code) && count($request->code) > 0) {
|
||||
$benefits->whereIn('code', $request->code);
|
||||
}
|
||||
|
||||
|
||||
$benefits = $benefits->paginate(0)->appends($request->all());
|
||||
|
||||
return $benefits;
|
||||
|
||||
}
|
||||
|
||||
public function activation(Request $request, $plan_id)
|
||||
{
|
||||
$request->validate([
|
||||
|
||||
@@ -81,6 +81,7 @@ Route::prefix('internal')->group(function () {
|
||||
Route::post('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'store']);
|
||||
Route::get('corporates/{corporate_id}/corporate-plans/{id}/edit', [CorporatePlanController::class, 'edit']);
|
||||
Route::put('corporates/{corporate_id}/corporate-plans/{id}', [CorporatePlanController::class, 'update']);
|
||||
Route::post('corporates/{corporate_id}/corporate-plans/filter', [CorporatePlanController::class, 'filter']);
|
||||
Route::put('plans/{plan_id}/activation', [CorporatePlanController::class, 'activation']);
|
||||
|
||||
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
|
||||
|
||||
@@ -382,27 +382,35 @@ export default function PlanList() {
|
||||
// };
|
||||
|
||||
let frequency_period_name: string
|
||||
let limit_frequency: string
|
||||
switch (row.max_frequency_period) {
|
||||
case '1' :
|
||||
frequency_period_name = 'Daily Visit';
|
||||
limit_frequency = row.daily_frequency ? row.daily_frequency : '1';
|
||||
break;
|
||||
case '2':
|
||||
frequency_period_name = 'Weekly';
|
||||
limit_frequency = row.weekly_frequency ? row.weekly_frequency : '7';
|
||||
break;
|
||||
case '3':
|
||||
frequency_period_name = 'Monthly';
|
||||
limit_frequency = row.monthly_frequency ? row.monthly_frequency : '30';
|
||||
break;
|
||||
case '4':
|
||||
frequency_period_name = 'Yearly';
|
||||
limit_frequency = row.yearly_frequency ? row.yearly_frequency : '365';
|
||||
break;
|
||||
case '5':
|
||||
frequency_period_name = 'Disability';
|
||||
limit_frequency = row.max_days_for_disability ? row.max_days_for_disability : '-';
|
||||
break;
|
||||
case '6':
|
||||
frequency_period_name = 'Visit';
|
||||
limit_frequency = row.daily_frequency ? row.daily_frequency : '-';
|
||||
break;
|
||||
default:
|
||||
frequency_period_name = 'Policy Period';
|
||||
limit_frequency = row.daily_frequency ? row.daily_frequency : '-';
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -419,7 +427,8 @@ export default function PlanList() {
|
||||
<TableCell align="left">{row.corporate_benefit_code}</TableCell>
|
||||
<TableCell align="left">{row.benefit?.description}</TableCell>
|
||||
<TableCell align="left">{ fNumber(row.limit_amount)}</TableCell>
|
||||
<TableCell align="left">{ row.max_frequency_period}</TableCell>
|
||||
<TableCell align="left">{ frequency_period_name}</TableCell>
|
||||
<TableCell align="left">{ limit_frequency}</TableCell>
|
||||
|
||||
<TableCell align="center">
|
||||
{row.active == 1 && (
|
||||
@@ -1086,6 +1095,9 @@ export default function PlanList() {
|
||||
<TableCell style={headStyle} align="left">
|
||||
Limit Benefit
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Freq. Period
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Limit Frequency
|
||||
</TableCell>
|
||||
|
||||
@@ -81,6 +81,19 @@ export default function CorporatePlanList() {
|
||||
}
|
||||
};
|
||||
|
||||
// filter
|
||||
const defaultValue = [
|
||||
{
|
||||
value: '-',
|
||||
label: '-'
|
||||
}
|
||||
];
|
||||
|
||||
const [serviceCode, setServiceCode] = useState(defaultValue);
|
||||
const [type, setType] = useState(defaultValue);
|
||||
const [code, setCode] = useState(defaultValue);
|
||||
const [codePlan, setCodePlan] = useState(defaultValue);
|
||||
|
||||
function SearchInput(props: any) {
|
||||
// SEARCH
|
||||
const searchInput = useRef<HTMLInputElement>(null);
|
||||
@@ -227,16 +240,7 @@ export default function CorporatePlanList() {
|
||||
<Grid item xs={2}>
|
||||
<Autocomplete
|
||||
id="combo-box-demo"
|
||||
options={[
|
||||
{
|
||||
value: 'IP',
|
||||
label: 'Inpatient'
|
||||
},
|
||||
{
|
||||
value: 'OP',
|
||||
label: 'Outpatient'
|
||||
},
|
||||
]}
|
||||
options={serviceCode}
|
||||
multiple
|
||||
limitTags={1}
|
||||
fullWidth
|
||||
@@ -252,16 +256,7 @@ export default function CorporatePlanList() {
|
||||
<Grid item xs={1.5}>
|
||||
<Autocomplete
|
||||
id="combo-box-demo"
|
||||
options={[
|
||||
{
|
||||
value: 'IP',
|
||||
label: 'IP-001'
|
||||
},
|
||||
{
|
||||
value: 'OP',
|
||||
label: 'OP-001'
|
||||
},
|
||||
]}
|
||||
options={codePlan}
|
||||
multiple
|
||||
limitTags={1}
|
||||
fullWidth
|
||||
@@ -277,16 +272,7 @@ export default function CorporatePlanList() {
|
||||
<Grid item xs={1.5}>
|
||||
<Autocomplete
|
||||
id="combo-box-demo"
|
||||
options={[
|
||||
{
|
||||
value: 'IP',
|
||||
label: 'IP-001'
|
||||
},
|
||||
{
|
||||
value: 'OP',
|
||||
label: 'OP-001'
|
||||
},
|
||||
]}
|
||||
options={code}
|
||||
multiple
|
||||
limitTags={1}
|
||||
fullWidth
|
||||
@@ -302,16 +288,7 @@ export default function CorporatePlanList() {
|
||||
<Grid item xs={1.5}>
|
||||
<Autocomplete
|
||||
id="combo-box-demo"
|
||||
options={[
|
||||
{
|
||||
value: 'IP',
|
||||
label: 'IP-001'
|
||||
},
|
||||
{
|
||||
value: 'OP',
|
||||
label: 'OP-001'
|
||||
},
|
||||
]}
|
||||
options={type}
|
||||
multiple
|
||||
limitTags={1}
|
||||
fullWidth
|
||||
@@ -790,10 +767,68 @@ export default function CorporatePlanList() {
|
||||
setDataTableLoading(true);
|
||||
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||
const response = await axios.get('/corporates/' + corporate_id + '/plans', { params: filter });
|
||||
// console.log(response.data);
|
||||
|
||||
setDataTableLoading(false);
|
||||
|
||||
setDataTableData(response.data);
|
||||
|
||||
const data = response.data.data;
|
||||
const serviceCodeArray :string[] = [];
|
||||
const codeArray :string[] = [];
|
||||
const typeArray :string[] = [];
|
||||
const planArray :string[] = [];
|
||||
|
||||
data.forEach((row: any) => {
|
||||
if (!serviceCodeArray.includes(row.service_code)) {
|
||||
serviceCodeArray.push(row.service_code);
|
||||
}
|
||||
|
||||
if (!codeArray.includes(row.code)) {
|
||||
codeArray.push(row.code);
|
||||
}
|
||||
|
||||
if (!typeArray.includes(row.type)) {
|
||||
typeArray.push(row.type);
|
||||
}
|
||||
|
||||
if (!planArray.includes(row.corporate_plan_id)) {
|
||||
planArray.push(row.corporate_plan_id);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
const optionServiceCode = serviceCodeArray.map((value) => {
|
||||
return {
|
||||
value: value,
|
||||
label: value
|
||||
};
|
||||
});
|
||||
const optionCode = codeArray.map((value) => {
|
||||
return {
|
||||
value: value,
|
||||
label: value
|
||||
};
|
||||
});
|
||||
const optionType = typeArray.map((value) => {
|
||||
return {
|
||||
value: value,
|
||||
label: value
|
||||
};
|
||||
});
|
||||
const optionPlan = planArray.map((value) => {
|
||||
return {
|
||||
value: value,
|
||||
label: value
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
console.log(optionCode)
|
||||
setServiceCode(optionServiceCode)
|
||||
setType(optionType)
|
||||
setCode(optionCode)
|
||||
setCodePlan(optionPlan)
|
||||
|
||||
};
|
||||
|
||||
const headStyle = {
|
||||
|
||||
Reference in New Issue
Block a user