-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add `atoExpirationDate` to `GetMyCedarSystems` * Add `atoEffectiveDate` to `GetCedarSystems` * AtoStatus * function getAtoStatus(dt) * Col atoStatus atoExpirationDate || atoEffectiveDate * AtoStatus#atoStatusColumn * AtoStatusIconText Additional DateFormat string * Correct `atoExpirationDate` prop * Ato column type Restore original column hide * Clean up column handling * Reorder AtoStatus file --------- Co-authored-by: ClayBenson94 <clay.benson@oddball.io>
- Loading branch information
1 parent
506f76c
commit 09d08df
Showing
15 changed files
with
353 additions
and
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { | ||
IconCheck, | ||
IconCheckCircleOutline, | ||
IconError, | ||
IconErrorOutline, | ||
IconHelp, | ||
IconHelpOutline, | ||
IconHighlightOff, | ||
IconWarning | ||
} from '@trussworks/react-uswds'; | ||
// eslint-disable-next-line import/no-unresolved | ||
import { IconProps } from '@trussworks/react-uswds/lib/components/Icon/Icon'; | ||
import classnames from 'classnames'; | ||
|
||
import { ATO_STATUS_DUE_SOON_DAYS } from 'constants/systemProfile'; | ||
import { AtoStatus } from 'types/systemProfile'; | ||
import { formatDateUtc, parseAsUTC } from 'utils/date'; | ||
|
||
import Tag from '../Tag'; | ||
|
||
/** | ||
* Get the ATO Status from a date property | ||
*/ | ||
export function getAtoStatus(dt: string | null | undefined): AtoStatus { | ||
// No ato if it doesn't exist or invalid empty string | ||
if (typeof dt !== 'string' || dt === '') return 'No ATO'; | ||
|
||
const expiry = parseAsUTC(dt).toString(); | ||
|
||
const date = new Date().toISOString(); | ||
|
||
if (date >= expiry) return 'Expired'; | ||
|
||
const soon = parseAsUTC(expiry) | ||
.minus({ days: ATO_STATUS_DUE_SOON_DAYS }) | ||
.toString(); | ||
|
||
if (date >= soon) return 'Due Soon'; | ||
|
||
return 'Active'; | ||
} | ||
|
||
const atoStatusTagClassNames: Record<AtoStatus, string> = { | ||
Active: 'text-white bg-success-dark', | ||
'Due Soon': 'bg-warning', | ||
Expired: 'text-white bg-error-dark', | ||
'No ATO': 'bg-base-lighter' | ||
}; | ||
|
||
const atoStatusTagIcon: Record<AtoStatus, React.ComponentType<IconProps>> = { | ||
Active: IconCheck, | ||
'Due Soon': IconWarning, | ||
Expired: IconError, | ||
'No ATO': IconHelp | ||
}; | ||
|
||
export function AtoStatusTag({ | ||
status, | ||
className | ||
}: { | ||
status: AtoStatus; | ||
className?: string; | ||
}) { | ||
const Icon = atoStatusTagIcon[status]; | ||
return ( | ||
<Tag className={classnames(`${atoStatusTagClassNames[status]}`, className)}> | ||
<Icon className="margin-right-1" /> | ||
{status} | ||
</Tag> | ||
); | ||
} | ||
|
||
const atoStatusIconClassNames: Record<AtoStatus, string> = { | ||
Active: 'text-success', | ||
'Due Soon': 'text-warning-dark', | ||
Expired: 'text-error', | ||
'No ATO': 'text-base-light' | ||
}; | ||
|
||
const atoStatusIcon: Record<AtoStatus, React.ComponentType<IconProps>> = { | ||
Active: IconCheckCircleOutline, | ||
'Due Soon': IconErrorOutline, | ||
Expired: IconHighlightOff, | ||
'No ATO': IconHelpOutline | ||
}; | ||
|
||
export function AtoStatusIconText({ dt }: { dt: string | null | undefined }) { | ||
const status = getAtoStatus(dt); | ||
const Icon = atoStatusIcon[status]; | ||
const { t } = useTranslation('systemProfile'); | ||
return ( | ||
<div className="display-flex flex-align-center"> | ||
<Icon | ||
size={3} | ||
className={`margin-right-1 ${atoStatusIconClassNames[status]}`} | ||
/> | ||
<span> | ||
{t(`systemTable.atoStatusColumn.${status}`)}{' '} | ||
{formatDateUtc(dt || null, 'MM/yyyy')} | ||
</span> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ export default gql` | |
systemMaintainerOrg | ||
systemMaintainerOrgComp | ||
isBookmarked | ||
atoExpirationDate | ||
} | ||
} | ||
`; |
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ export default gql` | |
systemMaintainerOrg | ||
systemMaintainerOrgComp | ||
isBookmarked | ||
atoExpirationDate | ||
} | ||
} | ||
`; |
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
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
Oops, something went wrong.