Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): clicking on side links refreshed page and dismissed banner #621

Merged
merged 7 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const AdminChanges = () => {

return (
<DetailsSection
id="administrative_package_changess"
id="administrative_package_changes"
title={`Administrative Package Changes (${data?.length})`}
description="Administrative changes reflect updates to specific data fields. If you have additional questions, please contact the assigned CPOC."
>
Expand Down
20 changes: 11 additions & 9 deletions src/services/ui/src/features/package/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useGetItem } from "@/api";
import { removeUnderscoresAndCapitalize } from "@/utils";
import { useLayoutEffect, useState } from "react";

export type DetailsSidebarLink = {
Expand All @@ -16,19 +15,22 @@ export const useDetailsSidebarLinks = (

useLayoutEffect(() => {
const ids = [
"package_detailss",
"package_activity",
"administrative_package_changess",
{ id: "package_details", label: "Package Details" },
{ id: "package_activity", label: "Package Activity" },
{
id: "administrative_package_changes",
label: "Administrative Package Changes",
},
asharonbaltazar marked this conversation as resolved.
Show resolved Hide resolved
];

// Check if dataId is not undefined before proceeding
if (data?._id) {
const links = ids
.filter((id) => document.getElementById(id) != null)
.map((id) => ({
id,
href: `?id=${encodeURIComponent(dataId)}#${id}`,
displayName: removeUnderscoresAndCapitalize(id),
.filter(({ id }) => document.getElementById(id) !== null)
.map((link) => ({
id: link.id,
href: `#${link.id}`,
displayName: link.label,
}));

setSideBarLinks(links);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@ export const PackageDetails: FC<{
title: string;
}> = (props) => {
const { data } = usePackageDetailsCache();
// const title = props.title || `${data.authority} Package Details`;

// andies thoughts:
// abstract out the grid container from the Details Item Grid components
// instead make the items just the "cells in the grid"
// add some sort of logic for the description to conditionally make it take up 2 cells
// ^ if it takes up 2 cells it must be on its own row
asharonbaltazar marked this conversation as resolved.
Show resolved Hide resolved
return (
<DetailsSection id="package_detailss" title={props.title}>
<DetailsSection id="package_details" title={props.title}>
<div className="flex-col gap-4 max-w-2xl">
<DetailItemsGrid
displayItems={[
Expand All @@ -63,7 +57,6 @@ export const PackageDetails: FC<{
]}
containerStyle="py-4"
/>
{/* <DetailItemsGrid displayItems={descriptionDetails(data)} fullWidth /> */}
<hr className="my-4" />
<DetailItemsGrid displayItems={submissionDetails(data)} />
<AppK />
Expand Down
Loading