frappe.listview_settings["Salary Component"] = {
    onload: function (listview) {
        listview.page.add_inner_button(__("Export Defaults"), function () {
            frappe.call({
                method: "jey_erp.custom.salary_component_export.export_salary_components",
                callback: function (r) {
                    if (!r.message) return;

                    const json = JSON.stringify(r.message, null, 2);
                    const blob = new Blob([json], { type: "application/json" });
                    const url = URL.createObjectURL(blob);
                    const a = document.createElement("a");
                    a.href = url;
                    a.download = "salary_components.json";
                    a.click();
                    URL.revokeObjectURL(url);
                },
            });
        });
    },
};
