Offline Support
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:brick_offline_first_with_supabase/brick_offline_first_with_supabase.dart';
|
||||
import 'package:brick_supabase/brick_supabase.dart';
|
||||
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
@ConnectOfflineFirstWithSupabase(
|
||||
supabaseConfig: SupabaseSerializable(tableName: 'it_service_request_actions'),
|
||||
)
|
||||
class ItServiceRequestAction extends OfflineFirstWithSupabaseModel {
|
||||
final String id;
|
||||
final String requestId;
|
||||
final String userId;
|
||||
// Quill Delta JSON stored as plain string.
|
||||
final String? actionTaken;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
|
||||
ItServiceRequestAction({
|
||||
required this.id,
|
||||
required this.requestId,
|
||||
required this.userId,
|
||||
this.actionTaken,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
factory ItServiceRequestAction.fromMap(Map<String, dynamic> map) {
|
||||
String? quillField(dynamic raw) {
|
||||
if (raw == null) return null;
|
||||
if (raw is String) return raw;
|
||||
try {
|
||||
return jsonEncode(raw);
|
||||
} catch (_) {
|
||||
return raw.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return ItServiceRequestAction(
|
||||
id: map['id'] as String,
|
||||
requestId: map['request_id'] as String,
|
||||
userId: map['user_id'] as String,
|
||||
actionTaken: quillField(map['action_taken']),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
updatedAt: AppTime.parse(map['updated_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user