-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into art/97602/arp-header
- Loading branch information
Showing
13 changed files
with
364 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...pplications/accredited-representative-portal/components/POARequestCard/POARequestCard.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Link } from 'react-router-dom'; | ||
import { differenceInDays } from 'date-fns'; | ||
|
||
import { | ||
formatDateParsedZoneLong, | ||
timeFromNow, | ||
} from 'platform/utilities/date/index'; | ||
|
||
const expiresSoon = expDate => { | ||
const EXPIRES_SOON_THRESHOLD_DURATION = 7 * 24 * 60 * 60 * 1000; | ||
const now = new Date(); | ||
const expiresAt = new Date(expDate); | ||
const daysLeft = timeFromNow(expiresAt, now); | ||
if ( | ||
differenceInDays(expiresAt, now) > 0 && | ||
differenceInDays(expiresAt, now) < EXPIRES_SOON_THRESHOLD_DURATION | ||
) { | ||
return `(in ${daysLeft})`; | ||
} | ||
return null; | ||
}; | ||
|
||
const POARequestCard = ({ poaRequest, id }) => { | ||
return ( | ||
<li> | ||
<va-card class="poa-request__card"> | ||
<span | ||
data-testid={`poa-request-card-${id}-status`} | ||
className="usa-label poa-request__card-field poa-request__card-field--status" | ||
> | ||
{poaRequest.status} | ||
</span> | ||
<Link to={id}> | ||
<span className="sr-only">View details for </span> | ||
<h3 | ||
data-testid={`poa-request-card-${id}-name`} | ||
className="poa-request__card-title vads-u-font-size--h4" | ||
> | ||
{`${poaRequest.claimant.lastName}, ${ | ||
poaRequest.claimant.firstName | ||
}`} | ||
</h3> | ||
</Link> | ||
|
||
<p className="poa-request__card-field poa-request__card-field--location"> | ||
<span data-testid={`poa-request-card-${id}-city`}> | ||
{poaRequest.claimantAddress.city} | ||
</span> | ||
{', '} | ||
<span data-testid={`poa-request-card-${id}-state`}> | ||
{poaRequest.claimantAddress.state} | ||
</span> | ||
{', '} | ||
<span data-testid={`poa-request-card-${id}-zip`}> | ||
{poaRequest.claimantAddress.zip} | ||
</span> | ||
</p> | ||
|
||
<p | ||
data-testid="poa-request-card-field-received" | ||
className="poa-request__card-field poa-request__card-field--request" | ||
> | ||
{poaRequest.status === 'Declined' && ( | ||
<> | ||
<span className="poa-request__card-field--label"> | ||
POA request declined on: | ||
</span> | ||
<span data-testid={`poa-request-card-${id}-declined`}> | ||
{formatDateParsedZoneLong(poaRequest.acceptedOrDeclinedAt)} | ||
</span> | ||
</> | ||
)} | ||
{poaRequest.status === 'Accepted' && ( | ||
<> | ||
<span className="poa-request__card-field--label"> | ||
POA request accepted on: | ||
</span> | ||
<span data-testid={`poa-request-card-${id}-accepted`}> | ||
{formatDateParsedZoneLong(poaRequest.acceptedOrDeclinedAt)} | ||
</span> | ||
</> | ||
)} | ||
|
||
{poaRequest.status === 'Pending' && ( | ||
<> | ||
{expiresSoon(poaRequest.expiresAt) && ( | ||
<va-icon | ||
class="poa-request__card-icon" | ||
icon="warning" | ||
size={2} | ||
srtext="warning" | ||
aria-hidden="true" | ||
/> | ||
)} | ||
<span className="poa-request__card-field--label"> | ||
POA request expires on: | ||
</span> | ||
<span data-testid={`poa-request-card-${id}-received`}> | ||
{formatDateParsedZoneLong(poaRequest.expiresAt)} | ||
</span> | ||
<span className="poa-request__card-field--expiry"> | ||
{expiresSoon(poaRequest.expiresAt)} | ||
</span> | ||
</> | ||
)} | ||
</p> | ||
</va-card> | ||
</li> | ||
); | ||
}; | ||
|
||
POARequestCard.propTypes = { | ||
cssClass: PropTypes.string, | ||
}; | ||
|
||
export default POARequestCard; |
138 changes: 0 additions & 138 deletions
138
...lications/accredited-representative-portal/components/POARequestsCard/POARequestsCard.jsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.