Skip to content

Commit

Permalink
fix expired and sent label
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Sep 10, 2024
1 parent 1bf635f commit 6b7e2be
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions client/extensions/tga-sign-off/src/components/SignOffListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ type IProps = IPropsApproved | IPropsPendingOrExpired | IPropsNotSend;
export function SignOffListItem(props: IProps) {
const {formatDateTime, gettext} = superdesk.localization;

const isExpired = (date: string) => {
const sentDate = new Date(date);
const currentDate = new Date();
const expiryDate = new Date(sentDate.getTime() + 24 * 60 * 60 * 1000);

return currentDate > expiryDate;
};

return (
<React.Fragment>
<div className="sd-d-flex sd-flex-align-items-center">
Expand Down Expand Up @@ -89,11 +97,14 @@ export function SignOffListItem(props: IProps) {
{props.state !== 'pending' ? null : (
<div className="sd-margin-l--5 sd-padding-l--0-5 sd-margin-t--1">
<label className="form-label form-label--block">{gettext('State:')}</label>
{new Date(props.date) <= new Date() ? (
<span>{gettext('Expired')}</span>
): (
<span>{gettext('Pending')}</span>
)}
{isExpired(props.date)
? (
<span>{gettext('Expired')}</span>
)
: (
<span>{gettext('Sent')}</span>
)
}
</div>
)}
{props.state !== 'not_sent' ? null : (
Expand Down

0 comments on commit 6b7e2be

Please sign in to comment.