Skip to content

Add Resource Type to Upload Flow #31

@joshuapanicker

Description

@joshuapanicker

Feature

Add resource type selection to the upload form and store it in the database. The PRD specifies four resource types: Lecture Notes, Study Guide, Class Overview, and Link. Each type earns different credits upon approval.

Step-by-Step Instructions:

  1. Check if database column exists:

    -- Run this query in Supabase SQL editor
    SELECT column_name, data_type 
    FROM information_schema.columns 
    WHERE table_name = 'resources' AND column_name = 'resource_type';
    • If column doesn't exist, create migration first:
      ALTER TABLE public.resources ADD COLUMN resource_type text;
      ALTER TABLE public.resources ADD CONSTRAINT check_resource_type 
        CHECK (resource_type IN ('lecture_notes', 'study_guide', 'class_overview', 'link'));
  2. Add resource type dropdown to upload form:

    • In the upload form component (Issue Note Uploading #4)
    • Add dropdown with options: "Lecture Notes", "Study Guide", "Class Overview", "Link"
    • Make it a required field
    • Store selected value in form state
  3. Send resource type to API:

    • Add resource_type to FormData when submitting upload
    • Map display names to database values:
      • "Lecture Notes" → "lecture_notes"
      • "Study Guide" → "study_guide"
      • "Class Overview" → "class_overview"
      • "Link" → "link"
  4. Update upload API to accept and validate resource type:

    • Extract resource_type from FormData
    • Validate against allowed values
    • Store in database insert statement
    • Return error if invalid type
  5. Test:

    • Upload with each resource type
    • Verify type is stored correctly in database
    • Verify invalid types are rejected

Acceptance criteria

  • Upload form includes resource type dropdown
  • Resource type is sent to /api/upload endpoint in FormData
  • Upload API validates resource type and stores it in database
  • Resource type is stored in resources.resource_type column

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions