admin profile added

master^2
Bhaskar 8 months ago
parent c59259f1af
commit a64d533e80

@ -88,6 +88,38 @@ exports.adminSignUp = async (request, reply) => {
}
};
exports.editAdmin = async (request, reply) => {
try {
const { customerId } = request.params;
const {
phone,
username,
picture,
} = request.body;
const existing = await Admin.findOne({ customerId });
if (!existing) {
return reply.status(404).send({ message: 'City not found' });
}
existing.phone = phone || existing.phone;
existing.username = username || existing.username;
existing.picture = picture || existing.picture;
await existing.save();
reply.send({ message: 'Admin user updated successfully' });
} catch (err) {
reply.status(500).send({ message: err.message });
}
};
// Admin Login Function (With Phone Number)
// exports.adminLogin = async (request, reply) => {

@ -31,6 +31,30 @@ fastify.route({
handler: adminController.adminSignUp,
});
fastify.put('/api/editAdmin/:customerId', {
schema: {
description: "Edit Admin details by CustomerId",
tags: ["Admin"],
summary: "Edit Admin details by CustomerId",
params: {
type: "object",
properties: {
customerId: { type: "string" },
},
required: ["customerId"],
},
body: {
type: "object",
properties: {
phone: { type: "string" },
username: { type: "string" },
picture: { type: "string" },
},
}
},
handler: adminController.editAdmin,
});
fastify.post("/api/adminLogin", {
schema: {

Loading…
Cancel
Save