All files / react-app/src/features/package/package-status index.tsx

83.33% Statements 5/6
93.33% Branches 14/15
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56          72x 3x   3x               3x             3x                                                                
import { useGetUser } from "@/api";
import { SEATOOL_STATUS, UserRoles } from "shared-types";
import { DetailCardWrapper } from "..";
import { FC } from "react";
import { ItemResult } from "shared-types/opensearch/main";
export const PackageStatusCard: FC<{ data: ItemResult }> = ({ data }) => {
  const { data: user } = useGetUser();
 
  Iif (!data) return null;
 
  // This really a check to determine if we should show the status of an RAI Withdraw being enabled
  // We have a flag that we monitor but there are certain things that can be done outside of onemac,
  // specifically in seatool that will invalidate the raiWithdrawEnabled flag such as the two statuses
  // below (Pending Approval, and Pending Concurrence). In the future we should build logic into the
  // seatool sink that allows us to simply clear these flags
  const isInRAIWithdrawEnabledSubStatus =
    data._source.raiWithdrawEnabled &&
    data._source.seatoolStatus !== SEATOOL_STATUS.PENDING_APPROVAL &&
    data._source.seatoolStatus !== SEATOOL_STATUS.PENDING_CONCURRENCE;
 
  // Similar to the above check their are certain things that occur in seatool that invalidate the secondClock
  // flag. Additionally second clock sub status only displays for CMS users
  const isInActiveSecondClockStatus =
    user?.isCms &&
    data._source.secondClock &&
    data._source.seatoolStatus !== SEATOOL_STATUS.PENDING_APPROVAL &&
    data._source.seatoolStatus !== SEATOOL_STATUS.PENDING_CONCURRENCE;
 
  return (
    <DetailCardWrapper title={"Status"}>
      <div className="my-3 max-w-2xl font-bold text-xl">
        <div>
          {user?.isCms && !user.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK)
            ? data?._source.cmsStatus
            : data?._source.stateStatus}
        </div>
        <div className="flex mt-1 flex-col gap-1 items-start">
          {isInRAIWithdrawEnabledSubStatus && (
            <div className="flex flex-row gap-1">
              <p className="text-xs font-bold opacity-80">·</p>
              <p className="text-xs opacity-80">Withdraw Formal RAI Response - Enabled</p>
            </div>
          )}
 
          {isInActiveSecondClockStatus && (
            <div className="flex flex-row gap-1">
              <p className="text-xs font-bold opacity-80">·</p>
              <p className="text-xs opacity-80">2nd Clock</p>
            </div>
          )}
        </div>
      </div>
    </DetailCardWrapper>
  );
};