@lendrik-kumar LOGIC OF FULL SELLER DASHBOARD PLEASE FOLLOW THIS LOGIC Bhai yeh raha Logic that i have made in Frontend and I want you to Provide in Backend #41
namansh70747
started this conversation in
General
Replies: 2 comments
-
|
SCREEN SHOT BHI HAI OR |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Purpose: Retrieve all items listed by the authenticated user (along with their approval status)
Request:
Headers:
Authorization:
Method: GET
Backend Logic:
Authenticate user using JWT token
Query database for all "Requests" (listings) associated with the user
Return requests with their linked Items
Sample Response:
json
Copy
[
{
"ID": 123,
"Item": {
"ID": 456,
"Title": "Used Textbook",
"Description": "Like new condition",
"Price": 500.00,
"Image": "base64string",
"Type": "sell",
"SellerID": 789
},
"Status": "pending"
}
]
2. POST /items - Create New Item Listing
Purpose: Submit a new item for listing (creates item + listing request)
Request:
Headers:
Authorization:
Content-Type: application/json
Body:
json
Copy
{
"title": "Item Title",
"description": "Item Description",
"price": 1000.00,
"image": "base64string",
"type": "sell"
}
Backend Logic:
Authenticate user using JWT token
Create new Item in database:
Store image as base64 string or upload to cloud storage
Set seller_id to authenticated user's ID
Create new Request entry:
status: "pending"
item_id: newly created item's ID
seller_id: user's ID
Return 201 Created status on success
Response:
Status Code: 201 Created
Body: Created item object (optional)
Database Schema Suggestions
Items Table:
sql
Copy
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
description TEXT NOT NULL,
price DECIMAL(10,2),
image TEXT,
type ENUM('sell', 'exchange') NOT NULL,
seller_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Requests Table (Listings/Approvals):
sql
Copy
CREATE TABLE requests (
id INT PRIMARY KEY AUTO_INCREMENT,
item_id INT NOT NULL,
seller_id INT NOT NULL,
status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending',
admin_id INT,
reviewed_at TIMESTAMP,
FOREIGN KEY (item_id) REFERENCES items(id),
FOREIGN KEY (seller_id) REFERENCES users(id),
FOREIGN KEY (admin_id) REFERENCES admins(id)
);
Flow Diagram
Copy
Frontend (React) Backend Database
| | |
| GET /requests | |
|---------------------->| |
| |--- Query Items -->|
| |<--- Return Data --|
|<----------------------| |
| | |
| POST /items | |
|---------------------->| |
| |--- Create Item -->|
| |--- Create Req -->|
|<----------------------| |
Security Considerations
Authentication: Validate JWT token on both endpoints
Authorization:
Ensure user can only access their own requests
Validate user owns item when modifying
Validation:
Sanitize input data
Validate price is positive number
Validate image format if processing
Rate Limiting: Prevent spam submissions
This implementation allows users to:
Submit new items for approval
View their existing listings
See approval status (pending/approved/rejected)
Maintain a catalog of their selling/exchange items
Beta Was this translation helpful? Give feedback.
All reactions