Skip to content

Commit

Permalink
bugFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
imkarimkarim committed Sep 10, 2022
1 parent c754d6f commit b7ac266
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
61 changes: 31 additions & 30 deletions src/db/productDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ const isProductHasDependency = (id, callback) => {
};

const getInCar = (carId, callback) => {
db.find({ $and: [{ docType: "product" }, { inCar: carId }] }, function (
err,
docs
) {
if (err) throw err;
if (typeof callback === "function") {
if (docs) {
docs = sortProductsArray(docs);
callback(docs);
db.find(
{ $and: [{ docType: "product" }, { inCar: carId }] },
function (err, docs) {
if (err) throw err;
if (typeof callback === "function") {
if (docs) {
docs = sortProductsArray(docs);
callback(docs);
}
}
}
});
);
};

const search = (searchFilters, callback) => {
Expand Down Expand Up @@ -149,15 +149,15 @@ const getFinished = (callback) => {

const getOne = (id, callback) => {
if (!id) return;
db.findOne({ $and: [{ docType: "product" }, { customeId: id }] }, function (
err,
doc
) {
if (err) throw err;
if (typeof callback === "function") {
callback(doc);
db.findOne(
{ $and: [{ docType: "product" }, { customeId: id }] },
function (err, doc) {
if (err) throw err;
if (typeof callback === "function") {
callback(doc);
}
}
});
);
};

const insert = (product, callback) => {
Expand Down Expand Up @@ -194,21 +194,21 @@ const toggleProductFinish = (id, callback) => {

const isProductBug = (productId, carId, callback) => {
if (!productId || !carId) return;
db.findOne({ $and: [{ docType: "car" }, { customeId: carId }] }, function (
err,
car
) {
if (err) throw err;
db.findOne(
{ $and: [{ docType: "car" }, { customeId: carId }] },
function (err, car) {
if (err) throw err;

const isInCarProducts = car.products.filter(
(p) => p.customeId === productId
);
const bool = isInCarProducts.length === 1 ? false : true;
const isInCarProducts = car.products.filter(
(p) => p.customeId === productId
);
const bool = isInCarProducts.length === 1 ? false : true;

if (typeof callback === "function") {
callback(bool);
if (typeof callback === "function") {
callback(bool);
}
}
});
);
};

const addCheat = (productId, cheat, callback) => {
Expand Down Expand Up @@ -293,6 +293,7 @@ const updateCarProduct = (productId, product, callback) => {
customeId: doc.customeId,
isProductFinish: doc.isProductFinish,
finishDate: doc.finishDate,
...doc,
},
{},
function () {
Expand Down
2 changes: 1 addition & 1 deletion src/ipcMains/ipcCars.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ipcMain.on("includeCar", (event, car) => {
});
}
});
}, 100 + 400 * ind);
}, 100 + 600 * ind);
})(i);
}
});
Expand Down

0 comments on commit b7ac266

Please sign in to comment.