Files
2025-10-24 23:34:56 +02:00

67 lines
1.9 KiB
Dart

class Share {
final int id;
final int hedgehogId;
final int ownerUserId;
final int? targetUserId;
final String? invitedEmail;
final String? targetEmail; // bei accepted (vom Backend)
final String role; // 'viewer' | 'editor'
final String status; // 'pending' | 'accepted' | 'revoked'
final DateTime? createdAt;
final DateTime? updatedAt;
Share({
required this.id,
required this.hedgehogId,
required this.ownerUserId,
this.targetUserId,
this.invitedEmail,
this.targetEmail,
required this.role,
required this.status,
this.createdAt,
this.updatedAt,
});
factory Share.fromJson(Map<String, dynamic> j) => Share(
id: j['id'] as int,
hedgehogId: j['hedgehog_id'] as int,
ownerUserId: j['owner_user_id'] as int,
targetUserId: j['target_user_id'] as int?,
invitedEmail: j['invited_email'] as String?,
targetEmail: j['target_email'] as String?,
role: j['role'] as String,
status: j['status'] as String,
createdAt:
j['created_at'] != null ? DateTime.tryParse(j['created_at']) : null,
updatedAt:
j['updated_at'] != null ? DateTime.tryParse(j['updated_at']) : null,
);
}
class SharedIgelItem {
final int id; // igel.id
final String name;
final String role; // viewer|editor
final int ownerUserId;
final String? ownerEmail; // <— NEU
SharedIgelItem({
required this.id,
required this.name,
required this.role,
required this.ownerUserId,
this.ownerEmail, // <— NEU
});
factory SharedIgelItem.fromJson(Map<String, dynamic> j) => SharedIgelItem(
id: j['id'] as int,
name: j['name'] as String,
role: j['role'] as String,
ownerUserId: j['owner_user_id'] as int,
ownerEmail: j['owner_email'] as String?, // <— NEU
);
}
enum AccessRole { owner, editor, viewer, none }