Skip to content

Commit

Permalink
Add method for deleting comm.pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
eoye committed Dec 16, 2024
1 parent 5b44211 commit cfca704
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions www/src/components/editor/EditorSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default function EditorSidebar() {
<Button
onClick={() => {
context?.deleteCommissioningPackage(context.activePackage.id);
setIsDeleteOpen(false);
}}
>
Delete
Expand Down
7 changes: 6 additions & 1 deletion www/src/context/CommissioningPackageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export const CommissioningPackageContextProvider: React.FC<{
}, [activePackage, commissioningPackages]);

const deleteCommissioningPackage = (packageId: string) => {
console.log("Deleting package with id: ", packageId);
setCommissioningPackages((prevPackages) =>
prevPackages.filter((pkg) => pkg.id !== packageId)
);
if (activePackage.id === packageId) {
setActivePackage(commissioningPackages[0]);
}
};

return (
Expand Down

0 comments on commit cfca704

Please sign in to comment.