unshareDomain method
Soft-deletes a curriculum share by setting revoked_at and revoked_by.
The row is preserved (not hard-deleted) so the audit trigger records a
domain.unshared event. Only the active (non-revoked) share is updated.
Implementation
Future<void> unshareDomain(String domainId, String targetUserId) async {
final userId = _client.auth.currentUser?.id;
if (userId == null) {
throw StateError('Cannot unshare domain: user is not authenticated');
}
await _client
.from('curriculum_shares')
.update({
'revoked_at': DateTime.now().toUtc().toIso8601String(),
'revoked_by': userId,
})
.eq('domain_id', domainId)
.eq('shared_with_user_id', targetUserId)
.isFilter('revoked_at', null);
}