Skip to content

Commit

Permalink
Update index.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
halfmanbear authored Aug 30, 2024
1 parent be2daae commit ee37684
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/pages/Generator/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,61 +20,50 @@ export function Generator() {
]);
const [selectedSlicer, setSelectedSlicer] = useState("orcaslicer");

useEffect(() => {
compilePrinterList().then((list) => {
console.log("Printer List:", list); // Debug point: Verify printer list
setPrinterList(list);
});
compileFilamentList().then((list) => {
console.log("Filament List:", list); // Debug point: Verify filament list
setFilamentList(list);
});
compileProcessList().then((list) => {
console.log("Process List:", list); // Debug point: Verify process list
setProcessesList(list);
});
}, []);

useEffect(() => {
const extractPrinterName = (printer) => {
return printer.split(" (")[0].replace(/ /g, "");
};

const getFilamentMatchKeyword = (filament) => {
if (filament.includes("PLA")) {
return "PLA";
}
if (filament.includes("PETG")) {
return "PETG";
}
return filament.split(" ").pop().replace(/-/g, "").replace("OpenNept4une", "").trim(); // Clean and trim the last part of the filament name
return filament.split(" ").pop().replace(/-/g, "").replace("OpenNept4une", "").trim();
};

const filtered = processesList.filter((process) => {
const processPrinterName = process.identifier
.split("@")[1]
.split(" (")[0]
.replace(/ /g, "");

const printerMatch = selectedPrinters.some((printer) => {
const printerName = extractPrinterName(printer);
console.log(
`Comparing printer name: ${printerName} with process printer name: ${processPrinterName}`,
);
return printerName === processPrinterName;
});

const filamentMatch = selectedFilament.some((filament) => {
const filamentKeyword = getFilamentMatchKeyword(filament);
console.log(
`Checking if process identifier: ${process.identifier} includes filament keyword: ${filamentKeyword}`,
);
return process.identifier.includes(filamentKeyword);
return process.identifier.toLowerCase().includes(filamentKeyword.toLowerCase());
});

console.log(
`Process: ${process.identifier}, Printer Match: ${printerMatch}, Filament Match: ${filamentMatch}`,
);

return printerMatch && filamentMatch;
});

console.log("Filtered Processes List:", filtered); // Debug point: Verify filtered processes list
setFilteredProcessesList(filtered);
}, [selectedPrinters, selectedFilament, processesList]);
Expand Down

0 comments on commit ee37684

Please sign in to comment.