import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__index_mjs__ from "../../../../index.mjs";
const useSaveRoleResourceAction = ()=>{
    const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
    const api = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useAPIClient)();
    const record = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useRecord)();
    const ctx = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useActionContext)();
    const { refresh } = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useResourceActionContext)();
    return {
        async run () {
            await api.resource('roles.resources', record.roleName)[record.exists ? 'update' : 'create']({
                filterByTk: record.name,
                values: {
                    ...form.values,
                    name: record.name
                }
            });
            ctx.setVisible(false);
            refresh();
        }
    };
};
export { useSaveRoleResourceAction };
