const mongoose = require('mongoose');
const UserSchema = new mongoose.Schema({
name: { type: String, required: true },
phone: { type: String, required: true, unique: true },
password: { type: String, required: true }, // Encrypted
address: {
street: String,
city: String,
state: String,
pincode: String
},
createdAt: { type: Date, default: Date.now }
});
module.exports = mongoose.model('User', UserSchema);
You've shared your User schema with phone-based authentication and address storage. What would you like me to add to the frontend?
I'll add full authentication with login/register pages, user profile, and auth state management. Let me first read the current store header and API lib to understand the existing structure.
Now I have the full picture. I'll create:
lib/api.tsconst mongoose = require('mongoose');
const OrderSchema = new mongoose.Schema({
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
items: [{
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' },
quantity: { type: Number, default: 1 },
size: String,
color: String
}],
totalAmount: { type: Number, required: true },
shippingAddress: Object,
paymentMethod: { type: String, enum: ['COD', 'ONLINE'], default: 'COD' },
paymentStatus: { type: String, enum: ['Pending', 'Paid', 'Failed'], default: 'Pending' },
orderStatus: { type: String, enum: ['Ordered', 'Packed', 'Shipped', 'Delivered'], default: 'Ordered' },
deliveryDate: String,
createdAt: { type: Date, default: Date.now }
});
module.exports = mongoose.model('Order', OrderSchema);