Publications & Notices
Overview
The Publications & Notices module provides a robust system for managing and displaying institutional documents, curriculum details, academic calendars, and official notices. It is designed to allow users to browse documents through a categorized tab system and securely download files for offline use.
The system is split into two primary entities:
- Categories: Logical groupings such as "Notices," "Curriculum," "Research Papers," or "Annual Reports."
- Publications: Individual entries containing metadata (title, description) and associated downloadable files.
User Interface & Features
Categorized Navigation
The front-end is designed to fetch categories dynamically. Users can filter publications by selecting specific tabs. This is achieved by calling getPublicationCategory() to populate the UI tabs and getPublicationByCategoryId(id) to update the document list when a tab is selected.
Document Downloads
The system handles file delivery through a specialized download utility. When a user clicks a "Download" button, the downloadPublicationFile function interacts with the backend to fetch the file as a Blob and triggers a browser-level download.
import { downloadPublicationFile } from './path/to/publicationApi';
// Example usage in a component
const handleDownload = (filename) => {
downloadPublicationFile(filename);
};
API Reference
The publicationApi.js module provides the following functions to interact with the publication system.
Fetching Content
getAllpublication()
Retrieves all available publications across all categories.
- Returns:
Promise<Array>- A list of publication objects.
getPublicationByCategoryId(id)
Retrieves publications filtered by a specific category ID. This is the primary function used for tab-based navigation.
- Parameters:
id(String) - The unique identifier of the category. - Returns:
Promise<Array>- A list of publications belonging to that category.
getPublicationCategory()
Retrieves the list of available categories to populate navigation menus or tabs.
- Returns:
Promise<Array>- An array of category objects (e.g.,{ id, categoryName, status }).
File Interaction
downloadPublicationFile(filename)
Initiates a secure file download from the server.
- Parameters:
filename(String) - The name of the file stored on the server. - Process:
- Fetches the file via a
GETrequest. - Converts the response into a
Blob. - Creates a temporary URL and triggers an anchor tag click.
- Cleans up the temporary URL.
- Fetches the file via a
Management (Administrative)
Management functions require a valid administrative token stored in localStorage under authToken.
| Function | Method | Description |
| :--- | :--- | :--- |
| addPublication(data) | POST | Adds a new publication with an optional file. |
| updatePublicationById(id, data) | PATCH | Updates publication metadata or replaces a file. |
| deletePublication(id) | DELETE | Removes a publication from the system. |
| addPublicationCategory(data) | POST | Creates a new category for organizing publications. |
Request Headers
All management functions automatically include the following header if a token is present:
{
'Authorization': `Bearer ${token}`
}
Data Structure Examples
Publication Object
{
"_id": "64f123...",
"title": "Semester Exam Schedule",
"description": "Final exam schedule for Fall 2024",
"file": "schedule_102.pdf",
"category": "64f456...",
"status": true,
"createdAt": "2024-08-20T..."
}
Category Object
{
"_id": "64f456...",
"categoryName": "Exams",
"status": true
}
Implementation Notes
- Private Access: Routes for adding or editing publications are protected by the
PrivateRoutes.jsxwrapper, ensuring only authorized roles can access the Content Management System (CMS). - Environment Variables: The API base URL and file storage paths are configured via
VITE_API_URLandVITE_FILE_URL.