|
|
@ -1016,6 +1016,41 @@ fastify.post('/api/uploads_team_profile/:customerId', {
|
|
|
|
return reply.code(500).send({ error: 'Upload failed', details: err.message });
|
|
|
|
return reply.code(500).send({ error: 'Upload failed', details: err.message });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.post('/api/uploads_admin_profile/:customerId', {
|
|
|
|
|
|
|
|
preHandler: upload.single('file')
|
|
|
|
|
|
|
|
}, async (request, reply) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const { customerId } = request.params;
|
|
|
|
|
|
|
|
const file = await request.file; // Uncomment this line
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
|
|
|
formData.append('file', file);
|
|
|
|
|
|
|
|
const bucketName = 'arminta_profile_pictures';
|
|
|
|
|
|
|
|
const filePath = `arminta_team_profiles/${file.originalname}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fileBuffer = await fs.promises.readFile(file.path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await storage.bucket(bucketName).file(filePath).save(fileBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// make file public
|
|
|
|
|
|
|
|
await storage.bucket(bucketName).file(filePath).makePublic();
|
|
|
|
|
|
|
|
const publicUrl = `https://storage.googleapis.com/${bucketName}/${filePath}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// save in DB
|
|
|
|
|
|
|
|
const picture = await AdminProfilePicture.findOneAndUpdate(
|
|
|
|
|
|
|
|
{ customerId },
|
|
|
|
|
|
|
|
{ picture: publicUrl },
|
|
|
|
|
|
|
|
{ new: true, upsert: true }
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reply.send({ picture: publicUrl });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
request.log.error(err);
|
|
|
|
|
|
|
|
return reply.code(500).send({ error: 'Upload failed', details: err.message });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// fastify.post('/api/uploads_team_profile/:customerId', async (request, reply) => {
|
|
|
|
// fastify.post('/api/uploads_team_profile/:customerId', async (request, reply) => {
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
// const { customerId } = request.params;
|
|
|
|
// const { customerId } = request.params;
|
|
|
@ -2219,6 +2254,7 @@ fastify.post("/api/teamMemberLogin", {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const moment = require("moment-timezone");
|
|
|
|
const moment = require("moment-timezone");
|
|
|
|
|
|
|
|
const { AdminProfilePicture } = require("./models/admin.js");
|
|
|
|
|
|
|
|
|
|
|
|
fastify.post("/api/supportLogin", {
|
|
|
|
fastify.post("/api/supportLogin", {
|
|
|
|
schema: {
|
|
|
|
schema: {
|
|
|
|