Skip to content

Check Paper in DB before submitting request paper and also check paperRequest collection to check already user has requested or not #485

@YOGESH-08

Description

@YOGESH-08

Is your feature request related to a problem? Please describe.

Yes. Currently, the "Request Paper" functionality does not check if a paper already exists in the database before allowing a user to submit a request. This leads to:

  1. Redundant Data: Duplicate requests for the same paper are stored in the database.
  2. Poor User Experience: Users might request a paper that is already available on the platform without realizing it.
  3. Manual Overload: Admins have to manually filter out requests for papers they already have.

Describe the solution you'd like

Implement a validation layer in the paper request workflow:

  1. Server-side Validation: Update src/app/api/request/route.ts to check Paper and Admin matching collections (subject, exam, slot, year) before creating a request.
  2. Duplicate Prevention: Prevent the creation of a new PaperRequest if an identical one already exists.
  3. Graceful Error Handling: Return specific status codes (e.g., 409 Conflict) so the frontend can distinguish between "already exists in library" and "already requested".
  4. Enhanced UI: Update RequestModal and the PaperRequest page to show helpful messages and a "View Paper" button if it's already available.

Additional context

  • Relevant files: src/app/api/request/route.ts, src/app/request/page.tsx, src/components/ui/RequestModal.tsx.
  • Database Models: Paper, PaperAdmin, PaperRequest.
  • Goals: Help maintain a clean database and improve user journey.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions