Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,796 changes: 0 additions & 3,796 deletions admin/package-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.3.0",
"vite": "^7.0.4"
"vite": "^7.1.6"
}
}
4 changes: 2 additions & 2 deletions admin/src/pages/Add/Add.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
cursor: pointer;
}

.add-product-name, .add-product-description {
.add-product-name, .add-product-description ,.add-product-restaurant{
width: max(40%, 280px);
}

.add-product-name input, .add-product-description textarea {
.add-product-name input, .add-product-description textarea ,.add-product-restaurant input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
Expand Down
10 changes: 9 additions & 1 deletion admin/src/pages/Add/Add.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Add = ({url}) => {
const [image, setImage] = useState(false);
const [data, setData] = useState({
name: '',
restaurantId:'',
description: '',
category: 'Salad',
price: ''
Expand All @@ -27,15 +28,17 @@ const Add = ({url}) => {
const formData = new FormData();
formData.append('image', image);
formData.append('name', data.name);
formData.append('restaurantId', data.restaurantId);
formData.append('description', data.description);
formData.append('category', data.category);
formData.append('price', Number(data.price));

const response = await axios.post(`${url}/api/food/add`, formData);
const response = await axios.post(`${url}api/food/add`, formData);
if(response.data.success) {
toast.success(response.data.message);
setData({
name: '',
restaurantId:'',
description: '',
category: 'Salad',
price: ''
Expand Down Expand Up @@ -63,6 +66,11 @@ const Add = ({url}) => {
<input onChange={onChangeHandler} value={data.name} type="text" name='name' placeholder='Type Here' required />
</div>

<div className="add-product-restaurant flex-col">
<p>Restaurant Id</p>
<input onChange={onChangeHandler} value={data.restaurantId} type="text" name="restaurantId" placeholder="Id" required />
</div>

<div className="add-product-description flex-col">
<p>Product Description</p>
<textarea onChange={onChangeHandler} value={data.description} name="description" rows="6" placeholder="Write content here..." required />
Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export const registerUser = async (req, res) => {
if (userExists) {
return res.status(400).json({ message: 'User already exists' });
}

// Hash password
const hashedPassword = await bcrypt.hash(password, 10);

// Create user
const user = await User.create({ name, email, password: hashedPassword });
console.log(user);

// Generate JWT
const token = generateToken(user._id);
Expand Down
1 change: 1 addition & 0 deletions backend/controllers/foodController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fs from 'fs';
const addFood = async (req, res) => {
try {
const body = { ...req.body };
console.log(body);
console.log("Parsed restaurantId:", body.restaurantId);
console.log("Type:", typeof body.restaurantId);

Expand Down
67 changes: 62 additions & 5 deletions backend/controllers/paymentController.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,71 @@
// import Razorpay from "razorpay";
// import dotenv from "dotenv";
// dotenv.config();

// const razorpay = new Razorpay({
// key_id: process.env.RAZORPAY_KEY_ID,
// key_secret: process.env.RAZORPAY_KEY_SECRET,
// });

// export const createOrder = async (req, res) => {
// try {
// const { amount } = req.body;

// const options = {
// amount: amount * 100, // convert to paise
// currency: "INR",
// receipt: `order_rcptid_${Date.now()}`,
// };

// const order = await razorpay.orders.create(options);

// res.status(200).json({
// success: true,
// orderId: order.id,
// amount: order.amount,
// currency: order.currency,
// });
// } catch (error) {
// res.status(500).json({
// success: false,
// message: "Payment order creation failed",
// error: error.message,
// });
// }
// };

// paymentController.js
import Razorpay from "razorpay";
import dotenv from "dotenv";
dotenv.config();

const razorpay = new Razorpay({
key_id: process.env.RAZORPAY_KEY_ID,
key_secret: process.env.RAZORPAY_KEY_SECRET,
});
// Initialize Razorpay or stub
let razorpay;
if (process.env.RAZORPAY_KEY_ID && process.env.RAZORPAY_KEY_SECRET) {
razorpay = new Razorpay({
key_id: process.env.RAZORPAY_KEY_ID,
key_secret: process.env.RAZORPAY_KEY_SECRET,
});
} else {
console.warn(
"⚙️ Razorpay credentials missing—running in STUB mode for development"
);
razorpay = {
orders: {
create: (opts) =>
Promise.resolve({
id: `stub_order_${Date.now()}`,
amount: opts.amount,
currency: opts.currency,
status: "created (stub)",
}),
},
};
}

export const createOrder = async (req, res) => {
try {
const { amount } = req.body;

const options = {
amount: amount * 100, // convert to paise
currency: "INR",
Expand All @@ -24,8 +79,10 @@ export const createOrder = async (req, res) => {
orderId: order.id,
amount: order.amount,
currency: order.currency,
status: order.status || "created",
});
} catch (error) {
console.error("createOrder error:", error);
res.status(500).json({
success: false,
message: "Payment order creation failed",
Expand Down
Loading