diff --git a/Modules/Internal/Http/Controllers/Api/CorporatePlanController.php b/Modules/Internal/Http/Controllers/Api/CorporatePlanController.php
index a71309a1..9c79a62a 100644
--- a/Modules/Internal/Http/Controllers/Api/CorporatePlanController.php
+++ b/Modules/Internal/Http/Controllers/Api/CorporatePlanController.php
@@ -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([
diff --git a/Modules/Internal/Routes/api.php b/Modules/Internal/Routes/api.php
index ec4e1a19..3485ed3a 100644
--- a/Modules/Internal/Routes/api.php
+++ b/Modules/Internal/Routes/api.php
@@ -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']);
diff --git a/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx b/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx
index 806dff2c..4aae7269 100644
--- a/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx
+++ b/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx
@@ -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() {
{row.corporate_benefit_code}
{row.benefit?.description}
{ fNumber(row.limit_amount)}
- { row.max_frequency_period}
+ { frequency_period_name}
+ { limit_frequency}
{row.active == 1 && (
@@ -1086,6 +1095,9 @@ export default function PlanList() {
Limit Benefit
+
+ Freq. Period
+
Limit Frequency
diff --git a/frontend/dashboard/src/pages/Corporates/Plan/List.tsx b/frontend/dashboard/src/pages/Corporates/Plan/List.tsx
index c40b2b9a..010b3f9d 100644
--- a/frontend/dashboard/src/pages/Corporates/Plan/List.tsx
+++ b/frontend/dashboard/src/pages/Corporates/Plan/List.tsx
@@ -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(null);
@@ -227,16 +240,7 @@ export default function CorporatePlanList() {
{
+ 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 = {