-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d25365b
commit c8f62b6
Showing
5 changed files
with
176 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
|
||
import { useChatbot } from '@/domain/contexts/ChatbotContext'; | ||
import { useSnackbar } from '@/domain/contexts/SnackbarContext'; | ||
import { YearInReview } from '@/domain/entities/YearInReview'; | ||
import { PdfFile } from '@/domain/props/PdfViewerProps'; | ||
import YearInReviewReportsProps from '@/domain/props/YearInReviewReportsProps'; | ||
import { DownloadPortalOperations } from '@/operations/download-portal/DownloadPortalOperations'; | ||
|
||
import PdfPreview from '../Pdf/PdfPreview'; | ||
import CustomTable from '../Table/CustomTable'; | ||
|
||
export default function YearInReviewReports({ yearInReviewReports }: YearInReviewReportsProps) { | ||
const [isModalOpen, setModalOpen] = useState(false); | ||
const [pdfFile, setPdfFile] = useState<PdfFile | null>(null); | ||
const [error, setError] = useState<string | null>(null); | ||
const [selectedReport, setSelectedReport] = useState<YearInReview | null>(null); | ||
const { initiateChatAboutReport } = useChatbot(); | ||
const toggleModal = () => setModalOpen((prev) => !prev); | ||
const { showSnackBar } = useSnackbar(); | ||
|
||
return ( | ||
<div> | ||
<CustomTable | ||
columns={DownloadPortalOperations.getColumns()} | ||
data={DownloadPortalOperations.formatYearInReviewTableData( | ||
yearInReviewReports, | ||
setSelectedReport, | ||
initiateChatAboutReport, | ||
setPdfFile, | ||
setError, | ||
toggleModal, | ||
showSnackBar | ||
)} | ||
ariaLabel="Year In Review Reports" | ||
/> | ||
<PdfPreview | ||
isModalOpen={isModalOpen} | ||
toggleModal={toggleModal} | ||
pdfFile={pdfFile} | ||
error={error} | ||
onDownloadPdf={() => { | ||
if (selectedReport) { | ||
DownloadPortalOperations.downloadYearInReview(selectedReport, showSnackBar); | ||
} | ||
}} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { YearInReview } from '../entities/YearInReview'; | ||
|
||
export default interface YearInReviewReportsProps { | ||
yearInReviewReports: YearInReview[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters