Skip to content

feat: implement Announcement Dashboard/Page #108

@harshitap1305

Description

@harshitap1305

Description

Currently, there is no centralized system for broadcasting information to users. Important updates regarding events, club activities, or general news are likely communicated through disparate channels. This feature introduces a dedicated Announcement Dashboard to serve as a single source of truth for all official communications within the platform.

This system will allow authorized users (like club heads, event organizers, or admins) to create, manage, and display announcements. General users will be able to view these announcements on a dedicated dashboard, with options to filter and see context-specific information.

Key Features & Acceptance Criteria

1. Backend

  • Create Announcement Schema: A new Mongoose model should be created to store announcements. See the suggested schema below.
  • CRUD API Endpoints: Develop a full set of RESTful endpoints for announcements:
    • POST /api/announcements - Create a new announcement.
    • GET /api/announcements - Fetch all announcements, with support for filtering.
    • GET /api/announcements/:id - Fetch a single announcement by its ID.
    • PUT /api/announcements/:id - Update an existing announcement.
    • DELETE /api/announcements/:id - Delete an announcement.
  • Association Logic: The system must support associating an announcement with other models (Event, Organizational_Unit, Position_Holder) or classifying it as 'General'.
  • Filtering: The GET /api/announcements endpoint should support query parameters for filtering, e.g., ?unit_id=<unitId>, ?event_id=<eventId>, ?type=general.

2. Frontend

  • Dashboard UI: Create a new page/component (/announcements) that displays a feed of all announcements in reverse chronological order.
  • Announcement Card Component: Each announcement in the feed should clearly display its title, content, author, date, and the associated entity (e.g., "Posted by: Coding Club").
  • Creation Form/Modal: For authorized users, provide a form to create new announcements. The form should include fields for title, content, and selecting an associated entity (if applicable).
  • Filtering UI: Implement UI elements (like dropdowns or tabs) to allow users to filter the announcements based on the associated entity (e.g., "All", "General", "Clubs", "Events").

Proposed Database Schema

A new collection, announcements, is required.

// announcementSchema
const announcementSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true,
  },
  content: {
    type: String,
    required: true,
  },
  author: { // The user who created the announcement
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    required: true,
  },
  type: { // The category of the announcement
    type: String,
    enum: ['General', 'Event', 'OrganizationalUnit', 'Position',],
    required: true,
  },
  target_id: { // The ID of the associated entity, if not 'General'
    type: mongoose.Schema.Types.ObjectId,
    refPath: 'type', // Dynamically references the model in 'type' field
  },
is_pinned: { // To keep important announcements at the top
    type: Boolean,
    default: false,
  },
  created_at: {
    type: Date,
    default: Date.now,
  },
  updated_at: {
    type: Date,
    default: Date.now,
  },
});

Note: refPath is a powerful Mongoose feature that allows for dynamic references based on the value of another field in the same document.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions