Social
The social feature provides a feed of posts, with the ability to create, edit, delete, like, and comment on posts. The main feed is available at /social and is protected: users must be logged in (email and password) to access it.
Feed
The feed is implemented by SocialPostList (src/features/social/components/social-post-list.tsx). It loads posts in pages using listPostsApi, which calls GET /posts?page=&limit=. Each post is rendered as a SocialPostCard with author, content, media (image or video), like count, comment count, and actions (like, comment, edit, delete).
Post Types
Posts can be one of three types:
- Text — Content only (1–1000 characters).
- Photo — Content plus one or more images (uploaded as files).
- Video — Content plus one video file (or URL when supported).
Validation is defined in src/features/social/validations/create-post.schema.ts: content is required and trimmed; photo type requires at least one image; video type requires a video file (or URL where applicable).
Actions on Posts
- Like / Unlike — Toggle via
toggleLikeApi(POST /posts/:id/likeor.../unlike). - Comment — Users can add comments; the frontend calls
POST /commentswithpostIdandcontent(max 100 characters). - Edit — Navigate to
/social/edit/[id]; updates are sent withPUT /posts/:id. - Delete — Confirmation dialog then
DELETE /posts/:id.
API Summary
Endpoints used by the social feature:
GET /posts— Paginated list (query:page,limit).GET /posts/:id— Single post detail.POST /posts— Create post (multipart/form-data:content,mediafor images/video).PUT /posts/:id— Update post.DELETE /posts/:id— Delete post.POST /posts/:id/like— Like a post.POST /posts/:id/unlike— Remove like.POST /comments— Create comment (body:postId,content).
For more detail on creating and editing posts (form, validation, media upload), see Posts.