Skip to content

Tender Review and Posting ITQ/RFQ/EOI/TOR tenders

Key Features:

  1. Tender Review Process:

    • Fetching and displaying detailed tender information based on a unique identifier (tender-id).
    • Managing the approval/review process with status tracking (e.g., Approved, Declined, Pending).
  2. Data Handling:

    • Dynamic updates for tender details, status, and unique status across different components and tabs.
    • Conditional rendering of components and messages based on tender and approval statuses.
  3. Document Management:

    • Generation and display of PDF files (EOI and TOR) for review.
    • Downloading government attachments related to tenders.
  4. Step and Tab Navigation:

    • Switching between tabs (EOI and TOR) with associated data rendering.
    • Editable functionality based on the tender’s current status.
  5. Error Handling and Notifications:

    • Using toast notifications for feedback on actions like approval, decline, or tender posting.
    • Safeguarding against invalid actions with error checks (e.g., missing serial_id).

Key Functionalities:

  1. Data Fetching:

    • Fetching Tender Details:
      • Retrieves data using the tenderService API, including tender details, unique status, and approvers’ status.
    • Fetching PDFs:
      • Uses documentService to generate and fetch PDF files for review (EOI, TOR).

    Example:

    const tenderDetailsResponse = await tenderService.getTenderBySerialId(reviewTenderParam);
    const pdfUrl = await documentService.generatePdfFileTOR(reviewTenderParam);
  2. Approval and Status Management:

    • Tracks approval statuses using the setTenderStatus state.
    • Handles tender approval/decline with comments and updates using updateTenderStatus.

    Example:

    const updateTenderStatus = async (status) => {
    const dataToUpdate = {
    serial_id: tenderDetails?.serial_id,
    status,
    action_taken_by: user,
    comment: comment.trim(),
    };
    await tenderService.updateTender(dataToUpdate);
    };
  3. Dynamic State Updates:

    • Conditionally enables editing or posting of tenders based on their status.
    • Populates approver feedback history and dynamically updates UI components.
  4. Navigation and File Handling:

    • Redirects to appropriate pages (handelEdit and handelPostTender) and downloads files (handelDownload).

Data Fetching and Step Handling:

  1. Flow of Data:

    • The component initializes by fetching the tender-id from query parameters.
    • Uses asynchronous functions to fetch tender details, approval status, and associated data.
    • Processes and updates states like tenderDetails, tenderStatus, and assignReviewersList.
  2. Step and State Management:

    • Approval steps are handled via conditions in the tenderStatus state, including checks for pending or declined statuses.
    • useEffect hooks monitor changes in states like tenderStatus and trigger side effects to update dependent data.

    Example:

    useEffect(() => {
    if (tenderStatus) {
    const hasPending = tenderStatus.result.some(({ status }) => status === 'Pending');
    setEnableEditMode(hasPending);
    }
    }, [tenderStatus]);
  3. Tab Management:

    • Switches between EOI and TOR tabs, loading the appropriate PDF and status details.

    Example:

    const handleTabChange = (tab) => {
    setCurrentTab(tab === 'EOI' ? 0 : 1);
    };

Code Snippet for Reference:

Fetching Tender Details and Updating States:

useEffect(() => {
if (reviewTenderParam) {
const fetchTender = async () => {
setLoadingReview(true);
try {
const tenderDetailsResponse = await tenderService.getTenderBySerialId(reviewTenderParam);
setTenderDetails(tenderDetailsResponse.tender);
const pdfUrl = await documentService.generatePdfFileTOR(reviewTenderParam);
setGeneratedPdf(window.URL.createObjectURL(new Blob([pdfUrl], { type: 'application/pdf' })));
} catch (error) {
console.error('Error fetching tender details:', error);
} finally {
setLoadingReview(false);
}
};
fetchTender();
}
}, [reviewTenderParam]);

This structure ensures efficient data handling, robust error management, and seamless user interaction for the tender review process.