Skip to content

Commit

Permalink
Merge pull request #71 from superdesk/sign-off-expired
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo authored Sep 19, 2024
2 parents b4b7e1d + e72fc70 commit 03b493a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 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 @@ -23,6 +23,7 @@ interface IPropsApproved extends IPropsBase {
interface IPropsPendingOrExpired extends IPropsBase {
state: 'pending';
date: string;
expiryDate: string;
}

interface IPropsNotSend extends IPropsBase {
Expand All @@ -31,6 +32,13 @@ interface IPropsNotSend extends IPropsBase {

type IProps = IPropsApproved | IPropsPendingOrExpired | IPropsNotSend;

const isExpired = (date: string) => {
const currentDate = new Date();
const expiryDate = new Date(date);

return currentDate > expiryDate;
};

export function SignOffListItem(props: IProps) {
const {formatDateTime, gettext} = superdesk.localization;

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.expiryDate)
? (
<span>{gettext('Expired')}</span>
)
: (
<span>{gettext('Sent')}</span>
)
}
</div>
)}
{props.state !== 'not_sent' ? null : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export class UserSignOffField extends React.Component<IEditorProps, IState> {
onClick: this.sendSignOff.bind(this, [pendingReview.user_id]),
}]}
date={pendingReview.sent}
expiryDate={pendingReview.expires}
/>
)
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ export class UserSignOffPreview extends React.PureComponent<IProps, IState> {
user={this.state.users[pendingReview.user_id]}
readOnly={true}
appendContentDivider={true}
date={pendingReview.expires}
date={pendingReview.sent}
expiryDate={pendingReview.expires}
/>
)
))}
Expand Down

0 comments on commit 03b493a

Please sign in to comment.