> For the complete documentation index, see [llms.txt](https://docs.wellcomecollection.org/request-for-comments-rfcs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wellcomecollection.org/request-for-comments-rfcs/086-item-viewer-refactor/11-phase-5-restriction-status.md).

# Phase 5: Restriction Status

[← Back to Index](/request-for-comments-rfcs/086-item-viewer-refactor.md)

**Effort:** 1 hour\
**Risk:** Low\
**Priority:** Low\
**Previous:** [Phase 4: Download Logic](/request-for-comments-rfcs/086-item-viewer-refactor/10-phase-4-download-logic.md)\
**Next:** [Phase 6: Duplicate Index Calls](/request-for-comments-rfcs/086-item-viewer-refactor/12-phase-6-duplicate-calls.md)

## Goal

Add `isCurrentCanvasRestricted` to context instead of calculating it in `ViewerTopBar`.

## Why?

* `ViewerTopBar` calculates this value
* Other components might need it too
* Centralise restriction logic in one place
* Clear boolean name makes intent obvious

**Note:** The `restricted-images` merge added the canonical `hasRestrictedItem()` helper that should be used for all restriction checks.

## Steps

### 3.1 Add to Context Type

**File:** `content/webapp/contexts/ItemViewerContextV2/index.tsx`

```typescript
type Props = {
  // ... existing ...
  isCurrentCanvasRestricted: boolean;  // Current canvas has restricted access
};
```

### 3.2 Calculate in `IIIFViewer.refactored.tsx`

```typescript
const isCurrentCanvasRestricted = currentCanvas 
  ? hasRestrictedItem(currentCanvas) 
  : false;

<ItemViewerContextV2.Provider value={{
  // ... existing ...
  isCurrentCanvasRestricted,
}}>
```

### 3.3 Update `ViewerTopBar.refactored.tsx`

```typescript
// REMOVE:
const isRestricted = currentCanvas && hasRestrictedItem(currentCanvas);

// ADD to destructuring:
const { isCurrentCanvasRestricted } = useItemViewerContextV2();

// UPDATE usage:
- {isRestricted && <RestrictedBadge />}
+ {isCurrentCanvasRestricted && <RestrictedBadge />}
```

## Testing

* [ ] Restricted badge appears on restricted canvases
* [ ] Badge doesn't appear on unrestricted canvases
* [ ] Download options respect restriction status

## Success Criteria

* [ ] `isCurrentCanvasRestricted` in context
* [ ] `ViewerTopBar` uses context value
* [ ] Restricted badge appears correctly

## Time: \~1 hour

***

**Next:** [Phase 6: Duplicate Index Calls](/request-for-comments-rfcs/086-item-viewer-refactor/12-phase-6-duplicate-calls.md)
