From 6b7e2be4f03126d9dc653e38a1261ae4102c276a Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Tue, 10 Sep 2024 15:08:38 +0200 Subject: [PATCH 1/3] fix expired and sent label --- .../src/components/SignOffListItem.tsx | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx b/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx index 77d7d2b..5e04b74 100644 --- a/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx +++ b/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx @@ -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 (
@@ -89,11 +97,14 @@ export function SignOffListItem(props: IProps) { {props.state !== 'pending' ? null : (
- {new Date(props.date) <= new Date() ? ( - {gettext('Expired')} - ): ( - {gettext('Pending')} - )} + {isExpired(props.date) + ? ( + {gettext('Expired')} + ) + : ( + {gettext('Sent')} + ) + }
)} {props.state !== 'not_sent' ? null : ( From d0bffc581baf235d392b6c6dd4c7f7506bed5bf0 Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Fri, 13 Sep 2024 09:49:51 +0200 Subject: [PATCH 2/3] changes after review --- .../src/components/SignOffListItem.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx b/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx index 5e04b74..ebde981 100644 --- a/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx +++ b/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx @@ -31,16 +31,16 @@ interface IPropsNotSend extends IPropsBase { 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); - 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 currentDate > expiryDate; - }; +export function SignOffListItem(props: IProps) { + const {formatDateTime, gettext} = superdesk.localization; return ( From e72fc70749d72f30633844058d2fa2f439d24f9d Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Sun, 15 Sep 2024 22:55:28 +0200 Subject: [PATCH 3/3] changes after review --- .../tga-sign-off/src/components/SignOffListItem.tsx | 6 +++--- .../tga-sign-off/src/components/fields/editor.tsx | 1 + .../tga-sign-off/src/components/fields/preview.tsx | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx b/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx index ebde981..53caf9a 100644 --- a/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx +++ b/client/extensions/tga-sign-off/src/components/SignOffListItem.tsx @@ -23,6 +23,7 @@ interface IPropsApproved extends IPropsBase { interface IPropsPendingOrExpired extends IPropsBase { state: 'pending'; date: string; + expiryDate: string; } interface IPropsNotSend extends IPropsBase { @@ -32,9 +33,8 @@ interface IPropsNotSend extends IPropsBase { type IProps = IPropsApproved | IPropsPendingOrExpired | IPropsNotSend; const isExpired = (date: string) => { - const sentDate = new Date(date); const currentDate = new Date(); - const expiryDate = new Date(sentDate.getTime() + 24 * 60 * 60 * 1000); + const expiryDate = new Date(date); return currentDate > expiryDate; }; @@ -97,7 +97,7 @@ export function SignOffListItem(props: IProps) { {props.state !== 'pending' ? null : (
- {isExpired(props.date) + {isExpired(props.expiryDate) ? ( {gettext('Expired')} ) diff --git a/client/extensions/tga-sign-off/src/components/fields/editor.tsx b/client/extensions/tga-sign-off/src/components/fields/editor.tsx index bc9b0f7..b2d0e96 100644 --- a/client/extensions/tga-sign-off/src/components/fields/editor.tsx +++ b/client/extensions/tga-sign-off/src/components/fields/editor.tsx @@ -213,6 +213,7 @@ export class UserSignOffField extends React.Component { onClick: this.sendSignOff.bind(this, [pendingReview.user_id]), }]} date={pendingReview.sent} + expiryDate={pendingReview.expires} /> ) ))} diff --git a/client/extensions/tga-sign-off/src/components/fields/preview.tsx b/client/extensions/tga-sign-off/src/components/fields/preview.tsx index 1e3af03..ac2f0ce 100644 --- a/client/extensions/tga-sign-off/src/components/fields/preview.tsx +++ b/client/extensions/tga-sign-off/src/components/fields/preview.tsx @@ -120,7 +120,8 @@ export class UserSignOffPreview extends React.PureComponent { user={this.state.users[pendingReview.user_id]} readOnly={true} appendContentDivider={true} - date={pendingReview.expires} + date={pendingReview.sent} + expiryDate={pendingReview.expires} /> ) ))}