diff --git a/Modules/Internal/Http/Controllers/Api/CorporateController.php b/Modules/Internal/Http/Controllers/Api/CorporateController.php index 654e3934..8bafc8cb 100644 --- a/Modules/Internal/Http/Controllers/Api/CorporateController.php +++ b/Modules/Internal/Http/Controllers/Api/CorporateController.php @@ -4,11 +4,14 @@ namespace Modules\Internal\Http\Controllers\Api; use App\Imports\PlansImport; use App\Models\Corporate; +use App\Models\Plan; use DB; use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Maatwebsite\Excel\Facades\Excel; +use Box\Spout\Reader\Common\Creator\ReaderEntityFactory; +use Illuminate\Support\Facades\Storage; class CorporateController extends Controller { @@ -19,7 +22,7 @@ class CorporateController extends Controller public function index() { $corporates = Corporate::query() - ->paginate(); + ->paginate(0); return $corporates; } @@ -166,18 +169,4 @@ class CorporateController extends Controller { // } - - - public function planImport(Request $request, $id) - { - $request->validate([ - 'file' => 'required|file|mimes:xls,xlsx,csv,txt', - ]); - - $data = Excel::toArray(new PlansImport, $request->file('file')); - dd($data); - - return 'OK'; - dd($id, $request->hasFile('file')); - } } diff --git a/Modules/Internal/Http/Controllers/Api/PlanController.php b/Modules/Internal/Http/Controllers/Api/PlanController.php new file mode 100644 index 00000000..95a1ad03 --- /dev/null +++ b/Modules/Internal/Http/Controllers/Api/PlanController.php @@ -0,0 +1,148 @@ +filter($request->all()) + ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) { + $corporatePlan->where('corporate_id', $corporate_id); + }) + ->with('corporatePlan') + ->paginate(0) + ->appends($request->all()); + + return $plans; + } + + /** + * Show the form for creating a new resource. + * @return Renderable + */ + public function create() + { + return view('internal::create'); + } + + /** + * Store a newly created resource in storage. + * @param Request $request + * @return Renderable + */ + public function store(Request $request) + { + // + } + + /** + * Show the specified resource. + * @param int $id + * @return Renderable + */ + public function show($id) + { + return view('internal::show'); + } + + /** + * Show the form for editing the specified resource. + * @param int $id + * @return Renderable + */ + public function edit($id) + { + return view('internal::edit'); + } + + /** + * Update the specified resource in storage. + * @param Request $request + * @param int $id + * @return Renderable + */ + public function update(Request $request, $id) + { + // + } + + /** + * Remove the specified resource from storage. + * @param int $id + * @return Renderable + */ + public function destroy($id) + { + // + } + + public function plansImport(Request $request, $corporate_id) + { + $request->validate([ + 'file' => 'required|file|mimes:xls,xlsx,csv,txt', + ]); + $file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName(); + $file = $request->file('file')->storeAs('temp', $file_name); + + // return false; + + $reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name)); + $reader->open(Storage::path('temp/'.$file_name)); + + $headers_map_to_table_fields = Plan::$doc_headers_to_field_map; + + $imported_plan_data = 0; + $failed_plan_data = []; + foreach ($reader->getSheetIterator() as $sheet) { + $doc_headers_indexes = []; + foreach ($sheet->getRowIterator() as $index => $row) { + if ($index == 1) { // First Row Must be Header + foreach ($row->getCells() as $index => $cell) { + $doc_headers_indexes[$index] = $cell->getValue(); + } + } else { // Next Row Should be Data + $new_plan_data = []; + foreach ($row->getCells() as $index => $cell) { + $new_plan_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue(); + } + + // $imported_plan_data[] = $new_row; // Insert to Array + // Create Directly + try { + Plan::updateOrCreate([ + 'code' => $new_plan_data['code'] + ], $new_plan_data); + + $imported_plan_data++; + } catch(\Exception $e) { + $failed_plan_data[] = $new_plan_data; + } + } + } + + break; //only read first sheet + } + $reader->close(); + Storage::delete('temp/'.$file_name); + // throw(404); + + return [ + 'total_successed_row' => $imported_plan_data, + 'total_failed_row' => count($failed_plan_data), + 'failed_row' => $failed_plan_data + ]; + } +} diff --git a/Modules/Internal/Routes/api.php b/Modules/Internal/Routes/api.php index c61c3e39..f998157b 100644 --- a/Modules/Internal/Routes/api.php +++ b/Modules/Internal/Routes/api.php @@ -3,6 +3,7 @@ use Modules\Internal\Http\Controllers\Api\AuthController; use Illuminate\Http\Request; use Modules\Internal\Http\Controllers\Api\CorporateController; +use Modules\Internal\Http\Controllers\Api\PlanController; /* |-------------------------------------------------------------------------- @@ -32,7 +33,8 @@ Route::prefix('internal')->group(function () { Route::resource('corporates', CorporateController::class); // Route::post('corporates/{id}/plans', [CorporateController::class, 'planImport']); - Route::post('corporates/{id}/plans/import', [CorporateController::class, 'planImport']); + Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']); + Route::post('corporates/{corporate_id}/plans/import', [PlanController::class, 'planImport']); }); }); // Route::resource('corporates', CorporateController::class); diff --git a/app/Models/CorporatePlan.php b/app/Models/CorporatePlan.php new file mode 100644 index 00000000..464adc48 --- /dev/null +++ b/app/Models/CorporatePlan.php @@ -0,0 +1,22 @@ +belongsTo(Corporate::class); + } +} diff --git a/app/Models/Plan.php b/app/Models/Plan.php index 742b8c6a..c5674013 100644 --- a/app/Models/Plan.php +++ b/app/Models/Plan.php @@ -8,4 +8,138 @@ use Illuminate\Database\Eloquent\Model; class Plan extends Model { use HasFactory; + + protected $fillable = [ + "service_code", + "corporate_plan_id", + "code", + "type", + "start", + "end", + "require_referral", + "referral_source", + "referral_duration", + "family_plan", + "family_plan_share_rules", + "limit_rules", + "layer", + "layer_conditions", + "budget_type", + "budget_code", + "budget_conditions", + "surgery_limit", + "non_surgery_limit", + "max_claim_limit", + "max_claim_count", + "area_limit", + "limit_shared_plans", + "limit_shared_plan_type", + "cashless_percentage", + "reimbursement_percentage", + "digital_percentage", + "co_share_m_percentage", + "co_share_s_percentage", + "co_share_c_percentage", + "cashless_deductible", + "reimbursement_deductible", + "digital_deductible", + "co_share_m_deductible", + "co_share_s_deductible", + "co_share_c_deductible", + "co_share_deductible_condition", + "msc", + "genders", + "min_age", + "max_age", + "rule_of_excess", + "max_excess_covered", + "prorate_type", + "prorate_lookup", + "currency", + "max_surgery_reinstatement_days", + "max_surgery_periode_days", + ]; + + public static $doc_headers_to_field_map = [ + "Service" => "service_code", + "Plan" => "corporate_plan_id", + "Customer Plan" => "code", + "Plan Type" => "type", + "Start Date of Plan" => "start", + "End Date of Plan" => "end", + "Referral" => "require_referral", + "Referral Source" => "referral_source", + "Referral Duration" => "referral_duration", + "Family Plan" => "family_plan", + "Family Sharing Overflow" => "family_plan_share_rules", + "Plan Limit" => "limit_rules", + "Layer ID" => "layer", + "Layer Condition" => "layer_conditions", + "Budget Type" => "budget_type", + "Budget Code" => "budget_code", + "Budget Condition" => "budget_conditions", + "Surgery" => "surgery_limit", + "Non Surgery" => "non_surgery_limit", + "Max/Claim" => "max_claim_limit", + "Max Count of Claim" => "max_claim_count", + "Area" => "area_limit", + "Shared Plan" => "limit_shared_plans", + "Shared Plan Type" => "limit_shared_plan_type", + "Cashless(%)" => "cashless_percentage", + "Reimbursement(%)" => "reimbursement_percentage", + "Digital(%)" => "digital_percentage", + "CoShareM(%)" => "co_share_m_percentage", + "CoShareS(%)" => "co_share_s_percentage", + "CoShareC(%)" => "co_share_c_percentage", + "Cashless Deductible" => "cashless_deductible", + "Reimbursement Deductible" => "reimbursement_deductible", + "Digital Deductible" => "digital_deductible", + "DeductibleM" => "co_share_m_deductible", + "DeductibleS" => "co_share_s_deductible", + "DeductibleC" => "co_share_c_deductible", + "Co-share & Deductible Condition" => "co_share_deductible_condition", + "MSC" => "msc", + "Gender" => "genders", + "Min Age" => "min_age", + "Max Age" => "max_age", + "Rule of Excess" => "rule_of_excess", + "Max Excess Covered" => "max_excess_covered", + "Prorate Type" => "prorate_type", + "Prorate Lookup" => "prorate_lookup", + "Currency" => "currency", + "Reinstatement days for Surgery NonSurgery" => "max_surgery_reinstatement_days", + "Max Periode of Surgery Non Surgery" => "max_surgery_periode_days", + ]; + + public function setStartAttribute($value) + { + return empty($valu) ? null : $value; + } + + public function setEndAttribute($value) + { + return empty($valu) ? null : $value; + } + + public function scopeFilter($query, array $filters) + { + $query->when($filters['search'] ?? false, function ($query, $search) { + return $query + ->where('service_code', 'like', "%" . $search . "%") + ->orWhere('code', 'like', "%" . $search . "%") + ->orWhereHas('corporatePlan', function ($query) use ($search) { + $query->where('code', 'like', "%" . $search . "%"); + }); + }); + } + + public function corporatePlan() + { + return $this->belongsTo(CorporatePlan::class); + } + + // public function Corporate() + // { + // return $this->belongsTo(Corporate::class); + // } } diff --git a/composer.json b/composer.json index f96ce8b3..3fe48c8a 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^8.0.2", + "box/spout": "^3.3", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.11", "laravel/sanctum": "^2.15", diff --git a/composer.lock b/composer.lock index b35965ed..8b809393 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,83 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b5340b061d1a252185e034fe63f2fb0c", + "content-hash": "f4f7a646aaed46ea86bc501ff51dbe38", "packages": [ + { + "name": "box/spout", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/box/spout.git", + "reference": "9bdb027d312b732515b884a341c0ad70372c6295" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/box/spout/zipball/9bdb027d312b732515b884a341c0ad70372c6295", + "reference": "9bdb027d312b732515b884a341c0ad70372c6295", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlreader": "*", + "ext-zip": "*", + "php": ">=7.2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2", + "phpunit/phpunit": "^8" + }, + "suggest": { + "ext-iconv": "To handle non UTF-8 CSV files (if \"php-intl\" is not already installed or is too limited)", + "ext-intl": "To handle non UTF-8 CSV files (if \"iconv\" is not already installed)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Box\\Spout\\": "src/Spout" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Adrien Loison", + "email": "adrien@box.com" + } + ], + "description": "PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way", + "homepage": "https://www.github.com/box/spout", + "keywords": [ + "OOXML", + "csv", + "excel", + "memory", + "odf", + "ods", + "office", + "open", + "php", + "read", + "scale", + "spreadsheet", + "stream", + "write", + "xlsx" + ], + "support": { + "issues": "https://github.com/box/spout/issues", + "source": "https://github.com/box/spout/tree/v3.3.0" + }, + "abandoned": true, + "time": "2021-05-14T21:18:09+00:00" + }, { "name": "brick/math", "version": "0.9.3", diff --git a/database/migrations/2022_05_23_073350_create_members_table.php b/database/migrations/2022_05_23_073350_create_members_table.php index 0df9a517..0224a4e6 100644 --- a/database/migrations/2022_05_23_073350_create_members_table.php +++ b/database/migrations/2022_05_23_073350_create_members_table.php @@ -15,7 +15,7 @@ return new class extends Migration { Schema::create('members', function (Blueprint $table) { $table->id(); - $table->foreignId('user_id')->nullable(); + $table->foreignId('user_id')->nullable()->index(); $table->string('name_prefix')->nullable(); $table->string('name'); $table->string('name_suffix')->nullable(); @@ -25,7 +25,7 @@ return new class extends Migration $table->string('language')->nullable(); $table->string('race')->nullable(); $table->string('marital_status')->nullable(); - $table->foreignId('principle_id')->nullable(); + $table->foreignId('principle_id')->nullable()->index(); $table->string('relation_with_principle')->nullable(); $table->date('bpjs_class')->nullable(); $table->boolean('active')->default(true); diff --git a/database/migrations/2022_06_16_045441_create_corporate_divisions_table.php b/database/migrations/2022_06_16_045441_create_corporate_divisions_table.php index f450f0d3..87e51ada 100644 --- a/database/migrations/2022_06_16_045441_create_corporate_divisions_table.php +++ b/database/migrations/2022_06_16_045441_create_corporate_divisions_table.php @@ -15,7 +15,7 @@ return new class extends Migration { Schema::create('corporate_divisions', function (Blueprint $table) { $table->id(); - $table->foreignId('corporate_id')->nullable(); + $table->foreignId('corporate_id')->nullable()->index(); $table->string('code'); $table->string('name')->nullable(); diff --git a/database/migrations/2022_06_23_083834_create_plans_table.php b/database/migrations/2022_06_23_083834_create_plans_table.php index d48b2e9d..5bf4d669 100644 --- a/database/migrations/2022_06_23_083834_create_plans_table.php +++ b/database/migrations/2022_06_23_083834_create_plans_table.php @@ -16,6 +16,7 @@ return new class extends Migration Schema::create('plans', function (Blueprint $table) { $table->id(); $table->string('service_code')->index(); + $table->string('corporate_plan_id')->index(); $table->string('code')->index(); $table->string('type')->nullable(); $table->dateTime('start')->nullable(); @@ -46,9 +47,10 @@ return new class extends Migration $table->tinyInteger('co_share_c_percentage')->default(100)->nullable(); $table->decimal('cashless_deductible', 15, 2)->nullable(); $table->decimal('reimbursement_deductible', 15, 2)->nullable(); + $table->decimal('digital_deductible', 15, 2)->nullable(); $table->decimal('co_share_m_deductible', 15, 2)->nullable(); - $table->decimal('co_share_s_eductible', 15, 2)->nullable(); - $table->decimal('co_share_c_eductible', 15, 2)->nullable(); + $table->decimal('co_share_s_deductible', 15, 2)->nullable(); + $table->decimal('co_share_c_deductible', 15, 2)->nullable(); $table->string('co_share_deductible_condition')->nullable(); $table->string('msc')->nullable(); $table->string('genders')->nullable(); @@ -59,6 +61,8 @@ return new class extends Migration $table->string('prorate_type')->nullable(); $table->string('prorate_lookup')->nullable(); $table->string('currency')->nullable(); + $table->tinyInteger('max_surgery_reinstatement_days')->nullable(); + $table->tinyInteger('max_surgery_periode_days')->nullable(); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2022_07_04_075238_create_files_table.php b/database/migrations/2022_07_04_075238_create_files_table.php index f5ecbb8b..f9547f0a 100644 --- a/database/migrations/2022_07_04_075238_create_files_table.php +++ b/database/migrations/2022_07_04_075238_create_files_table.php @@ -30,7 +30,6 @@ return new class extends Migration $table->index(['fileable_id', 'fileable_type']); $table->index(['fileable_id', 'fileable_type', 'type']); - $table->timestamps(); }); } diff --git a/database/migrations/2022_07_07_040543_create_corporate_plans_table.php b/database/migrations/2022_07_07_040543_create_corporate_plans_table.php new file mode 100644 index 00000000..75dd4b8c --- /dev/null +++ b/database/migrations/2022_07_07_040543_create_corporate_plans_table.php @@ -0,0 +1,39 @@ +id(); + $table->foreignId('corporate_id')->nullable()->index(); + $table->string('code')->index(); + $table->string('name')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->foreignId('created_by')->nullable()->index(); + $table->foreignId('updated_by')->nullable()->index(); + $table->foreignId('deleted_by')->nullable()->index(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('corporate_plans'); + } +}; diff --git a/frontend/dashboard/src/@types/corporates.ts b/frontend/dashboard/src/@types/corporates.ts index 0c188c6b..7016778c 100644 --- a/frontend/dashboard/src/@types/corporates.ts +++ b/frontend/dashboard/src/@types/corporates.ts @@ -40,3 +40,63 @@ export type Policy = { start: string | Date; end: string | Date; } + +export type CorporatePlan = { + id: number; + corporate_id: number; + code: string; + name: string; +} + +export type Plan = { + id: number; + corporate_plan: CorporatePlan | null; + service_code: string; + corporate_plan_id: string; + code: string; + type: string; + start: string; + end: string; + require_referral: string; + referral_source: string; + referral_duration: string; + family_plan: string; + family_plan_share_rules: string; + limit_rules: string; + layer: string; + layer_conditions: string; + budget_type: string; + budget_code: string; + budget_conditions: string; + surgery_limit: string; + non_surgery_limit: string; + max_claim_limit: string; + max_claim_count: string; + area_limit: string; + limit_shared_plans: string; + limit_shared_plan_type: string; + cashless_percentage: string; + reimbursement_percentage: string; + digital_percentage: string; + co_share_m_percentage: string; + co_share_s_percentage: string; + co_share_c_percentage: string; + cashless_deductible: string; + reimbursement_deductible: string; + digital_deductible: string; + co_share_m_deductible: string; + co_share_s_deductible: string; + co_share_c_deductible: string; + co_share_deductible_condition: string; + msc: string; + genders: string; + min_age: string; + max_age: string; + rule_of_excess: string; + max_excess_covered: string; + prorate_type: string; + prorate_lookup: string; + currency: string; + max_surgery_reinstatement_days: string; + max_surgery_periode_days: string; +} diff --git a/frontend/dashboard/src/pages/Corporates/Benefit/Index.tsx b/frontend/dashboard/src/pages/Corporates/Benefit/Index.tsx index a0fa42a8..0ab7f815 100644 --- a/frontend/dashboard/src/pages/Corporates/Benefit/Index.tsx +++ b/frontend/dashboard/src/pages/Corporates/Benefit/Index.tsx @@ -39,7 +39,7 @@ export default function Divisions() { - + diff --git a/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx b/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx index 0133b164..0622f281 100644 --- a/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx +++ b/frontend/dashboard/src/pages/Corporates/Benefit/List.tsx @@ -1,29 +1,163 @@ // @mui -import { Box, Button, Card, Collapse, Container, FormControl, Grid, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack } 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 } from '@mui/material'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; -import PublishIcon from '@mui/icons-material/Publish'; import AddIcon from '@mui/icons-material/Add'; +import UploadIcon from '@mui/icons-material/Upload'; +import CancelIcon from '@mui/icons-material/Cancel'; // hooks +import React, { Component, useEffect, useRef, useState } from 'react'; import useSettings from '../../../hooks/useSettings'; +import { useParams, useSearchParams } from 'react-router-dom'; // components -import Page from '../../../components/Page'; import axios from '../../../utils/axios'; -import useAuth from '../../../hooks/useAuth'; -import { Link , NavLink as RouterLink, useParams } from 'react-router-dom'; -import React, { useEffect, useRef } from 'react'; -import { Theme, useTheme } from '@mui/material/styles'; -import { Corporate } from '../../../@types/corporates'; +import { Plan } from '../../../@types/corporates'; import { LaravelPaginatedData } from '../../../@types/paginated-data'; -import CorporateTabNavigations from '../CorporateTabNavigations'; -export default function DivisionsList() { +export default function PlanList() { const { themeStretch } = useSettings(); + const { id } = useParams(); + const [searchParams, setSearchParams] = useSearchParams(); + + function SearchInput(props: any) { + // SEARCH + const searchInput = useRef(null); + const [searchText, setSearchText] = useState(""); + + const handleSearchChange = (event: any) => { + const newSearchText = event.target.value ?? '' + setSearchText(newSearchText); + } + + const handleSubmit = (event: any) => { + event.preventDefault(); + props.onSearch(searchText); // Trigger to Parent + } + + useEffect(() => { + console.log('Search Input: useEffect') + setSearchText(searchParams.get('search') ?? ''); + }, [searchParams]) + + return ( +
+ + + ); + } + + function ImportForm(props: any) { + // IMPORT + // Create Button Menu + const [anchorEl, setAnchorEl] = React.useState(null); + const createMenu = Boolean(anchorEl); + const importPlan = useRef(null) + const [currentImportFileName, setCurrentImportFileName] = useState(null) + + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + + const handleClose = () => { + setAnchorEl(null); + }; + + const handleImportButton = () => { + if (importPlan?.current) { + handleClose(); + importPlan.current ? importPlan.current.click() : console.log('No File selected'); + } else { + alert('No file selected') + } + } + + const handleCancelImportButton = () => { + importPlan.current.value = ""; + importPlan.current.dispatchEvent(new Event("change", { bubbles: true })); + } + + const handleImportChange = (event: any) => { + if (event.target.files[0]) { + setCurrentImportFileName(event.target.files[0].name) + } else { + setCurrentImportFileName(null); + } + } + + const handleUpload = () => { + if (importPlan.current?.files.length) { + const formData = new FormData(); + formData.append("file", importPlan.current?.files[0]) + axios.post(`corporates/${id}/plans/import`, formData ) + .then(response => { + handleCancelImportButton(); + loadDataTableData(); + alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows'); + }) + .catch(response => { + alert('Looks like something went wrong. Please check your data and try again. ' + response.message) + }) + } else { + alert('No File Selected') + } + } + + return ( +
+ + {( !currentImportFileName && + + {/*

kjasndkjandskjasndkjansdkjansd

*/} + + + Import + Download Template + +
+ )} + + {( currentImportFileName && + + + + + + + + )} +
+ ); + } // Called on every row to map the data to the columns - function createData( corporate: Corporate ): Corporate { + function createData( plan: Plan ): Plan { return { - ...corporate, + ...plan, } } @@ -44,17 +178,69 @@ export default function DivisionsList() { {open ? : } + {row.service_code} + {row.corporate_plan?.code} {row.code} - {row.name} + {row.type} + {row.start} + {row.end} + {row.require_referral} + {row.referral_source} + {row.referral_duration} + {row.family_plan} + {row.family_plan_share_rules} + {row.limit_rules} + {row.layer} + {row.layer_conditions} + {row.budget_type} + {row.budget_code} + {row.budget_conditions} + {row.surgery_limit} + {row.non_surgery_limit} + {row.max_claim_limit} + {row.max_claim_count} + {row.area_limit} + {row.limit_shared_plans} + {row.limit_shared_plan_type} + {row.cashless_percentage} + {row.reimbursement_percentage} + {row.digital_percentage} + {row.co_share_m_percentage} + {row.co_share_s_percentage} + {row.co_share_c_percentage} + {row.cashless_deductible} + {row.reimbursement_deductible} + {row.digital_deductible} + {row.co_share_m_deductible} + {row.co_share_s_deductible} + {row.co_share_c_deductible} + {row.co_share_deductible_condition} + {row.msc} + {row.genders} + {row.min_age} + {row.max_age} + {row.rule_of_excess} + {row.max_excess_covered} + {row.prorate_type} + {row.prorate_lookup} + {row.currency} + {row.max_surgery_reinstatement_days} + {row.max_surgery_periode_days} + {/* COLLAPSIBLE ROW */} - + - + + + No Extra Data + + + {false && - History + Rules @@ -66,27 +252,23 @@ export default function DivisionsList() { - {row.history ? row.history.map(( historyRow ) => ( - - - {historyRow?.date} - - {historyRow?.customerId} - {historyRow?.amount} - - {Math.round(historyRow?.amount * 1000 * 100) / 100} - + {/* {row.history ? row.history.map((historyRow) => ( */} + + {row.start} - {row.end} + {row.start} + {row.start} + {row.start} - )) + {/* )) : ( No Data ) - } + } */}
-
+
}
@@ -111,95 +293,32 @@ export default function DivisionsList() { total: 0 }); - const loadDataTableData = async () => { + const loadDataTableData = async (appliedFilter = null) => { setDataTableLoading(true); - const response = await axios.get('/corporates'); + const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]); + const response = await axios.get('/corporates/'+id+'/plans', { params: filter }); // console.log(response.data); setDataTableLoading(false); setDataTableData(response.data); } - useEffect(() => { - loadDataTableData(); - }, []) - const headStyle = { fontWeight: 'bold', }; - // FILTER SELECT - const ITEM_HEIGHT = 48; - const ITEM_PADDING_TOP = 8; - const MenuProps = { - PaperProps: { - style: { - maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, - width: 250, - }, - }, - }; - - const names = [ - 'PLAN001', - 'PLAN002', - 'PLAN003', - 'PLAN004', - 'PLAN005', - ]; - function getStyles(name: string, personName: string[], theme: Theme) { - return { - fontWeight: - personName.indexOf(name) === -1 - ? theme.typography.fontWeightRegular - : theme.typography.fontWeightMedium, - }; - } - - const theme = useTheme(); - const [planIdFilter, setPlanIdFilter] = React.useState([]); - - const handleChangePlanID = (event: SelectChangeEvent) => { - const { - target: { value }, - } = event; - setPlanIdFilter( - // On autofill we get a stringified value. - typeof value === 'string' ? value.split(',') : value, - ); - }; - - const [statusFilter, setStatusFilter] = React.useState([]); - const handleChangeStatus = (event: SelectChangeEvent) => { - const { - target: { value }, - } = event; - setStatusFilter( - // On autofill we get a stringified value. - typeof value === 'string' ? value.split(',') : value, - ); - }; - // END FILTER SELECT - - // IMPORT - const importMember = React.useRef(null); - const handleImportButton = (event: any) => { - if (importMember?.current) - importMember.current ? importMember.current.click() : console.log('fuck'); - else - alert('No file selected') + const applyFilter = async (searchFilter) => { + await loadDataTableData({ "search" : searchFilter }); + setSearchParams({ "search" : searchFilter }); } - const { id } = useParams(); - + useEffect(() => { + loadDataTableData(); + }, []) + return ( - - - - + + + {/* COLLAPSIBLE ROW */} + + + + + + No Extra Data + + + {false && + + Rules + + + + + Date + Customer + Amount + Total price ($) + + + + {/* {row.history ? row.history.map((historyRow) => ( */} + + {row.start} - {row.end} + {row.start} + {row.start} + {row.start} + + {/* )) + : ( + + No Data + + ) + } */} + +
+
} +
+
+
+ + ); + } + + // Dummy Default Data + const [dataTableIsLoading, setDataTableLoading] = React.useState(true); + const [dataTableData, setDataTableData] = React.useState({ + current_page: 1, + data: [], + path: "", + first_page_url: "", + last_page: 1, + last_page_url: "", + next_page_url: "", + prev_page_url: "", + per_page: 10, + from: 0, + to: 0, + total: 0 + }); + + const loadDataTableData = async (appliedFilter = null) => { + setDataTableLoading(true); + const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]); + const response = await axios.get('/corporates/'+id+'/plans', { params: filter }); + // console.log(response.data); + setDataTableLoading(false); + + setDataTableData(response.data); + } + + const headStyle = { + fontWeight: 'bold', + }; + + const applyFilter = async (searchFilter) => { + await loadDataTableData({ "search" : searchFilter }); + setSearchParams({ "search" : searchFilter }); + } + + useEffect(() => { + loadDataTableData(); + }, []) + + return ( + + {/* The Main Table */} @@ -233,9 +326,56 @@ export default function DivisionsList() { - # + + Service + Plan Code - Name + Type + Start + End + Referral + Referral Source + Referral Duration + Family Plan + Family Sharing Overflow + Plan Limit + Layer ID + Layer Condition + Budget Type + Budget Code + Budget Condition + Surgery + Non Surgery + Max/Claim + Max Count of Claim + Area + Shared Plan + Limit Shared Type + Cashless(%) + Reimbursement(%) + Digital(%) + CoShare M(%) + CoShare S(%) + CoShare C(%) + Cashless Deductible + Reimbursement Deductible + Digital Deductible + DeductibleM + DeductibleS + DeductibleC + CoShare & Deductible Condition + MSC + Gender + Min Age + Max Age + Rule of Excess + Max Excess Covered + Prorate Type + Prorate Lookup + Currency + Reinstatement Surgery + Period of Surgery + Status Action