# useMutateCustomProperties

## Purpose-Specific Mutation Hook
A specialized abstraction of [`useMutateGeneric`](./useMutateGeneric.md) optimized for managing custom properties configurations in FOLIO. Designed for operations targeting specific resource identifiers with enforced endpoint structure.

```mermaid
graph TD
  A[useMutateCustomProperties] --> B[useMutateGeneric]
  B --> C[Pre-configured Endpoints]
  B --> D[Standardized Query Keys]
```

## When to Use
- Managing custom properties for **single-resource endpoints**
- Operations requiring fixed ID in URL paths
- Standardizing cache keys for property-related mutations

## Key Differentiators
|| useMutateGeneric | useMutateCustomProperties |
|---|---|---|
| **Endpoint Structure** | Configurable | Enforced `/endpoint/{id}` |
| **Query Key** | Customizable | Auto-generated hierarchy |
| **ID Handling** | Manual in calls | Built into configuration |

## Usage Example
```jsx
const CustomPropertiesEditor = ({ recordId }) => {
  const { post, put } = useMutateCustomProperties({
    endpoint: 'configurations/custom-properties',
    id: recordId
  });

  const saveProperty = (property) => 
    property.id ? put(property) : post(property);

  return <PropertyForm onSubmit={saveProperty} />;
};
```

## Required Props
| Prop | Type | Description |
|------|------|-------------|
| `endpoint` | string | Base API path (e.g., `'license/custom-properties'`) |
| `id` | string | Unique resource identifier for URL construction |

## Default Behavior
1. **Endpoint Construction**
   ```js
   // PUT/DELETE endpoints
   `${endpoint}/${id}`
   ```
2. **Query Key Structure**
   ```js
   ['stripes-kint-components', 'useMutateCustomProperties', id]
   ```

## Customization
While providing opinionated defaults, maintains full compatibility with [`useMutateGeneric`](./useMutateGeneric.md) configuration:

```jsx
// Override delete endpoint while keeping other defaults
useMutateCustomProperties({
  endpoint: 'inventory/types',
  id: 'BOOK',
  endpointMutators: {
    delete: () => `inventory/legacy-types/${id}?version=2`
  }
});
```

## Error Handling
Inherits the [error handling characteristics](./useMutateGeneric.md#error-handling-philosophy) of the base hook. Recommended pattern:

```jsx
useMutateCustomProperties({
  catchQueryCalls: {
    post: (error) => {
      logger.error('Custom property creation failed', error);
      throw error; // Propagate to error boundary
    }
  }
});
```

## Performance Notes
- Cache keys automatically include the `id` parameter
- Memoize configurations when using multiple instances
- Prefer single instance per resource ID lifecycle