Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FFS] Facilitation du restock des vêtements en rupture #350

Open
wants to merge 2 commits into
base: oss
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,18 @@ export class FightForStyleRestockProvider {
}
}
}
const randomItem = loopItems[Math.floor(Math.random() * loopItems.length)];

const itemStock = loopItems.filter(
item => item.stock != null && item.stock < 50
);

let randomItem;
if (!itemStock) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!itemStock) {
if (!itemStock.length) {

Ca marche en python, mais pas en JS 🙏

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah mince! X) je pensais que ça marchais pcq j'avais vu cette ligne (Je suis néophyte en TS )
" if (!randomItem || !loopItems) {" (ligne 179)

randomItem = loopItems[Math.floor(Math.random() * loopItems.length)];
} else {
randomItem = itemStock[Math.floor(Math.random() * itemStock.length)];
}

if (!randomItem || !loopItems) {
return;
}
Expand All @@ -191,6 +202,7 @@ export class FightForStyleRestockProvider {
},
},
});
this.notifier.notify(source, `Vous avez restock des ~g~${randomItem.modelLabel} ~s~`, 'success');
}

// Update repository
Expand Down