72 lines
2.4 KiB
Dart
72 lines
2.4 KiB
Dart
import 'package:brick_offline_first_with_supabase/brick_offline_first_with_supabase.dart';
|
|
import 'package:brick_sqlite/brick_sqlite.dart';
|
|
import 'package:brick_supabase/brick_supabase.dart';
|
|
|
|
import '../utils/app_time.dart';
|
|
|
|
@ConnectOfflineFirstWithSupabase(
|
|
supabaseConfig: SupabaseSerializable(tableName: 'tickets'),
|
|
)
|
|
class Ticket extends OfflineFirstWithSupabaseModel {
|
|
final String id;
|
|
final String subject;
|
|
final String description;
|
|
final String officeId;
|
|
final String status;
|
|
final DateTime createdAt;
|
|
final String? creatorId;
|
|
final DateTime? respondedAt;
|
|
final DateTime? promotedAt;
|
|
final DateTime? closedAt;
|
|
|
|
Ticket({
|
|
required this.id,
|
|
required this.subject,
|
|
required this.description,
|
|
required this.officeId,
|
|
required this.status,
|
|
required this.createdAt,
|
|
required this.creatorId,
|
|
required this.respondedAt,
|
|
required this.promotedAt,
|
|
required this.closedAt,
|
|
});
|
|
|
|
@Supabase(ignore: true)
|
|
@Sqlite(ignore: true)
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is Ticket &&
|
|
runtimeType == other.runtimeType &&
|
|
id == other.id && subject == other.subject &&
|
|
description == other.description && officeId == other.officeId &&
|
|
status == other.status && createdAt == other.createdAt &&
|
|
creatorId == other.creatorId && respondedAt == other.respondedAt &&
|
|
promotedAt == other.promotedAt && closedAt == other.closedAt;
|
|
|
|
@Supabase(ignore: true)
|
|
@Sqlite(ignore: true)
|
|
@override
|
|
int get hashCode => Object.hash(id, subject, description, officeId, status,
|
|
createdAt, creatorId, respondedAt, promotedAt, closedAt);
|
|
|
|
factory Ticket.fromMap(Map<String, dynamic> map) {
|
|
return Ticket(
|
|
id: map['id'] as String,
|
|
subject: map['subject'] as String? ?? '',
|
|
description: map['description'] as String? ?? '',
|
|
officeId: map['office_id'] as String? ?? '',
|
|
status: map['status'] as String? ?? 'pending',
|
|
createdAt: AppTime.parse(map['created_at'] as String),
|
|
creatorId: map['creator_id'] as String?,
|
|
respondedAt: map['responded_at'] == null
|
|
? null : AppTime.parse(map['responded_at'] as String),
|
|
promotedAt: map['promoted_at'] == null
|
|
? null : AppTime.parse(map['promoted_at'] as String),
|
|
closedAt: map['closed_at'] == null
|
|
? null : AppTime.parse(map['closed_at'] as String),
|
|
);
|
|
}
|
|
}
|