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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | 5x 4x 4x 4x 4x 5x 24x 24x 24x 24x 2x 22x 5x 24x 24x 5x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x | import { ReactNode, useState } from "react";
import { Authority, opensearch, SEATOOL_STATUS } from "shared-types";
import {
formatActionType,
formatDateToET,
formatDateToUTC,
isCmsUser,
isHelpDeskUser,
isStateUser,
} from "shared-utils";
import { OneMacUser } from "@/api/useGetUser";
import { BLANK_VALUE } from "@/consts";
import { convertStateAbbrToFullName } from "@/utils";
type ReviewTeamListProps = {
reviewTeam: opensearch.main.Document["reviewTeam"];
};
const ReviewTeamList = ({ reviewTeam = [] }: ReviewTeamListProps) => {
const [isExpanded, setIsExpanded] = useState(false);
const displayTeam = isExpanded ? reviewTeam : reviewTeam.slice(0, 3);
Eif (displayTeam.length === 0) {
return BLANK_VALUE;
}
return (
<ul>
{displayTeam.map((reviewer, idx) => (
<li key={`reviewteam-ul-${reviewer.name}-${idx}`}>{reviewer.name}</li>
))}
{reviewTeam.length > 3 && (
<li className={"text-xs text-sky-700 hover:cursor-pointer"}>
<button onClick={() => setIsExpanded(!isExpanded)}>
{isExpanded ? "Show less" : "Show more"}
</button>
</li>
)}
</ul>
);
};
export type LabelAndValue = {
label: string;
value: ReactNode;
canView?: boolean;
};
type GetLabelAndValueFromSubmission = (
submission: opensearch.main.Document,
user: OneMacUser,
chipFlagEnabled: boolean,
) => LabelAndValue[];
const getDraftWaiverNumber = (submission: opensearch.main.Document) => {
const draftData = submission.draft?.data as Record<string, unknown> | undefined;
const nestedWaiverNumber = (
draftData?.ids as { validAuthority?: { waiverNumber?: unknown } } | undefined
)?.validAuthority?.waiverNumber;
const directWaiverNumber = draftData?.waiverNumber;
if (typeof nestedWaiverNumber === "string" && nestedWaiverNumber.trim()) {
return nestedWaiverNumber;
}
return typeof directWaiverNumber === "string" && directWaiverNumber.trim()
? directWaiverNumber
: undefined;
};
const getDraftTitle = (submission: opensearch.main.Document) => {
const draftTitle = submission.draft?.data?.title;
return typeof draftTitle === "string" && draftTitle.trim() ? draftTitle : undefined;
};
export const getSubmissionDetails: GetLabelAndValueFromSubmission = (
submission,
{ user },
chipFlagEnabled,
) => {
const isEligibilityChipSubmissionType = submission.event === "new-chip-details-submission";
const chipSubmissionTypeFromDraftData = submission.draft?.data?.chipSubmissionType;
const hasChipSubmissionType =
(Array.isArray(submission.chipSubmissionType) && submission.chipSubmissionType.length > 0) ||
(Array.isArray(chipSubmissionTypeFromDraftData) && chipSubmissionTypeFromDraftData.length > 0);
const amendmentTitle = submission.title ?? getDraftTitle(submission);
const shouldShowAmendmentTitle = submission.event === "app-k" || amendmentTitle !== undefined;
let chipSubmissionValue = (
<span className="break-words">{submission.chipSubmissionType?.join(", ")}</span>
);
Iif (
Array.isArray(chipSubmissionTypeFromDraftData) &&
chipSubmissionTypeFromDraftData.length > 0
) {
chipSubmissionValue = (
<span className="break-words">{chipSubmissionTypeFromDraftData.join(", ")}</span>
);
}
const chipSubmissionTypeField: LabelAndValue[] =
chipFlagEnabled && (isEligibilityChipSubmissionType || hasChipSubmissionType)
? [
{
label: "CHIP Submission Type",
value: hasChipSubmissionType ? (
chipSubmissionValue
) : (
<span className="italic text-gray-500">{BLANK_VALUE}</span>
),
},
]
: [];
return [
{
label: "Submission ID",
value: submission.id,
},
{
label: "Authority",
value: submission.authority,
},
{
label: "Action Type",
value: formatActionType(submission.actionType),
canView: ([Authority["1915b"], Authority["1915c"]] as string[]).includes(
submission.authority,
),
},
{
label: "State",
value: convertStateAbbrToFullName(submission.state),
},
{
label: "Amendment Title",
value: amendmentTitle ?? BLANK_VALUE,
canView: shouldShowAmendmentTitle,
},
{
label: "Subject",
value: submission.subject || BLANK_VALUE,
canView: isCmsUser(user) && submission.actionType !== "Extend",
},
{
label: "Type",
value:
submission.types && submission.types.length ? (
<ul className="list-disc list-outside pl-5">
{submission.types
.filter((type) => type?.SPA_TYPE_ID && type?.SPA_TYPE_NAME)
.map((type) => (
<li className="mb-2" key={type?.SPA_TYPE_ID}>
{type?.SPA_TYPE_NAME}
</li>
))}
</ul>
) : (
BLANK_VALUE
),
canView: submission.actionType !== "Extend" && isStateUser(user) === false,
},
{
label: "Subtype",
value:
submission.subTypes && submission.subTypes.length ? (
<ul className="list-disc list-outside pl-5">
{submission.subTypes
.filter((T) => T?.TYPE_ID && T?.TYPE_NAME)
.map((T) => (
<li className="mb-2" key={T?.TYPE_ID}>
{T?.TYPE_NAME}
</li>
))}
</ul>
) : (
BLANK_VALUE
),
canView: submission.actionType !== "Extend" && isStateUser(user) === false,
},
{
label: "Approved Initial or Renewal Number",
value: submission.originalWaiverNumber ?? getDraftWaiverNumber(submission) ?? BLANK_VALUE,
canView: submission.actionType === "Extend",
},
...chipSubmissionTypeField,
{
label: "Initial Submission Date",
value: submission.submissionDate ? formatDateToET(submission.submissionDate) : BLANK_VALUE,
},
{
label: "Latest Package Activity",
value: submission.makoChangedDate ? formatDateToET(submission.makoChangedDate) : BLANK_VALUE,
},
{
label: "Formal RAI Response Date",
value: submission.raiReceivedDate ? formatDateToET(submission.raiReceivedDate) : BLANK_VALUE,
canView: submission.actionType !== "Extend",
},
];
};
export const getApprovedAndEffectiveDetails: GetLabelAndValueFromSubmission = (submission) => [
{
label: "Final Disposition Date",
value: submission.finalDispositionDate
? formatDateToUTC(submission.finalDispositionDate)
: BLANK_VALUE,
canView: submission.actionType !== "Extend",
},
{
label: "Proposed Effective Date",
value: (() => {
const proposedDateFromDraftData = submission.draft?.data?.proposedEffectiveDate;
const draftDateValue =
typeof proposedDateFromDraftData === "string" ||
typeof proposedDateFromDraftData === "number"
? proposedDateFromDraftData
: undefined;
const effectiveDate = submission.proposedDate ?? draftDateValue;
return effectiveDate ? formatDateToUTC(effectiveDate) : "-- --";
})(),
canView: submission.actionType !== "Extend",
},
{
label: "Approved Effective Date",
value: submission.approvedEffectiveDate
? formatDateToUTC(submission.approvedEffectiveDate)
: BLANK_VALUE,
canView: submission.actionType !== "Extend",
},
];
export const getDescriptionDetails: GetLabelAndValueFromSubmission = (submission, { user }) => [
{
label: "Description",
value: submission.description || BLANK_VALUE,
canView: isCmsUser(user) && submission.actionType !== "Extend",
},
];
export const getSubmittedByDetails: GetLabelAndValueFromSubmission = (submission, { user }) => [
//possibly add details new drop down here
...(() => {
const isDraft = submission.seatoolStatus === SEATOOL_STATUS.DRAFT;
const createdByName =
submission.draft?.createdByName ??
submission.draft?.draftOwnerName ??
submission.submitterName;
const canViewCreatedBy = isDraft ? isStateUser(user) || isHelpDeskUser(user) : true;
return [
{
label: isDraft ? "Created By" : "Submitted By",
value: (
<p className="text-lg">
{(isDraft ? createdByName : submission.submitterName) || BLANK_VALUE}
</p>
),
canView: canViewCreatedBy,
},
{
label: "CPOC",
value: <p className="text-lg">{submission.leadAnalystName || BLANK_VALUE}</p>,
canView: submission.actionType !== "Extend",
},
{
label: "SRT",
value: <ReviewTeamList reviewTeam={submission.reviewTeam} />,
canView: isCmsUser(user) && submission.actionType !== "Extend",
},
];
})(),
];
|