Skip to content

Commit d86d66f

Browse files
committed
#update functionality admin page
1 parent aa9d197 commit d86d66f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

β€Žbackend/app/routes/admin/updateAdmin.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ module.exports =async (req, res) => {
1111

1212
// Delete previous image if it exists
1313
if (admin.image && admin.image!=="undefined" && req.file?.path) {
14+
if (fs.existsSync(path.join(__dirname,'..' ,'..','..', admin.image))) {
1415
fs.unlinkSync(path.join(__dirname,'..' ,'..','..', admin.image));
16+
}
1517
}
1618

1719
try {
@@ -31,7 +33,7 @@ module.exports =async (req, res) => {
3133
{ $set: updateFields },
3234
{ new: true }
3335
);
34-
res.status(200).json({updatedAdmin,updateFields});
36+
res.status(200).json({updatedAdmin,"Req.Body":updateFields});
3537
} catch (err) {
3638
res.status(500).json(err);
3739
}

β€Žfrontend/src/pages/Admin/Admin.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const Admin = (props) => {
5050
};
5151

5252
const response = await axios.get(baseUrl, { params, headers });
53+
// image retrieving
5354
let formattedPath = response.data[0].image?.replace(/\\/g, "/");
5455
if (formattedPath?.startsWith("uploads/")) {
5556
formattedPath = formattedPath.replace("uploads/", "");

0 commit comments

Comments
Β (0)