feat(tender-details): enhance document handling and navigation in tender details

- Added a new documents section to the tender details page, improving organization and visibility of related documents.
- Updated the tender navigation items to conditionally include the documents section based on the loading state and document availability.
- Refactored the TenderDetailsContent component to manage document loading states and conditionally render the documents section.
- Enhanced the getTenderNavItems utility to accept options for showing the documents section, improving flexibility in navigation rendering.
This commit is contained in:
AmirReza Jamali
2026-05-13 08:55:40 +03:30
parent d65f8cdf48
commit 2178f25af5
6 changed files with 49 additions and 17 deletions
+15 -5
View File
@@ -41,9 +41,20 @@ const TenderDetails = ({ params }: IProps) => {
];
const tenderForNav = data?.data;
const { data: documentsResponse, isPending: isDocumentsLoading } =
useGetTenderDocumentsQuery(details);
const documents = documentsResponse?.data ?? [];
const showDocumentsSection =
isDocumentsLoading || documents.length > 0;
const tenderNavItems = useMemo(
() => (tenderForNav ? getTenderNavItems(tenderForNav) : []),
[tenderForNav],
() =>
tenderForNav
? getTenderNavItems(tenderForNav, {
showDocuments: showDocumentsSection,
})
: [],
[tenderForNav, showDocumentsSection],
);
const sectionIds = useMemo(
@@ -51,8 +62,6 @@ const TenderDetails = ({ params }: IProps) => {
[tenderNavItems],
);
const activeSectionId = useTenderSectionScrollSpy(sectionIds);
const { data: documentsResponse, isPending: isDocumentsLoading } =
useGetTenderDocumentsQuery(details);
const handleLanguageChange = useCallback(
(event: React.ChangeEvent<HTMLSelectElement>) => {
const nextParams = new URLSearchParams(searchParams.toString());
@@ -108,8 +117,9 @@ const TenderDetails = ({ params }: IProps) => {
tenderNavItems={tenderNavItems}
activeSectionId={activeSectionId}
tenderId={details}
documents={documentsResponse?.data ?? []}
documents={documents}
documentsLoading={isDocumentsLoading}
showDocumentsSection={showDocumentsSection}
/>
</ShowcaseSection>
</>