Skip to content

Commit

Permalink
fix(substatus and 2nd clock): Correct rai resp withdraw enabled subst…
Browse files Browse the repository at this point in the history
…atus logic, as well as 2nd clock display (#345)

* Fix up sub statuses and 2nd clocks

* add pauls comment

* Revert "add pauls comment"

This reverts commit a157972.

* pass stuff explicitly

* Correct logic for dashboard

* new line

* Correct export for reviewer

* Correct logic around exports

* Clear 2nd clock when an rai is withdrawn

* UPPERCASE
  • Loading branch information
mdial89f authored Jan 25, 2024
1 parent 3ba6571 commit d80d5b2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 18 deletions.
27 changes: 27 additions & 0 deletions src/packages/shared-types/opensearch/main/transforms/seatool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@ const getFinalDispositionDate = (status: string, record: SeaTool) => {
: null;
};

const isInSecondClock = (
raiReceivedDate: any,
raiWithdrawnDate: any,
seatoolStatus: any,
authority: any
) => {
if (
authority != "CHIP" && // if it's not a chip
[
SEATOOL_STATUS.PENDING,
SEATOOL_STATUS.PENDING_CONCURRENCE,
SEATOOL_STATUS.PENDING_APPROVAL,
].includes(seatoolStatus) && // if it's in pending
raiReceivedDate && // if its latest rai has a received date
!raiWithdrawnDate // if the latest rai has not been withdrawn
) {
return true; // then we're in second clock
}
return false; // otherwise, we're not
};

export const transform = (id: string) => {
return seatoolSchema.transform((data) => {
const { leadAnalystName, leadAnalystOfficerId } = getLeadAnalyst(data);
Expand Down Expand Up @@ -138,6 +159,12 @@ export const transform = (id: string) => {
data.STATE_PLAN.SUBMISSION_DATE
),
subject: data.STATE_PLAN.TITLE_NAME,
secondClock: isInSecondClock(
raiReceivedDate,
raiWithdrawnDate,
seatoolStatus,
authorityLookup(data.STATE_PLAN.PLAN_TYPE)
),
};
});
};
Expand Down
21 changes: 13 additions & 8 deletions src/services/ui/src/components/Opensearch/main/Filtering/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,22 @@ export const EXPORT_GROUPS = (
{
name: "Status",
transform(data) {
if (user?.data?.isCms && !user?.data?.user) {
if (data.cmsStatus) {
const status = (() => {
if (user?.data?.isCms) {
if (
user?.data.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK)
) {
return data.stateStatus;
}
return data.cmsStatus;
}
return BLANK_VALUE;
} else {
if (data.stateStatus) {
} else {
return data.stateStatus;
}
return BLANK_VALUE;
}
})();
const subStatus = data.raiWithdrawEnabled
? " (Withdraw Formal RAI Response - Enabled)"
: null;
return subStatus ? status + subStatus : status;
},
},
{
Expand Down
25 changes: 19 additions & 6 deletions src/services/ui/src/pages/dashboard/Lists/spas/consts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
renderCellIdLink,
} from "../renderCells";
import { BLANK_VALUE } from "@/consts";
import { formatSeatoolDate } from "shared-utils";
import { formatSeatoolDate, isCmsReadonlyUser } from "shared-utils";

export const useSpaTableColumns = (): OsTableColumn[] => {
const { data: props } = useGetUser();
Expand Down Expand Up @@ -40,11 +40,24 @@ export const useSpaTableColumns = (): OsTableColumn[] => {
{
field: props?.isCms ? "cmsStatus.keyword" : "stateStatus.keyword",
label: "Status",
cell: (data) =>
props?.isCms &&
!(props.user?.["custom:cms-roles"] === UserRoles.HELPDESK)
? data.cmsStatus
: data.stateStatus,
cell: (data) => {
const status = (() => {
if (!props?.isCms) return data.stateStatus;
if (props.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK))
return data.stateStatus;
return data.cmsStatus;
})();

const subStatus = data.raiWithdrawEnabled
? "Withdraw Formal RAI Response - Enabled"
: null;
return (
<>
<p>{status}</p>
{!!subStatus && <p className="text-xs opacity-60">{subStatus}</p>}
</>
);
},
},
{
field: "submissionDate",
Expand Down
7 changes: 3 additions & 4 deletions src/services/ui/src/pages/detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const DetailCardWrapper = ({
);
const StatusCard = (data: opensearch.main.Document) => {
const transformedStatuses = getStatus(data.seatoolStatus);
const checker = PackageCheck(data);
const { data: user } = useGetUser();

return (
Expand All @@ -52,14 +51,14 @@ const StatusCard = (data: opensearch.main.Document) => {
? transformedStatuses.cmsStatus
: transformedStatuses.stateStatus}
</h2>
{checker.hasEnabledRaiWithdraw && (
{data.raiWithdrawEnabled && (
<em className="text-xs my-4 mr-2">
{"Withdraw Formal RAI Response - Enabled"}
</em>
)}
{user?.isCms && checker.isInSecondClock && (
{user?.isCms && data.secondClock && (
<span id="secondclock" className="ml-2">
2nd Clock
<br></br>2nd Clock
</span>
)}
</div>
Expand Down

0 comments on commit d80d5b2

Please sign in to comment.