import { useForm } from "@tachybase/schema";
import { useAPIClient, useActionContext, useRecord, useResourceActionContext } from "../../../../index.mjs";
const useSaveRoleResourceAction = ()=>{
    const form = useForm();
    const api = useAPIClient();
    const record = useRecord();
    const ctx = useActionContext();
    const { refresh } = 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 };
