NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import { Typography, Button, Chip } from "@qbe/ui-core";
import { useEffect, useState } from "react";
import { PolicyStatusBtn } from "../../../Components/PolicyStatusButton/PolicyStatusBtn";
import "./PolicyCard.css";
import { Link, useNavigate } from "react-router-dom";
import Popup from "reactjs-popup";
//import { changePolicyStatus } from "../../../Redux/Feautures/policyDashboardSlice";
import { updateDeniedPolicy } from "../../../Redux/Feautures/policyDashboardSlice";
import { setDenyPolicyModalActive } from "../../../Redux/Feautures/modalSlice"
import { useDispatch } from "react-redux";
import { setRemovePolicyModalState, setRemovedPolicyNumberState } from "../../../Redux/Feautures/modalSlice";
import "reactjs-popup/dist/index.css";
//import { showSuccess } from "../../../Components/AlertBox/AlertBox";
import { usePolicyApproveDenyMutation } from "../../../Redux/Apis/policyApi";
import useToast from "../../../Hooks/useTost";
const policyStatus = {
"1": "Pending Approval",
"2": "Approved",
"3": "Denied",
"4": "Removed"
}

export const PolicyCard = ({ data, onClickExpandThreeDots }) => {
const {
id,
policyHolderName,
policyPortalStatus,
policyNumber,
policyEffectiveDate,
eslStatus,
paymentStatus
} = data;
const navigate = useNavigate();
const dispatch = useDispatch();
const showToast = useToast();

//API call for the remove specific policy
const [addPolicyApproval, { isLoading, isSuccess, isError }] = usePolicyApproveDenyMutation();

//Remove policy on remove policy btn click
const onClickRemove = async () => {
dispatch(setRemovePolicyModalState(true));
dispatch(setRemovedPolicyNumberState(data));
}


//REUSABLE BLOCK TO RENDER POLICY DATES
const renderPolicyDates = (label) => {
return (
<div className={policyStatus[policyPortalStatus] !== policyStatus["1"] ? "policy-dates-container" : "policy-dates-container policy-dates-conatiner-visibility"}>
<div>
<Typography
variant="label3"
weight="medium"
className="policy-dates-title"
>
{label}
</Typography>
<Typography className="effective-dt" variant="subtitle2" weight="bold">
{policyEffectiveDate}
</Typography>
</div>
<div>
<Typography
variant="label3"
weight="medium"
className="policy-dates-title"
>
Status
</Typography>
<Popup className="popup-arrow popup-overlay" on={['hover', 'focus']} trigger={
<div className="esl-status-ellipsis">
{eslStatus}
</div>} position="bottom center">
{eslStatus}
</Popup>
</div>
{/* <div className="dt-text"> {policyEffectiveDate} </div> */}
</div>
);
};

const renderDecisionBtn = () => {
return (
<div className="decision-btn-container">
<Button className="approve-btn" onClick={onClickApprove} label="Approve" size="small" />
<a onClick={onClickDeny} className="deny-decision-link" href="#">
Deny
</a>
</div>
);

};

const handleNavigation = () => {
navigate('policydetails', { state: data })
}

const onClickDeny = async () => {
dispatch(setDenyPolicyModalActive(true));
dispatch(updateDeniedPolicy(data));
}

useEffect(() => {
if (!isLoading && isSuccess) {
// showSuccess("Policy request has been approved")
}
}, [isLoading])

const onClickApprove = async () => {
// dispatch(changePolicyStatus({ id, status: "Approved" }))
let data1 = { ...data };
data1.policyPortalStatus = 2;
await addPolicyApproval(data1)
showToast("User's policy has been successfully approved", "success")

}

const renderPolicyStatus = () => {
if ( policyStatus[policyPortalStatus] !== policyStatus["1"] && paymentStatus===null){
return policyStatus["2"]
}
if (policyStatus[policyPortalStatus] !== policyStatus["1"]) {
return paymentStatus
} else {
return policyStatus[policyPortalStatus]
}
}

return (
<div className="policy-card-container">
<div className="policy-card-header">
<PolicyStatusBtn policyStatus={renderPolicyStatus()} />
<div
className={
policyStatus[policyPortalStatus] !== policyStatus["1"]
? "threedots"
: "threedots policy-dates-conatiner-visibility"
}
>
<Popup
on={["hover", "focus"]}
trigger={
<div>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-three-dots"
viewBox="0 0 16 16"
>
<path d="M3 9.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3" />
</svg>
</div>
}
position="bottom center"
>
<Typography
onClick={onClickRemove}
variant="label3"
weight="bold"
className="custom-popover-style"
>
{/* Approve/Deny */}
Remove Policy
</Typography>
</Popup>
</div>
</div>
<></>
<div className="company-information">
{policyStatus[policyPortalStatus] === policyStatus["2"] && (
<Popup className="popup-arrow popup-overlay" on={['hover', 'focus']} trigger={
<div className="policy-holder-ellipsis">
{policyHolderName}
</div>} position="bottom center">
{policyHolderName}
</Popup>
)}
<Typography
variant="caption1" weight="medium" className="policy-number"> {policyNumber} </Typography>
</div>
<div className={ policyStatus[policyPortalStatus] === policyStatus["1"] ? "pending-approval-container" : "policy-dates-main-container" }>
{policyStatus[policyPortalStatus] === policyStatus["2"] && ["Effective date"].map((e) => renderPolicyDates(e))}
{policyStatus[policyPortalStatus] === policyStatus["1"] && renderDecisionBtn()}
{/* <Link to={`${id}`}>
{" "} */}
<Button onClick={handleNavigation} disabled={policyStatus[policyPortalStatus] === policyStatus["1"] && !paymentStatus} className="policy-btn" label="View Policy" size="small" />
{/* </Link> */}
</div>
</div>
);
};
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.