mwangimuringi / zurihomes

Kahawa yetu is a kenya coffee cooperative system.
https://zurihomes.vercel.app
3 stars 1 forks source link

Add API and UI for New Property Listings. #106

Closed mwangimuringi closed 4 days ago

mwangimuringi commented 4 days ago

We need to implement functionality for adding new property listings. This includes:

Backend: Creating an API to handle property listing data (e.g., title, description, price, location).
Frontend: Building a UI to allow users to input property details and submit them to the API.
Integration: Connecting the API with the frontend form and ensuring proper state management and validation.

Tasks:

Create a POST /api/properties route in the backend. Implement a controller to handle property creation, including validation and database insertion. Design a frontend form for adding property details (React/TailwindCSS). Connect the form to the API using fetch or Axios. Add client-side validation for user input. Display success or error messages based on API response.

muringitech commented 4 days ago

What HTTP method should be used for creating new listings, and why?

mwangimuringi commented 4 days ago

POST because it is used for creating new resources on the server.

muringitech commented 4 days ago

1.How should errors like missing fields be handled? 2.How can state be managed for user input and submission results?

mwangimuringi commented 4 days ago

1.On the backend, validate fields and return a 400 Bad Request with error details. On the frontend, display user-friendly messages for required fields. 2.Use React's useState or a state management library like Redux to track form inputs and submission outcomes.