Skip to content

Commit

Permalink
Debug (#56)
Browse files Browse the repository at this point in the history
* FF-8 feat: admin management and  authorization

* FF-8 feat: admin management and  authorization

* FF-9

* [FF-9] feat: product management

* fixed bugs

* FF-10

* some changes

* Debug

* Fixed bug

* fixed bug

* fixed multer dirname

* added commented code

---------

Co-authored-by: Ilham Hidayatulloh <[email protected]>
  • Loading branch information
dittolk and Ilhamhidayatulloh59 committed Feb 13, 2024
1 parent 06b125c commit 26334c6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 71 deletions.
80 changes: 40 additions & 40 deletions apps/api/src/controllers/product.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,46 +411,46 @@ export const getAllBranchProduct = async (req, res) => {
};
}

// if (cond && cond === 'disc') {
// const allBranchProducts = await ProductBranch.findAndCountAll({
// include: [
// {
// model: Product,
// },
// {
// model: Branch,
// },
// {
// model: Discount,
// },
// ],
// where: {
// [Op.and]: [whereCondition, { '$Discounts.id$': null }],
// },
// });
// return res.status(200).send({ result: allBranchProducts });
// }

// const allBranchProducts = await ProductBranch.findAndCountAll({
// include: [
// {
// model: Product,
// },
// {
// model: Branch,
// },
// ],
// where: whereCondition,
// order: [[sortBy, sortOrder.toUpperCase()]],
// limit: parseInt(limit),
// offset: parseInt(offset),
// });
// const totalPages = Math.ceil(allBranchProducts.count / limit);
// return res
// .status(200)
// .send({ result: allBranchProducts, page, totalPages });

return res.status(200).send({ message: 'success' });
if (cond && cond === 'disc') {
const allBranchProducts = await ProductBranch.findAndCountAll({
include: [
{
model: Product,
},
{
model: Branch,
},
{
model: Discount,
},
],
where: {
[Op.and]: [whereCondition, { '$Discounts.id$': null }],
},
});
return res.status(200).send({ result: allBranchProducts });
}

const allBranchProducts = await ProductBranch.findAndCountAll({
include: [
{
model: Product,
},
{
model: Branch,
},
],
where: whereCondition,
order: [[sortBy, sortOrder.toUpperCase()]],
limit: parseInt(limit),
offset: parseInt(offset),
});
const totalPages = Math.ceil(allBranchProducts.count / limit);
return res
.status(200)
.send({ result: allBranchProducts, page, totalPages });

// return res.status(200).send({ message: 'success' });
} catch (error) {
console.error(error);
return res.status(500).send({ message: error.message });
Expand Down
31 changes: 0 additions & 31 deletions apps/api/src/middleware/admin/product.multer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,4 @@ module.exports = {
const limits = { fileSize: 1024 * 1024 };
return multer({ storage, fileFilter, limits });
},

multerUploadProfile: () => {
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, "./src/public/admin_pp");
},
filename: (req, file, cb) => {
cb(
null,
"PIMG" +
"-" +
Date.now() +
Math.round(Math.random() * 1000000) +
"." +
file.mimetype.split("/")[1]
);
},
});
const fileFilter = (req, file, cb) => {
const extFilter = ["jpg", "jpeg", "png", "gif"];
const checkEct = extFilter.includes(file.mimetype.split("/")[1].toLowerCase());

if (checkEct) {
cb(null, true);
} else {
cb(new Error("file format not match"));
}
};
const limits = { fileSize: 1024 * 1024 };
return multer({ storage, fileFilter, limits });
},
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/web/src/pages/admin/stockManagement/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function StockManagement() {
Authorization: `Bearer ${token}`,
},
});
console.log("response", response);
updateURL(navigate, page, sort, order, search)
setProductBranchData(response.data?.result.rows)
setTotalPages(response.data?.totalPages)
Expand Down

0 comments on commit 26334c6

Please sign in to comment.