Skip to content

feat: add Post category field and client-side image compression#285

Closed
Uchechukwu-Ekezie wants to merge 1 commit intogeevapp:mainfrom
Uchechukwu-Ekezie:feat/issues-204-64-category-image-compression
Closed

feat: add Post category field and client-side image compression#285
Uchechukwu-Ekezie wants to merge 1 commit intogeevapp:mainfrom
Uchechukwu-Ekezie:feat/issues-204-64-category-image-compression

Conversation

@Uchechukwu-Ekezie
Copy link
Copy Markdown

Closes #204
Closes #64

What changed

Issue #204 — Add Post category field

  • Added PostCategory enum to schema.prisma with 10 predefined values: electronics, clothing, books, furniture, toys, food, sports, beauty, automotive, other
  • Added category PostCategory? to the Post model with a @@index([category]) for fast filtering
  • Migration file 20260423000000_add_post_category/migration.sql
  • POST /api/posts now accepts and stores category — previously it was silently discarded
  • GET /api/posts?category=electronics filtering was already wired in the handler; it now works against the real DB column

Issue #64 — Client-side image optimisation

  • New lib/image-compression.ts utility powered by browser-image-compression:
    • compressImage() — reduces images to <500 KB at max 1200×1200, outputs WebP when supported (fallback JPEG), quality 82%
    • generateThumbnail() — generates 300×300 thumbnail as both a File and a data URL for instant preview
    • formatFileSize() — human-readable size string
  • Updated MediaUpload component:
    • Images are compressed + thumbnail generated before upload
    • "Optimising…" spinner overlay during compression phase
    • "Uploading…" overlay during transfer phase
    • After upload: per-card savings label (e.g. 1.8 MB → 312 KB (−83%))
    • Toast notification with before/after summary on success
    • Falls back to original file silently on compression error — uploads never break
    • Videos skip compression (unchanged)

How to test

  • Create a post with a category — verify it's stored and returned in GET responses
  • Filter posts with GET /api/posts?category=electronics
  • Upload a large image (>1 MB) — observe the "Optimising…" → "Uploading…" transition and the savings badge

Closes #204
Closes #64

Issue #204 — Post category field
- Add PostCategory enum (electronics, clothing, books, furniture, toys,
  food, sports, beauty, automotive, other) to schema.prisma
- Add optional category field to Post model with @@index for fast filtering
- Migration: 20260423000000_add_post_category
- POST /api/posts now accepts and stores category
- GET /api/posts already filtered by ?category= — now backed by the real field

Issue #64 — Client-side image optimisation
- New lib/image-compression.ts: compressImage() (max 0.5 MB / 1200×1200,
  WebP when supported, fallback JPEG), generateThumbnail() (300×300),
  formatFileSize() helper — all powered by browser-image-compression
- Updated MediaUpload component:
  - Images compressed + thumbnail generated before upload
  - "Optimising…" overlay during compression, "Uploading…" during transfer
  - After upload: before/after size badge ("1.8 MB → 312 KB (−83%)")
  - Toast notification with savings summary
  - Falls back to original file on compression error

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

@Uchechukwu-Ekezie Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Uchechukwu-Ekezie
Copy link
Copy Markdown
Author

Superseded — PR will be raised against OpenSourceCOntr/geev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Post category field to schema — referenced in forms but missing from model Feature: Implement client-side image optimization and compression

1 participant