Skip to content

Commit

Permalink
feat(ui): show 1915(c) Appendix K Package Details for withdrawn child…
Browse files Browse the repository at this point in the history
…ren (#671)

* chore: move `title` into `PackageDetails`

* chore: remove redundant hook cache call

* feat: add `appkParent` to withdrawing Appk child

* feat: add `wasAppkChild` property to withdrawn children

* chore: tidy up types and braces

* Revert "feat: add `wasAppkChild` property to withdrawn children"

This reverts commit 7de7b5a.

* chore: update `appkParent` title

* fix: use correct URL for parent appks in Package Activity

* chore: remove unused property
  • Loading branch information
asharonbaltazar authored Jul 31, 2024
1 parent 8a986b7 commit 37175e4
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ export const transform = (id: string) => {
changedDate: getDateStringOrNullFromEpoc(data.changedDate),
subject: null,
description: null,
makoChangedDate: !!data.timestamp
? new Date(data.timestamp).toISOString()
: null,
makoChangedDate:
typeof data.timestamp === "number"
? new Date(data.timestamp).toISOString()
: null,
// ----------
};
} else {
Expand All @@ -72,9 +73,10 @@ export const transform = (id: string) => {
submitterName:
data.submitterName === "-- --" ? null : data.submitterName,
origin: "OneMAC",
makoChangedDate: !!data.timestamp
? new Date(data.timestamp).toISOString()
: null,
makoChangedDate:
typeof data.timestamp === "number"
? new Date(data.timestamp).toISOString()
: null,
};
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const transform = (id: string) => {
return {
id,
appkParentId: null,
makoChangedDate: !!data.timestamp
appkParent: true,
makoChangedDate: data.timestamp
? new Date(data.timestamp).toISOString()
: null,
};
Expand Down
17 changes: 1 addition & 16 deletions src/services/ui/src/features/package/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@ export const DetailsContent: FC<{ id: string }> = ({ id }) => {
if (isLoading) return <LoadingSpinner />;
if (!data?._source) return <LoadingSpinner />;
if (error) return <ErrorAlert error={error} />;
const title =
(() => {
switch (data._source.authority) {
case Authority["1915b"]:
case Authority["1915c"]:
case undefined: // Some TEs have no authority
if (data._source.appkParent)
return "Appendix K Amendment Package Details";
else if (data._source.actionType == "Extend")
return "Temporary Extension Request Details";
else return undefined;
default:
return undefined;
}
})() || `${data._source.authority} Package Details`;

return (
<div className="w-full py-1 px-4 lg:px-8">
Expand All @@ -61,7 +46,7 @@ export const DetailsContent: FC<{ id: string }> = ({ id }) => {
<PackageActionsCard id={id} />
</section>
<div className="flex flex-col gap-3">
<PackageDetails title={title} />
<PackageDetails itemResult={data} />
<PackageActivities />
<AdminChanges />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
import * as Table from "@/components";
import { BLANK_VALUE } from "@/consts";
import { usePackageActivities, useAttachmentService } from "./hook";
import { Link } from "@/components/Routing";
import { attachmentTitleMap } from "shared-types";
import { Link } from "react-router-dom";

// id, attachments, hook
const AttachmentDetails: FC<{
Expand Down Expand Up @@ -54,8 +54,7 @@ export const PA_AppkParentRemovedChild: FC<opensearch.changelog.Document> = (
return (
<div className="flex gap-1">
<Link
path="/details"
query={{ id: props.appkChildId }}
to={`/details/${props.authority}/${props.appkChildId}`}
className="hover:underline font-semibold text-blue-600"
>
{props.appkChildId}
Expand All @@ -72,8 +71,7 @@ export const PA_AppkChildRemovedFromParent: FC<
<div className="flex gap-1">
<p>Removed from:</p>
<Link
path="/details"
query={{ id: props.appkParentId }}
to={`/details/${props.authority}/${props.appkParentId}`}
className="hover:underline font-semibold text-blue-600"
>
{props.appkParentId}
Expand Down
38 changes: 27 additions & 11 deletions src/services/ui/src/features/package/package-details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import {
submissionDetails,
} from "./hooks";

import { FC } from "react";
import { FC, useMemo } from "react";

import { DetailSectionItem } from "./hooks";
import { useGetUser } from "@/api/useGetUser";
import { AppK } from "./appk";
import { cn } from "@/utils";
import { usePackageDetailsCache } from "..";
import { Authority } from "shared-types";
import { ItemResult } from "shared-types/opensearch/main";

export const DetailItemsGrid: FC<{
displayItems: DetailSectionItem[];
Expand Down Expand Up @@ -41,24 +42,39 @@ export const DetailItemsGrid: FC<{
);
};

export const PackageDetails: FC<{
title: string;
}> = (props) => {
const { data } = usePackageDetailsCache();
type PackageDetailsProps = {
itemResult: ItemResult;
};

export const PackageDetails = ({ itemResult }: PackageDetailsProps) => {
const title = useMemo(() => {
const { _source: source } = itemResult;

switch (source.authority) {
case Authority["1915b"]:
case Authority["1915c"]:
case undefined: // Some TEs have no authority
if (source.appkParent) return "1915(c) Appendix K Package Details";
if (source.actionType == "Extend")
return "Temporary Extension Request Details";
}

return `${source.authority} Package Details`;
}, [itemResult]);

return (
<DetailsSection id="package_details" title={props.title}>
<DetailsSection id="package_details" title={title}>
<div className="flex-col gap-4 max-w-2xl">
<DetailItemsGrid
displayItems={[
...recordDetails(data),
...approvedAndAEffectiveDetails(data),
...descriptionDetails(data),
...recordDetails(itemResult._source),
...approvedAndAEffectiveDetails(itemResult._source),
...descriptionDetails(itemResult._source),
]}
containerStyle="py-4"
/>
<hr className="my-4" />
<DetailItemsGrid displayItems={submissionDetails(data)} />
<DetailItemsGrid displayItems={submissionDetails(itemResult._source)} />
<AppK />
</div>
</DetailsSection>
Expand Down

0 comments on commit 37175e4

Please sign in to comment.