This commit is contained in:
kevin
2023-06-16 10:26:56 +07:00
parent 3a8a7438ba
commit b05f052848
4 changed files with 92 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ class MemberResource extends JsonResource
{
// $data = parent::toArray($request);
$currentMemberPlan = $this->memberPlans?->first();
$limitTelecon = $currentMemberPlan->plan->limit_telecon ?? null;
$limitTelecon = $this->totalUsage >= 6 ? null : $limitTelecon;
$data = [
'member_id' => $this->member_id,
@@ -29,7 +31,9 @@ class MemberResource extends JsonResource
'code' => $currentMemberPlan->plan->code ?? null,
'start' => $currentMemberPlan->start,
'end' => $currentMemberPlan->end,
'limit' => $this->currentPlan->limit_rules
'limit' => $this->currentPlan->limit_rules,
'limit_telecon' => $limitTelecon,
] : null,
'policy_code' => $this->currentPolicy?->code ?? null,
'corporate' => [

View File

@@ -64,6 +64,7 @@ return new class extends Migration
$table->string('currency')->nullable();
$table->float('max_surgery_reinstatement_days')->nullable();
$table->float('max_surgery_periode_days')->nullable();
$table->timestamps();
$table->softDeletes();

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(' plans', function (Blueprint $table) {
$table->string('limit_telecon')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('plans', function (Blueprint $table) {
$table->dropColumn('limit_telecon');
});
}
};

View File

@@ -21,6 +21,22 @@ const BorderLinearProgress = styled(LinearProgress)(({ theme }) => ({
}));
type DataMember = {
id: number;
fullName: string;
memberId: string;
limit: {
current: number;
total: number;
percentage: number;
};
avatar: {
url: string;
title: string;
};
status: JSX.Element;
};
type CardPolicyProps = {
limit: {
myLimit: {
@@ -49,6 +65,8 @@ type CardPolicyProps = {
members?: DataMember[];
};
// ----------------------------------------------------------------------
export default function CardPolicyNumber() {
@@ -85,6 +103,42 @@ export default function CardPolicyNumber() {
// topUpLimit: corporateTopUpLimit.data.data,
// });
}, [corporateValue]);
const calculateProgressValue = (current:number,total:number) => {
return (current/total) * 100;
};
const getMemberLimitUsage = (memberId: string) => {
if (policyData?.members) {
const member = policyData.members.find(member => member.memberId === memberId);
if (member) {
return member.limit;
}
}
return null;
};
const renderYearlyLimit = () => {
if (policyData) {
const { myLimit } = policyData.limit;
const { balance, total, percentage } = myLimit;
const progressValue = calculateProgressValue(balance, total);
return (
<Stack spacing={1} sx={{ width: '206.5px' }}>
<Typography variant="subtitle2">Yearly Limit</Typography>
<BorderLinearProgress variant="determinate" value={progressValue} />
<Typography variant="subtitle2" sx={{ fontWeight: 500 }}>
{balance.toLocaleString()} /{' '}
<Typography variant="body2" color="#757575" component="span">
{total.toLocaleString()}
</Typography>
</Typography>
</Stack>
);
}
return null;
};
return (
<Card sx={{ padding: 2 }}>