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 | 8x 8x 8x 2x 2x 4x 5x 18x 18x 4x 2x 2x 2x 8x 2x 2x 5x 25x 3x | import { useMemo } from "react"; import { opensearch } from "shared-types"; import { ItemResult } from "shared-types/opensearch/changelog"; import { formatDateToET } from "shared-utils"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, DetailsSection, } from "@/components"; import { BLANK_VALUE } from "@/consts"; type AdminChangeProps = { adminActivity: opensearch.changelog.Document; }; const AC_WithdrawEnabled = ({ adminActivity }: AdminChangeProps) => ( <div className="flex flex-col gap-2"> <p className="font-bold">Change made</p> <p> {adminActivity.submitterName} has enabled State package action to withdraw formal RAI response </p> </div> ); const AC_WithdrawDisabled = ({ adminActivity }: AdminChangeProps) => ( <div className="flex flex-col gap-2"> <p className="font-bold">Change made</p> <p> {adminActivity.submitterName} has disabled State package action to withdraw formal RAI response </p> </div> ); const AC_LegacyAdminChange = ({ adminActivity }: AdminChangeProps) => ( <div className="flex flex-col gap-6"> <div> <h2 className="font-bold text-lg mb-2">Change Made</h2> <p>{adminActivity.changeMade || "No information submitted"}</p> </div> {adminActivity.changeReason && ( <div> <h2 className="font-bold text-lg mb-2">Change Reason</h2> <p>{adminActivity.changeReason}</p> </div> )} </div> ); function checkRegexPatterns(input: string): string { // Check which pattern matches const enabledPattern = /enabled.*withdraw Formal RAI Response/; const disabledPattern = /disabled.*withdraw Formal RAI Response/; switch (true) { case enabledPattern.test(input): return "Enable Formal RAI Response Withdraw"; case disabledPattern.test(input): return "Disable Formal RAI Response Withdraw"; default: return ""; } } const AC_Update = () => <p>Coming Soon</p>; export const AdminChange = ({ adminActivity }: AdminChangeProps) => { const [label, Content] = useMemo(() => { switch (adminActivity.event) { case "toggle-withdraw-rai": { if (adminActivity.raiWithdrawEnabled) { return ["Enable Formal RAI Response Withdraw", AC_WithdrawEnabled]; } return ["Disable Formal RAI Response Withdraw", AC_WithdrawDisabled]; } case "NOSO": return [adminActivity.changeType || "Package Added", AC_LegacyAdminChange]; case "legacy-admin-change": return [ checkRegexPatterns(adminActivity.changeMade) || "Manual Update", AC_LegacyAdminChange, ]; case "split-spa": return ["Package Added", AC_LegacyAdminChange]; case "update-id": return ["Manual Update", AC_LegacyAdminChange]; case "update-values": return ["Manual Update", AC_LegacyAdminChange]; default: return [BLANK_VALUE, AC_Update]; } }, [ adminActivity.event, adminActivity.changeType, adminActivity.raiWithdrawEnabled, adminActivity.changeMade, ]); return ( <AccordionItem value={adminActivity.id}> <AccordionTrigger className="bg-gray-100 px-3" showPlusMinus> <p className="flex flex-row gap-2 text-gray-600"> <strong>{label as string}</strong> {" - "} {formatDateToET(adminActivity.timestamp)} </p> </AccordionTrigger> <AccordionContent className="p-4"> <Content adminActivity={adminActivity} /> </AccordionContent> </AccordionItem> ); }; type AdminChangesProps = { changelog: ItemResult[]; }; export const AdminPackageActivities = ({ changelog }: AdminChangesProps) => { const adminChangelog = changelog.filter((item) => item._source.isAdminChange); if (adminChangelog.length === 0) return null; return ( <DetailsSection id="administrative_package_changes" title={`Administrative Package Changes (${adminChangelog.length})`} description="Administrative changes reflect updates to specific data fields. If you have additional questions, please contact the assigned CPOC." > <Accordion // There is a cached value (defaultValue) below // If you ever want to get around the cached value so // that is re-renders simply use a unique key that will // change when you need it to re-render key={adminChangelog[0]._source.id} type="multiple" defaultValue={[adminChangelog[0]._source.id]} className="flex flex-col gap-2" > {adminChangelog.map(({ _source: adminActivity }) => ( <AdminChange key={adminActivity.id} adminActivity={adminActivity} /> ))} </Accordion> </DetailsSection> ); }; |