Newer
Older
smart-home-server / webclient / src / js / components / confirm-popup.js
export default function confirmPopup(text, confirmedCb, canceledCb) {
	Modals.create("confirm-popup", {
		title: `Requires confirmation`,
		body: modal => {
			return `
				<p>${text}</p>
			`;
		},
		actions: modal => {
			const buttonNO = Helper.template.createElement("button", { class: "btn btn-primary" }, "NO");
			const buttonYES = Helper.template.createElement("button", { class: "btn btn-warning" }, "YES");

			buttonNO.addEventListener("click", e => {
				modal.close();
				canceledCb();
			});

			buttonYES.addEventListener("click", e => {
				modal.close();
				confirmedCb();
			});

			return [ buttonNO, buttonYES ];
		}
	}).show();
}