request
This commit is contained in:
@@ -17,6 +17,8 @@ class MemberResource extends JsonResource
|
|||||||
{
|
{
|
||||||
// $data = parent::toArray($request);
|
// $data = parent::toArray($request);
|
||||||
$currentMemberPlan = $this->memberPlans?->first();
|
$currentMemberPlan = $this->memberPlans?->first();
|
||||||
|
$limitTelecon = $currentMemberPlan->plan->limit_telecon ?? null;
|
||||||
|
$limitTelecon = $this->totalUsage >= 6 ? null : $limitTelecon;
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'member_id' => $this->member_id,
|
'member_id' => $this->member_id,
|
||||||
@@ -29,7 +31,9 @@ class MemberResource extends JsonResource
|
|||||||
'code' => $currentMemberPlan->plan->code ?? null,
|
'code' => $currentMemberPlan->plan->code ?? null,
|
||||||
'start' => $currentMemberPlan->start,
|
'start' => $currentMemberPlan->start,
|
||||||
'end' => $currentMemberPlan->end,
|
'end' => $currentMemberPlan->end,
|
||||||
'limit' => $this->currentPlan->limit_rules
|
'limit' => $this->currentPlan->limit_rules,
|
||||||
|
'limit_telecon' => $limitTelecon,
|
||||||
|
|
||||||
] : null,
|
] : null,
|
||||||
'policy_code' => $this->currentPolicy?->code ?? null,
|
'policy_code' => $this->currentPolicy?->code ?? null,
|
||||||
'corporate' => [
|
'corporate' => [
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ return new class extends Migration
|
|||||||
$table->float('max_surgery_reinstatement_days')->nullable();
|
$table->float('max_surgery_reinstatement_days')->nullable();
|
||||||
$table->float('max_surgery_periode_days')->nullable();
|
$table->float('max_surgery_periode_days')->nullable();
|
||||||
|
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
|
|||||||
@@ -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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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 = {
|
type CardPolicyProps = {
|
||||||
limit: {
|
limit: {
|
||||||
myLimit: {
|
myLimit: {
|
||||||
@@ -49,6 +65,8 @@ type CardPolicyProps = {
|
|||||||
members?: DataMember[];
|
members?: DataMember[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export default function CardPolicyNumber() {
|
export default function CardPolicyNumber() {
|
||||||
@@ -86,6 +104,42 @@ export default function CardPolicyNumber() {
|
|||||||
// });
|
// });
|
||||||
}, [corporateValue]);
|
}, [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 (
|
return (
|
||||||
<Card sx={{ padding: 2 }}>
|
<Card sx={{ padding: 2 }}>
|
||||||
<Stack>
|
<Stack>
|
||||||
|
|||||||
Reference in New Issue
Block a user