table member dan table benefit

This commit is contained in:
pajri
2022-12-20 17:48:28 +07:00
parent da14589328
commit 88ad144921
17 changed files with 1365 additions and 499 deletions

View File

@@ -20,12 +20,12 @@ class BenefitController extends Controller
public function index(Request $request, $corporate_id) public function index(Request $request, $corporate_id)
{ {
$benefits = CorporateBenefit::query() $benefits = CorporateBenefit::query()
->filter($request->all()) ->filter($request->all())
->where('corporate_id', $corporate_id) ->where('corporate_id', $corporate_id)
->with('benefit') ->with('benefit', 'plan')
->paginate() ->paginate()
->appends($request->all()); ->appends($request->all());
return $benefits; return $benefits;
} }
@@ -133,7 +133,7 @@ class BenefitController extends Controller
// } // }
// } // }
// } // }
// break; //only read first sheet // break; //only read first sheet
// } // }
// $reader->close(); // $reader->close();

View File

@@ -18,14 +18,30 @@ class CorporateBenefitController extends Controller
public function index(Request $request, $corporate_id) public function index(Request $request, $corporate_id)
{ {
$benefits = CorporateBenefit::query() $benefits = CorporateBenefit::query()
->filter($request->all()) ->filter($request->all())
->where('corporate_id', $corporate_id) ->where('corporate_id', $corporate_id)
->paginate(0) ->paginate(0)
->appends($request->all()); ->appends($request->all());
return $benefits; return $benefits;
} }
public function activation(Request $request, $benefit_id)
{
$request->validate([
'active' => 'required'
]);
// abort(404);
$benefit = CorporateBenefit::findOrFail($benefit_id);
$benefit->active = $request->active == '1';
if ($benefit->save()) {
return response()->json([
'benefit' => $benefit,
'message' => 'Status Updated Successfully'
]);
}
}
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @return Renderable * @return Renderable

View File

@@ -51,6 +51,25 @@ class CorporateMemberController extends Controller
return Helper::paginateResources(MemberDataTableResource::collection($members)); return Helper::paginateResources(MemberDataTableResource::collection($members));
} }
public function activation(Request $request, $member_id)
{
$request->validate([
'active' => 'required'
]);
// abort(404);
$member = Member::findOrFail($member_id);
$member->active = $request->active == '1';
if ($member->save()) {
return response()->json([
'member' => $member,
'message' => 'Status Updated Successfully'
]);
}
}
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @return Renderable * @return Renderable

View File

@@ -28,16 +28,16 @@ class PlanController extends Controller
public function index(Request $request, $corporate_id) public function index(Request $request, $corporate_id)
{ {
$plans = Plan::query() $plans = Plan::query()
->filter($request->all()) ->filter($request->all())
->where('corporate_id', $corporate_id) ->where('corporate_id', $corporate_id)
// ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) { // ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) {
// $corporatePlan->where('corporate_id', $corporate_id); // $corporatePlan->where('corporate_id', $corporate_id);
// }) // })
// ->with('corporatePlan') // ->with('corporatePlan')
->orderBy('corporate_plan_id', 'ASC') ->orderBy('corporate_plan_id', 'ASC')
->paginate() ->paginate()
->appends($request->all()); ->appends($request->all());
return $plans; return $plans;
} }
@@ -105,14 +105,14 @@ class PlanController extends Controller
{ {
$request->validate([ $request->validate([
'file' => 'required|file|mimes:xls,xlsx,csv,txt', 'file' => 'required|file|mimes:xls,xlsx,csv,txt',
]); ]);
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName(); $file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
$file = $request->file('file')->storeAs('temp', $file_name); $file = $request->file('file')->storeAs('temp', $file_name);
$corporate = Corporate::findOrFail($corporate_id); $corporate = Corporate::findOrFail($corporate_id);
$import = $this->importService; $import = $this->importService;
$import->read(Storage::path('temp/'.$file_name)); $import->read(Storage::path('temp/' . $file_name));
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls'); $import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map; $headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
@@ -142,7 +142,7 @@ class PlanController extends Controller
// Create Directly // Create Directly
try { try {
$rowResponse = $this->corporateService->handlePlanRow($corporate, $plan_row); $rowResponse = $this->corporateService->handlePlanRow($corporate, $plan_row);
// Write Success Result to File // Write Success Result to File
array_push($plan_row, 'SUCCESS'); array_push($plan_row, 'SUCCESS');
$import->addArrayToRow($plan_row); $import->addArrayToRow($plan_row);
@@ -160,11 +160,11 @@ class PlanController extends Controller
} }
} }
} }
break; //only read first sheet break; //only read first sheet
} }
$import->reader->close(); $import->reader->close();
Storage::delete('temp/'.$file_name); Storage::delete('temp/' . $file_name);
$import->writer->close(); $import->writer->close();
// throw(404); // throw(404);
@@ -173,8 +173,8 @@ class PlanController extends Controller
'total_failed_row' => count($failed_plan_data), 'total_failed_row' => count($failed_plan_data),
'failed_row' => $failed_plan_data, 'failed_row' => $failed_plan_data,
'result_file' => [ 'result_file' => [
'url' => Storage::disk('public')->url('temp/result-'.$file_name), 'url' => Storage::disk('public')->url('temp/result-' . $file_name),
'name' => 'result-'.$file_name, 'name' => 'result-' . $file_name,
] ]
]; ];
} }

View File

@@ -65,6 +65,7 @@ Route::prefix('internal')->group(function () {
Route::post('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'store']); Route::post('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'store']);
Route::get('corporates/{corporate_id}/corporate-benefits/{id}/edit', [CorporateBenefitController::class, 'edit']); Route::get('corporates/{corporate_id}/corporate-benefits/{id}/edit', [CorporateBenefitController::class, 'edit']);
Route::put('corporates/{corporate_id}/corporate-benefits/{id}', [CorporateBenefitController::class, 'update']); Route::put('corporates/{corporate_id}/corporate-benefits/{id}', [CorporateBenefitController::class, 'update']);
Route::put('benefits/{benefit_id}/activation', [CorporateBenefitController::class, 'activation']);
Route::get('corporates/{corporate_id}/benefits', [BenefitController::class, 'index']); Route::get('corporates/{corporate_id}/benefits', [BenefitController::class, 'index']);
Route::post('corporates/{corporate_id}/benefits/import', [BenefitController::class, 'memberBenefitImport']); Route::post('corporates/{corporate_id}/benefits/import', [BenefitController::class, 'memberBenefitImport']);
@@ -76,6 +77,8 @@ Route::prefix('internal')->group(function () {
Route::get('corporates/{corporate_id}/members', [CorporateMemberController::class, 'index']); Route::get('corporates/{corporate_id}/members', [CorporateMemberController::class, 'index']);
Route::post('corporates/{corporate_id}/members/import', [CorporateMemberController::class, 'import']); Route::post('corporates/{corporate_id}/members/import', [CorporateMemberController::class, 'import']);
Route::put('members/{member_id}/activation', [CorporateMemberController::class, 'activation']);
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/import', [DiagnosisExclusionController::class, 'import']); Route::post('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']);

View File

@@ -10,6 +10,7 @@ use App\Models\CorporateDivision;
use App\Models\CorporatePlan; use App\Models\CorporatePlan;
use App\Models\Member; use App\Models\Member;
use App\Models\MemberPolicy; use App\Models\MemberPolicy;
use App\Models\Person;
use App\Models\Plan; use App\Models\Plan;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory; use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
use Box\Spout\Common\Entity\Row; use Box\Spout\Common\Entity\Row;
@@ -408,12 +409,35 @@ class MemberEnrollmentService
// Validate If Exist Member // Validate If Exist Member
if ($member) { if ($member) {
$person = Person::updateOrCreate(
[
'id' => $member->person_id
],
[
'name' => $row['name'] ?? null,
'birth_date' => Carbon::parse(strtotime($row['date_of_birth'])),
'gender' => Helper::genderPerson($row['sex']),
'language' => $row['language'] ?? null,
'race' => $row['race'] ?? null,
]
);
$member->person_id = $person->id;
$member->save();
throw new ImportRowException(__('enrollment.MEMBER_UNIQUE', [ throw new ImportRowException(__('enrollment.MEMBER_UNIQUE', [
'member_id' => $row['member_id'], 'member_id' => $row['member_id'],
'policy_id' => $row['policy_number'] 'policy_id' => $row['policy_number']
]), 0, null, $row); ]), 0, null, $row);
} else { } else {
$member = new Member(); $member = new Member();
$person = Person::create([
'name' => $row['name'],
'birth_date' => Carbon::parse(strtotime($row['date_of_birth'])),
'gender' => Helper::genderPerson($row['sex']),
'language' => $row['language'] ?? null,
'race' => $row['race'] ?? null,
]);
$member->person_id = $person->id;
$member->save();
} }
$memberPolicy = $member->policies() $memberPolicy = $member->policies()

View File

@@ -24,6 +24,21 @@ class Helper
} }
} }
public static function genderPerson($anyGenderCode)
{
if ($anyGenderCode == 'M') {
return 'L';
} else if ($anyGenderCode == 'F') {
return 'P';
} else if ($anyGenderCode == 'O') {
return 'others';
} else if ($anyGenderCode == 'U') {
return 'unknown';
} else {
return null;
}
}
public static function paginateResources($resource) public static function paginateResources($resource)
{ {
return [ return [

View File

@@ -146,7 +146,7 @@ class CorporateBenefit extends Model
'max_frequency' 'max_frequency'
]; ];
public function setAreaLimitAttribute($value) public function setAreaLimitAttribute($value)
{ {
$this->attributes['area_limit'] = empty($value) ? null : $value; $this->attributes['area_limit'] = empty($value) ? null : $value;
@@ -170,31 +170,31 @@ class CorporateBenefit extends Model
public function getMaxFrequencyAttribute() public function getMaxFrequencyAttribute()
{ {
switch ($this->max_frequency_period) { switch ($this->max_frequency_period) {
// case(0) : // case(0) :
// // TODO Fix This // // TODO Fix This
// return null; // return null;
// break; // break;
case(1) : case (1):
return empty($this->daily_frequency) ? 1 : $this->daily_frequency; return empty($this->daily_frequency) ? 1 : $this->daily_frequency;
break; break;
case(2) : case (2):
return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency; return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency;
break; break;
case(3) : case (3):
return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency; return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency;
break; break;
case(4) : case (4):
return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency; return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency;
break; break;
case(5) : case (5):
// TODO Fix This // TODO Fix This
return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability; return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability;
break; break;
case(6) : case (6):
// TODO Fix This // TODO Fix This
return 1; return 1;
break; break;
default : default:
return null; return null;
break; break;
} }
@@ -214,13 +214,19 @@ class CorporateBenefit extends Model
{ {
return $this->belongsTo(Plan::class); return $this->belongsTo(Plan::class);
} }
public function scopeFilter($query, array $filters) public function scopeFilter($query, array $filters)
{ {
$query->when($filters['search'] ?? false, function ($query, $search) { $query->when($filters['search'] ?? false, function ($query, $search) {
return $query return $query
->where('code', 'like', "%" . $search . "%") ->whereHas('benefit', function ($query) use ($search) {
->orWhere('name', 'like', "%" . $search . "%"); $query->where('code', 'like', "%" . $search . "%")
->orWhere('service_code', 'like', "%" . $search . "%");
})->orWhereHas('plan', function ($query) use ($search) {
$query->where('code', 'like', "%" . $search . "%");
});
// ->where('code', 'like', "%" . $search . "%")
// ->orWhere('name', 'like', "%" . $search . "%");
}); });
} }
} }

View File

@@ -14,6 +14,7 @@ class Member extends Model
protected $fillable = [ protected $fillable = [
"id", "id",
"person_id",
"member_id", "member_id",
"record_type", "record_type",
"payor_id", "payor_id",
@@ -73,11 +74,18 @@ class Member extends Model
'deleted_by', 'deleted_by',
]; ];
public function claims() public function claims()
{ {
return $this->hasMany(Claim::class, 'member_id', 'id'); return $this->hasMany(Claim::class, 'member_id', 'id');
} }
public function person()
{
return $this->belongsTo(Person::class, 'person_id', 'id');
}
public function employeds() public function employeds()
{ {
return $this->hasMany(CorporateEmployee::class, 'member_id'); return $this->hasMany(CorporateEmployee::class, 'member_id');
@@ -110,13 +118,13 @@ class Member extends Model
// // ]) // // ])
// ->where('start', '<', now()) // ->where('start', '<', now())
// ->where('end', '>', now()); // ->where('end', '>', now());
return $this->hasOneThrough(Corporate::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'corporate_id'); return $this->hasOneThrough(Corporate::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'corporate_id');
// ->where('corporate_policies.start', '<', now()) // ->where('corporate_policies.start', '<', now())
// ->where('corporate_policies.end', '>', now()) // ->where('corporate_policies.end', '>', now())
// ->where('member_policies.start', '<', now()) // ->where('member_policies.start', '<', now())
// ->where('member_policies.end', '>', now()); // ->where('member_policies.end', '>', now());
} }
public function memberPlans() public function memberPlans()
@@ -160,13 +168,16 @@ class Member extends Model
public function getFullNameAttribute() public function getFullNameAttribute()
{ {
$arr = []; if (!$this->person) {
if (!empty($this->name_prefix)) { return null;
$arr[] = $this->name_prefix;
} }
$arr[] = $this->name; $arr = [];
if (!empty($this->name_suffix)) { if (!empty($this->person->name_prefix)) {
$arr[] = $this->name_suffix; $arr[] = $this->person->name_prefix;
}
$arr[] = $this->person->name;
if (!empty($this->person->name_suffix)) {
$arr[] = $this->person->name_suffix;
} }
return implode(' ', $arr); return implode(' ', $arr);
@@ -177,13 +188,35 @@ class Member extends Model
return $this->gender ? ($this->gender == 'female' ? 'F' : 'M') : $this->gender; return $this->gender ? ($this->gender == 'female' ? 'F' : 'M') : $this->gender;
} }
public function getNameAttribute()
{
return $this->person->name ?? null;
}
public function getBirthDateAttribute()
{
return Carbon::parse($this->person->birth_date ?? null)->format('Y-m-d') ?? null;
}
public function getGenderAttribute()
{
return $this->person->gender ?? null;
}
public function scopeFilter($query, array $filters) public function scopeFilter($query, array $filters)
{ {
$query->when($filters['search'] ?? false, function ($query, $search) { $query->when($filters['search'] ?? false, function ($query, $search) {
return $query return $query
->where('member_id', 'like', "%" . $search . "%") ->where('member_id', 'like', "%" . $search . "%")
->orWhere('payor_id', 'like', "%" . $search . "%") ->orWhere('payor_id', 'like', "%" . $search . "%")
->orWhere('name', 'like', "%" . $search . "%"); ->orWhere('email', 'like', "%" . $search . "%")
->orWhereHas('person', function ($query) use ($search) {
$query->where('name', 'like', "%" . $search . "%");
$query->orWhere('phone', 'like', "%" . $search . "%");
})
->orWhereHas('currentPlan', function ($query) use ($search) {
$query->where('code', 'like', "%" . $search . "%");
});
// ->orWhereHas('corporatePlan', function ($query) use ($search) { // ->orWhereHas('corporatePlan', function ($query) use ($search) {
// $query->where('code', 'like', "%" . $search . "%"); // $query->where('code', 'like', "%" . $search . "%");
// }); // });

View File

@@ -107,4 +107,27 @@ class Person extends Model
{ {
return $this->morphMany(AppointmentParticipant::class, 'participantable'); return $this->morphMany(AppointmentParticipant::class, 'participantable');
} }
public function setGenderAttribute($value)
{
if ($value == "M" || $value == "L") {
return $this->attributes['gender'] = "male";
} else if ($value == "F" || $value == "P") {
return $this->attributes['gender'] = "female";
} else {
return $this->attributes['gender'] = $value;
}
}
public function getGenderAttribute()
{
if ($this->attributes['gender'] == "male" || $this->attributes['gender'] == "L") {
return "male";
} else if ($this->attributes['gender'] == "female" || $this->attributes['gender'] == "P") {
return "female";
} else {
return "other";
}
}
} }

View File

@@ -11,6 +11,8 @@ class Plan extends Model
{ {
use HasFactory, SoftDeletes, Blameable; use HasFactory, SoftDeletes, Blameable;
protected $table = "plans";
protected $fillable = [ protected $fillable = [
"service_code", "service_code",
"corporate_id", "corporate_id",
@@ -138,7 +140,7 @@ class Plan extends Model
{ {
$this->attributes['max_surgery_reinstatement_days'] = empty($value) ? null : $value; $this->attributes['max_surgery_reinstatement_days'] = empty($value) ? null : $value;
} }
public function setMaxSurgeryPeriodeDaysAttribute($value) public function setMaxSurgeryPeriodeDaysAttribute($value)
{ {
$this->attributes['max_surgery_periode_days'] = empty($value) ? null : $value; $this->attributes['max_surgery_periode_days'] = empty($value) ? null : $value;
@@ -148,11 +150,11 @@ class Plan extends Model
{ {
$query->when($filters['search'] ?? false, function ($query, $search) { $query->when($filters['search'] ?? false, function ($query, $search) {
return $query return $query
->where('service_code', 'like', "%" . $search . "%") ->where('service_code', 'like', "%" . $search . "%")
->orWhere('code', 'like', "%" . $search . "%") ->orWhere('code', 'like', "%" . $search . "%")
->orWhereHas('corporatePlan', function ($query) use ($search) { ->orWhereHas('corporatePlan', function ($query) use ($search) {
$query->where('code', 'like', "%" . $search . "%"); $query->where('code', 'like', "%" . $search . "%");
}); });
}); });
} }
@@ -169,12 +171,12 @@ class Plan extends Model
public function benefits() public function benefits()
{ {
return $this->belongsToMany(Benefit::class, 'corporate_benefits', 'benefit_id', 'id') return $this->belongsToMany(Benefit::class, 'corporate_benefits', 'benefit_id', 'id')
->withTimestamps() ->withTimestamps()
->withPivot([ ->withPivot([
// TODO corporate_benefits pivot // TODO corporate_benefits pivot
]); ]);
} }
public function corporateBeneftis() public function corporateBeneftis()
{ {
return $this->hasMany(CorporateBenefit::class, 'benefit_id', 'id'); return $this->hasMany(CorporateBenefit::class, 'benefit_id', 'id');

View File

@@ -14,7 +14,7 @@ return new class extends Migration
public function up() public function up()
{ {
Schema::table('plans', function (Blueprint $table) { Schema::table('plans', function (Blueprint $table) {
$table->boolean('active')->after('max_surgery_periode_days'); $table->boolean('active')->after('max_surgery_periode_days')->default(true);
}); });
} }

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('members', function (Blueprint $table) {
$table->unsignedBigInteger('person_id')->after('id')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('members', function (Blueprint $table) {
$table->dropColumn('person_id');
});
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('persons', function (Blueprint $table) {
$table->string('language')->after('birth_place')->nullable();
$table->string('race')->after('language')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('persons', function (Blueprint $table) {
$table->dropColumn('language');
$table->dropColumn('race');
});
}
};

View File

@@ -0,0 +1,125 @@
import * as Yup from 'yup';
import { LoadingButton } from '@mui/lab';
import { Box, Card, Grid, Stack, Typography } from '@mui/material';
import { CorporatePlan } from '../../../@types/corporates';
import { FormProvider, RHFSwitch, RHFTextField } from '../../../components/hook-form';
import { useEffect, useMemo } from 'react';
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import { useSnackbar } from 'notistack';
import { useNavigate, useParams } from 'react-router-dom';
import axios from '../../../utils/axios';
type Props = {
isEdit: boolean;
currentCorporatePlan?: CorporatePlan;
};
export default function CorporatePlanForm({ isEdit, currentCorporatePlan }: Props) {
const { enqueueSnackbar } = useSnackbar();
const navigate = useNavigate();
const { corporate_id } = useParams();
const NewCorporatePlanSchema = Yup.object().shape({
name: Yup.string().required('Name is required'),
code: Yup.string().required('Corporate Code is required'),
});
const defaultValues = useMemo(
() => ({
name: currentCorporatePlan?.name || '',
code: currentCorporatePlan?.code || '',
active: currentCorporatePlan?.active === 1 ? true : false,
}),
[currentCorporatePlan]
);
useEffect(() => {
if (isEdit && currentCorporatePlan) {
reset(defaultValues);
}
if (!isEdit) {
reset(defaultValues);
}
}, [isEdit, currentCorporatePlan]);
const methods = useForm({
resolver: yupResolver(NewCorporatePlanSchema),
defaultValues,
});
const {
reset,
watch,
control,
setValue,
getValues,
setError,
handleSubmit,
formState: { isSubmitting },
} = methods;
const onSubmit = async (data: any) => {
if (!isEdit) {
await axios
.post('/corporates/' + corporate_id + '/divisions', data)
.then((res) => {
enqueueSnackbar('Division created successfully', { variant: 'success' });
})
.then((res) => {
navigate('/corporates/' + corporate_id + '/divisions', { replace: true });
})
.catch(({ response }) => {
if (response.status === 422) {
for (const [key, value] of Object.entries(response.data.errors)) {
setError(key, { message: value[0] });
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
}
} else {
enqueueSnackbar('Create Failed : ' + response.data.message, { variant: 'error' });
}
});
} else {
await axios
.put('/corporates/' + corporate_id + '/divisions/' + currentCorporatePlan?.id, data)
.then((res) => {
enqueueSnackbar('Division updated successfully', { variant: 'success' });
})
.then((res) => {
navigate('/corporates/' + corporate_id + '/divisions/', { replace: true });
})
.catch(({ response }) => {
enqueueSnackbar('Update Failed : ' + response.data.message, { variant: 'error' });
});
}
};
return (
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Box sx={{ margin: 1, pb: 2, pl: 4 }}>
<Grid container>
<Grid item xs={6} sx={{ padding: 2 }}>
<Grid container>
<Stack direction="row" alignItems="center" sx={{ width: '100%' }}>
<Typography variant="subtitle2" sx={{ mr: 2 }}>
ASO/Budget
</Typography>
<RHFTextField name="budget" />
</Stack>
</Grid>
</Grid>
<Grid item xs={6} sx={{ padding: 2 }}>
<Grid container>
<Stack direction="row" alignItems="center" sx={{ width: '100%' }}>
<Typography variant="subtitle2" sx={{ mr: 2 }}>
ASO/Budget
</Typography>
<RHFTextField name="budget" />
</Stack>
</Grid>
</Grid>
</Grid>
</Box>
</FormProvider>
);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,33 @@
// @mui // @mui
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup, Grid } from '@mui/material'; import {
Box,
Button,
Card,
Collapse,
IconButton,
InputLabel,
MenuItem,
OutlinedInput,
Paper,
Select,
SelectChangeEvent,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
TextField,
Typography,
Badge,
Tab,
Tabs,
CardHeader,
Stack,
Menu,
ButtonGroup,
Grid,
} 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 AddIcon from '@mui/icons-material/Add';
@@ -21,77 +49,85 @@ 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) const [importResult, setImportResult] = useState(null);
// Dummy Default Data // Dummy Default Data
const [dataTableIsLoading, setDataTableLoading] = React.useState(true); const [dataTableIsLoading, setDataTableLoading] = React.useState(true);
const [dataTableData, setDataTableData] = React.useState<LaravelPaginatedData>({ const [dataTableData, setDataTableData] = React.useState<LaravelPaginatedData>({
current_page: 1, current_page: 1,
data: [], data: [],
path: "", path: '',
first_page_url: "", first_page_url: '',
last_page: 1, last_page: 1,
last_page_url: "", last_page_url: '',
next_page_url: "", next_page_url: '',
prev_page_url: "", prev_page_url: '',
per_page: 10, per_page: 10,
from: 0, from: 0,
to: 0, to: 0,
total: 0 total: 0,
}); });
const loadDataTableData = async (appliedFilter = null) => { const loadDataTableData = async (appliedFilter = null) => {
setDataTableLoading(true); setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]); const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios const response = await axios
.get('/corporates/'+corporate_id+'/members', { params: filter }) .get('/corporates/' + corporate_id + '/members', { params: filter })
.catch((response) => { .catch((response) => {
enqueueSnackbar('Failed getting data. ' + response.message, { variant: 'error' }) enqueueSnackbar('Failed getting data. ' + response.message, { variant: 'error' });
}); });
// console.log(response.data); // console.log(response.data);
setDataTableLoading(false); setDataTableLoading(false);
setDataTableData(response.data); setDataTableData(response.data);
} };
const applyFilter = async (searchFilter: string) => { const applyFilter = async (searchFilter: string) => {
await loadDataTableData({ "search" : searchFilter }); await loadDataTableData({ search: searchFilter });
setSearchParams({ "search" : searchFilter }); setSearchParams({ search: searchFilter });
} };
const handlePageChange = (event : ChangeEvent, value: number) => { const handlePageChange = (event: ChangeEvent, value: number) => {
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]); const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]);
loadDataTableData(filter); loadDataTableData(filter);
setSearchParams(filter); setSearchParams(filter);
} };
useEffect(() => { useEffect(() => {
loadDataTableData(); loadDataTableData();
}, []) }, []);
function SearchInput(props: any) { function SearchInput(props: any) {
// SEARCH // SEARCH
const searchInput = useRef<HTMLInputElement>(null); const searchInput = useRef<HTMLInputElement>(null);
const [searchText, setSearchText] = useState(""); const [searchText, setSearchText] = useState('');
const handleSearchChange = (event: any) => { const handleSearchChange = (event: any) => {
const newSearchText = event.target.value ?? '' const newSearchText = event.target.value ?? '';
setSearchText(newSearchText); setSearchText(newSearchText);
} };
const handleSubmit = (event: any) => { const handleSubmit = (event: any) => {
event.preventDefault(); event.preventDefault();
props.onSearch(searchText); // Trigger to Parent props.onSearch(searchText); // Trigger to Parent
} };
useEffect(() => { useEffect(() => {
// console.log('Search Input: useEffect') // console.log('Search Input: useEffect')
setSearchText(searchParams.get('search') ?? ''); setSearchText(searchParams.get('search') ?? '');
}, [searchParams]) }, [searchParams]);
return ( return (
<form onSubmit={handleSubmit} style={{ width: '100%' }}> <form onSubmit={handleSubmit} style={{ width: '100%' }}>
<TextField id="search-input" ref={searchInput} label="Search" variant="outlined" fullWidth onChange={handleSearchChange} value={searchText}/> <TextField
id="search-input"
ref={searchInput}
label="Search"
variant="outlined"
fullWidth
onChange={handleSearchChange}
value={searchText}
/>
</form> </form>
); );
} }
@@ -101,8 +137,8 @@ export default function CorporatePlanList() {
// Create Button Menu // Create Button Menu
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const createMenu = Boolean(anchorEl); const createMenu = Boolean(anchorEl);
const importPlan = useRef<HTMLInputElement>(null) const importPlan = useRef<HTMLInputElement>(null);
const [currentImportFileName, setCurrentImportFileName] = useState(null) const [currentImportFileName, setCurrentImportFileName] = useState(null);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget); setAnchorEl(event.currentTarget);
@@ -117,51 +153,65 @@ export default function CorporatePlanList() {
handleClose(); handleClose();
importPlan.current ? importPlan.current.click() : console.log('No File selected'); importPlan.current ? importPlan.current.click() : console.log('No File selected');
} else { } else {
alert('No file selected') alert('No file selected');
} }
} };
const handleCancelImportButton = () => { const handleCancelImportButton = () => {
importPlan.current.value = ""; importPlan.current.value = '';
importPlan.current.dispatchEvent(new Event("change", { bubbles: true })); importPlan.current.dispatchEvent(new Event('change', { bubbles: true }));
} };
const handleImportChange = (event: any) => { const handleImportChange = (event: any) => {
if (event.target.files[0]) { if (event.target.files[0]) {
setCurrentImportFileName(event.target.files[0].name) setCurrentImportFileName(event.target.files[0].name);
} else { } else {
setCurrentImportFileName(null); setCurrentImportFileName(null);
} }
} };
const handleUpload = () => { const handleUpload = () => {
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}/members/import`, formData ) axios
.then(response => { .post(`corporates/${corporate_id}/members/import`, formData)
.then((response) => {
handleCancelImportButton(); handleCancelImportButton();
loadDataTableData(); loadDataTableData();
setImportResult(response.data) setImportResult(response.data);
})
.catch(response => {
enqueueSnackbar('Looks like something went wrong. Please check your data and try again. ' + response.message, { variant: 'error' })
}) })
.catch((response) => {
enqueueSnackbar(
'Looks like something went wrong. Please check your data and try again. ' +
response.message,
{ variant: 'error' }
);
});
} else { } else {
enqueueSnackbar('No File Selected', { variant: 'warning' }) enqueueSnackbar('No File Selected', { variant: 'warning' });
} }
} };
return ( return (
<div> <div>
<input type='file' id='file' ref={importPlan} style={{ display: 'none' }} onChange={handleImportChange} accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain" /> <input
{( !currentImportFileName && <Stack direction={'row'} spacing={2} sx={{ p: 2 }}> type="file"
<SearchInput onSearch={applyFilter}/> id="file"
{/* <h1>kjasndkjandskjasndkjansdkjansd</h1> */} ref={importPlan}
<Button style={{ display: 'none' }}
onChange={handleImportChange}
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
/>
{!currentImportFileName && (
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<SearchInput onSearch={applyFilter} />
{/* <h1>kjasndkjandskjasndkjansdkjansd</h1> */}
<Button
id="import-button" id="import-button"
variant='outlined' variant="outlined"
startIcon={<AddIcon />} sx={{ p: 1.8 }} startIcon={<AddIcon />}
sx={{ p: 1.8 }}
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}
@@ -181,153 +231,268 @@ export default function CorporatePlanList() {
<MenuItem onClick={handleImportButton}>Import</MenuItem> <MenuItem onClick={handleImportButton}>Import</MenuItem>
<MenuItem onClick={handleClose}>Download Template</MenuItem> <MenuItem onClick={handleClose}>Download Template</MenuItem>
</Menu> </Menu>
</Stack> </Stack>
)} )}
{( currentImportFileName && <Stack direction={'row'} spacing={2} sx={{ p: 2 }}> {currentImportFileName && (
<ButtonGroup variant="outlined" aria-label="outlined button group" fullWidth> <Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<Button onClick={handleImportButton} fullWidth>{currentImportFileName ?? "No File Selected"}</Button> <ButtonGroup variant="outlined" aria-label="outlined button group" fullWidth>
<Button onClick={handleCancelImportButton} size="small" fullWidth={false} sx={{ p: 1.8 }}><CancelIcon color="error"/></Button> <Button onClick={handleImportButton} fullWidth>
</ButtonGroup> {currentImportFileName ?? 'No File Selected'}
</Button>
<Button
onClick={handleCancelImportButton}
size="small"
fullWidth={false}
sx={{ p: 1.8 }}
>
<CancelIcon color="error" />
</Button>
</ButtonGroup>
<Button <Button
id="upload-button" id="upload-button"
variant='outlined' variant="outlined"
startIcon={<UploadIcon />} sx={{ p: 1.8 }} startIcon={<UploadIcon />}
onClick={handleUpload} sx={{ p: 1.8 }}
> onClick={handleUpload}
Upload >
</Button> Upload
</Stack> </Button>
</Stack>
)} )}
{( importResult && {importResult && (
<Stack direction={'row'} sx={{ px: 2, pb: 2 }}> <Stack direction={'row'} sx={{ px: 2, pb: 2 }}>
<Box sx={{ color: "text.secondary" }}>Last Import Result : <Box sx={{ color: "success.main", display: "inline" }}>{ importResult.total_success_row ?? 0 }</Box> Row Processed, <Box sx={{ color: "error.main", display: "inline" }}>{ importResult.total_failed_row }</Box> Failed, Report : <a href={importResult.result_file?.url ?? "#"}>{importResult.result_file?.name ?? "-"}</a></Box> <Box sx={{ color: 'text.secondary' }}>
</Stack> Last Import Result :{' '}
<Box sx={{ color: 'success.main', display: 'inline' }}>
{importResult.total_success_row ?? 0}
</Box>{' '}
Row Processed,{' '}
<Box sx={{ color: 'error.main', display: 'inline' }}>
{importResult.total_failed_row}
</Box>{' '}
Failed, Report :{' '}
<a href={importResult.result_file?.url ?? '#'}>
{importResult.result_file?.name ?? '-'}
</a>
</Box>
</Stack>
)} )}
</div> </div>
); );
} }
// Called on every row to map the data to the columns // Called on every row to map the data to the columns
function createData( member: Member ): Member { function createData(member: Member): Member {
return { return {
...member, ...member,
} };
} }
const [columns, setColumns] = React.useState([ const [columns, setColumns] = React.useState([
{ id: 'member_id', label: 'MemberID', minWidth: 100, align: "left" }, { id: 'member_id', label: 'MemberID', minWidth: 100, align: 'left' },
{ id: 'principal_id', label: 'Mapping ID', minWidth: 100, align: "left" }, // { id: 'principal_id', label: 'Mapping ID', minWidth: 100, align: 'left' },
{ id: 'nik', label: 'NIK', minWidth: 100, align: "left" }, // { id: 'nik', label: 'NIK', minWidth: 100, align: 'left' },
{ id: 'current_policy.policy_number', label: 'Policy Number', minWidth: 100, align: "left" }, // { id: 'current_policy.policy_number', label: 'Policy Number', minWidth: 100, align: 'left' },
{ id: 'effective_date', label: 'Effective Date', minWidth: 100, align: "left" }, { id: 'effective_date', label: 'Effective Date', minWidth: 100, align: 'left' },
{ id: 'name', label: 'Name', minWidth: 100, align: "left" }, { id: 'name', label: 'Name', minWidth: 100, align: 'left' },
{ id: 'nric', label: 'NRIC', minWidth: 100, align: "left" }, // { id: 'nric', label: 'NRIC', minWidth: 100, align: 'left' },
{ id: 'email', label: 'E-mail', minWidth: 100, align: "left" }, // { id: 'email', label: 'E-mail', minWidth: 100, align: 'left' },
{ id: 'plan_id', label: 'PlanID', minWidth: 100, align: "left" }, { id: 'plan_id', label: 'PlanID', minWidth: 100, align: 'left' },
{ id: 'activation_date', label: 'Activation Date', minWidth: 100, align: "right" }, { id: 'activation_date', label: 'Activation Date', minWidth: 100, align: 'left' },
{ id: 'termination_date', label: 'Termination Date', minWidth: 100, align: 'right' }, { id: 'termination_date', label: 'Termination Date', minWidth: 100, align: 'left' },
]); ]);
// Generate the every row of the table // Generate the every row of the table
function Row(props: { row: ReturnType<typeof createData> }) { function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props; const { row } = props;
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const handleActivate = (model: any, status: string) => {
axios
.put(`/members/${row.id}/activation`, {
// service_code: service.service_code,
active: status == 'active',
})
.then((res) => {
setDataTableData({
...dataTableData,
data: dataTableData.data.map((model) => {
let updatedModel = model;
if (row.id == model.id) {
updatedModel.active = res.data.member.active;
}
return updatedModel;
}),
});
})
.catch((error) => {
// console.log('asdasd', error.response.data.message)
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>
<IconButton <IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
aria-label="expand row"
size="small"
onClick={() => setOpen(!open)}
>
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />} {open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
</IconButton> </IconButton>
</TableCell> </TableCell>
{/* { columns.map((column, index) =>
<TableCell key={ index } align={ column.align } minwidth={ column.minWidth }>{ row[column.id] ?? '-' }</TableCell>
) } */}
{/* TODO FIX DISPLAY DATA FROM RELATION */}
{/* { id: 'member_id', label: 'MemberID', minWidth: 100, align: "left" },
{ id: 'principal_id', label: 'Mapping ID', minWidth: 100, align: "left" },
{ id: 'nik', label: 'NIK', minWidth: 100, align: "left" },
{ id: 'current_policy.policy_number', label: 'Policy Number', minWidth: 100, align: "left" },
{ id: 'effective_date', label: 'Effective Date', minWidth: 100, align: "left" },
{ id: 'name', label: 'Name', minWidth: 100, align: "left" },
{ id: 'nric', label: 'NRIC', minWidth: 100, align: "left" },
{ id: 'email', label: 'E-mail', minWidth: 100, align: "left" },
{ id: 'plan_id', label: 'PlanID', minWidth: 100, align: "left" },
{ id: 'termination_date', label: 'Termination Date', minWidth: 100, align: 'right' },
{ id: 'activation_date', label: 'Activation Date', minWidth: 100, align: "right" },
*/}
<TableCell align="left">{row.member_id}</TableCell> <TableCell align="left">{row.member_id}</TableCell>
<TableCell align="left">{row.principal_id}</TableCell>
<TableCell align="left">{row.employeds[0]?.nik}</TableCell>
<TableCell align="left">{row.current_policy?.policy_id}</TableCell>
<TableCell align="left">{row.current_policy?.start}</TableCell> <TableCell align="left">{row.current_policy?.start}</TableCell>
<TableCell align="left">{row.name}</TableCell> <TableCell align="left">{row.name}</TableCell>
<TableCell align="left">{row.nric}</TableCell>
<TableCell align="left">{row.email}</TableCell>
<TableCell align="left">{row.current_plan?.code}</TableCell> <TableCell align="left">{row.current_plan?.code}</TableCell>
<TableCell align="left">{row.current_policy?.start}</TableCell> <TableCell align="left">{row.current_policy?.start}</TableCell>
<TableCell align="left">{row.current_policy?.end}</TableCell> <TableCell align="left">{row.current_policy?.end}</TableCell>
{( row.active ? (<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>) <TableCell align="center">
: (<TableCell align="right"><Button variant="outlined" color="error" size="small">Inactive</Button></TableCell>) {row.active == 1 && (
)} <Button
variant="outlined"
color="success"
size="small"
onClick={() => {
handleActivate(row, 'inactive');
}}
>
Active
</Button>
)}
{row.active != 1 && (
<Button
variant="outlined"
color="error"
size="small"
onClick={() => {
handleActivate(row, 'active');
}}
>
Inactive
</Button>
)}
</TableCell>
{/* <TableCell align="right"><Button variant="outlined" color="success" size="small">Edit</Button></TableCell> */} {/* <TableCell align="right"><Button variant="outlined" color="success" size="small">Edit</Button></TableCell> */}
</TableRow> </TableRow>
{/* COLLAPSIBLE ROW */} {/* COLLAPSIBLE ROW */}
<TableRow> <TableRow>
<TableCell></TableCell> <TableCell />
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={30}> <TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={15}>
<Collapse in={open} timeout="auto" unmountOnExit> <Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ margin: 1, borderBottom: 1, pb: 2 }}> <Box sx={{ pb: 2 }}>
<Typography sx={{ fontWeight: '600', mb: 1 }}>Claim History</Typography> <Typography sx={{ fontWeight: '600', mb: 1 }}>Detail</Typography>
<Grid container> <Grid container sx={{ pb: 2, mb: 2, borderBottom: 1 }}>
<Grid item xs={6}> <Grid item xs={6}>
<Grid container> <Grid container>
<Grid item xs={6}> <Grid item xs={6}>
Requested Mapping ID
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
: {row.total_claims.requested} : {row.principal_id ?? '-'}
</Grid>
<Grid item xs={6}>
Policy Number
</Grid>
<Grid item xs={6}>
: {row.current_policy?.code ?? '-'}
</Grid>
<Grid item xs={6}>
NRIC
</Grid>
<Grid item xs={6}>
: {row.nric ?? '-'}
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
Pending NIK
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
: {row.total_claims.received} : {row.employeds[0]?.nik ?? '-'}
</Grid>
<Grid item xs={6}>
Email
</Grid>
<Grid item xs={6}>
: {row.email ?? '-'}
</Grid>
</Grid>
</Grid>
<Grid item xs={6}>
<Grid container>
<Grid item xs={6}>
Birth Date
</Grid>
<Grid item xs={6}>
: {row.birth_date ?? '-'}
</Grid>
<Grid item xs={6}>
Gender
</Grid>
<Grid item xs={6}>
: {row.gender ?? '-'}
</Grid>
<Grid item xs={6}>
Martial Status
</Grid>
<Grid item xs={6}>
: {row.marital_status ?? '-'}
</Grid>
<Grid item xs={6}>
Language
</Grid>
<Grid item xs={6}>
: {row.language ?? '-'}
</Grid>
<Grid item xs={6}>
Race
</Grid>
<Grid item xs={6}>
: {row.race ?? '-'}
</Grid>
</Grid>
</Grid>
</Grid>
<Typography sx={{ fontWeight: '600', mb: 1 }}>Claim History</Typography>
<Grid container sx={{ pb: 2, mb: 2, borderBottom: 1 }}>
<Grid item xs={6}>
<Grid container>
<Grid item xs={6}>
Requested
</Grid>
<Grid item xs={6}>
: {row.total_claims?.requested}
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
Approved Pending
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
: {row.total_claims.approved} : {row.total_claims?.received}
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
Declined Approved
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
: {row.total_claims.declined} : {row.total_claims?.approved}
</Grid>
<Grid item xs={6}>
Paid
</Grid>
<Grid item xs={6}>
: {row.total_claims.paid}
</Grid> </Grid>
<Grid item xs={6}>
Declined
</Grid>
<Grid item xs={6}>
: {row.total_claims?.declined}
</Grid>
<Grid item xs={6}>
Paid
</Grid>
<Grid item xs={6}>
: {row.total_claims?.paid}
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
@@ -360,48 +525,54 @@ export default function CorporatePlanList() {
<Stack> <Stack>
<ImportForm /> <ImportForm />
<Card> <Card>
{/* The Main Table */} {/* The Main Table */}
<TableContainer component={Paper}> <TableContainer component={Paper}>
<Table aria-label="collapsible table"> <Table aria-label="collapsible table">
<TableBody> <TableBody>
<TableRow> <TableRow>
<TableCell style={headStyle} align="left" /> <TableCell style={headStyle} align="left" />
{ columns.map((column, index) => ( {columns.map((column, index) => (
<TableCell style={headStyle} key={index} align={column.align}>{column.label}</TableCell> <TableCell style={headStyle} key={index} align={column.align}>
)) } {column.label}
<TableCell style={headStyle} align="right">Status</TableCell> </TableCell>
<TableCell style={headStyle} align="right">Action</TableCell> ))}
<TableCell style={headStyle} align="center">
Status
</TableCell>
<TableCell style={headStyle} align="center">
Action
</TableCell>
</TableRow> </TableRow>
</TableBody> </TableBody>
{dataTableIsLoading ? {dataTableIsLoading ? (
( <TableBody>
<TableBody> <TableRow>
<TableRow> <TableCell colSpan={8} align="center">
<TableCell colSpan={8} align="center">Loading</TableCell> Loading
</TableRow> </TableCell>
</TableBody> </TableRow>
) : ( </TableBody>
dataTableData.data.length == 0 ? ) : dataTableData.data.length == 0 ? (
( <TableBody>
<TableBody> <TableRow>
<TableRow> <TableCell colSpan={8} align="center">
<TableCell colSpan={8} align="center">No Data</TableCell> No Data
</TableRow> </TableCell>
</TableBody> </TableRow>
) : ( </TableBody>
<TableBody> ) : (
{dataTableData.data.map((row, index) => ( <TableBody>
<Row key={index} row={row} /> {dataTableData.data.map((row, index) => (
))} <Row key={index} row={row} />
</TableBody> ))}
) </TableBody>
)} )}
</Table> </Table>
</TableContainer> </TableContainer>
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/> <BasePagination paginationData={dataTableData} onPageChange={handlePageChange} />
</Card> </Card>
</Stack> </Stack>
); );
} }