This commit is contained in:
2026-05-29 12:26:41 +02:00
parent 6211cc6729
commit 5ad3e12b1f
18 changed files with 1303 additions and 372 deletions

View File

@@ -0,0 +1,65 @@
import 'package:equatable/equatable.dart';
class ReminderDefaultModel extends Equatable {
final String? id;
final String companyId;
final String staffId;
final int minutesBefore;
final String channel; // 'push' o 'email'
const ReminderDefaultModel({
this.id,
required this.companyId,
required this.staffId,
required this.minutesBefore,
required this.channel,
});
ReminderDefaultModel copyWith({
String? id,
String? companyId,
String? staffId,
int? minutesBefore,
String? channel,
}) {
return ReminderDefaultModel(
id: id ?? this.id,
companyId: companyId ?? this.companyId,
staffId: staffId ?? this.staffId,
minutesBefore: minutesBefore ?? this.minutesBefore,
channel: channel ?? this.channel,
);
}
Map<String, dynamic> toMap() {
return {
if (id != null) 'id': id,
'company_id': companyId,
'staff_id': staffId,
'minutes_before': minutesBefore,
'channel': channel,
};
}
factory ReminderDefaultModel.fromMap(Map<String, dynamic> map) {
return ReminderDefaultModel(
id: map['id'] as String?,
companyId: map['company_id'] as String,
staffId: map['staff_id'] as String,
minutesBefore: map['minutes_before'] as int,
channel: map['channel'] as String,
);
}
@override
List<Object?> get props => [id, companyId, staffId, minutesBefore, channel];
// Helper per la UI: formatta i minuti in qualcosa di leggibile (es. "1 ora prima")
String get friendlyTime {
if (minutesBefore < 60) return '$minutesBefore minuti prima';
if (minutesBefore == 60) return '1 ora prima';
if (minutesBefore < 1440) return '${minutesBefore ~/ 60} ore prima';
if (minutesBefore == 1440) return '1 giorno prima';
return '${minutesBefore ~/ 1440} giorni prima';
}
}

View File

@@ -0,0 +1,22 @@
import 'package:equatable/equatable.dart';
class TaskReminderConfig extends Equatable {
final int minutesBefore;
final String channel; // 'push' o 'email'
const TaskReminderConfig({
required this.minutesBefore,
required this.channel,
});
String get friendlyTime {
if (minutesBefore < 60) return '$minutesBefore minuti prima';
if (minutesBefore == 60) return '1 ora prima';
if (minutesBefore < 1440) return '${minutesBefore ~/ 60} ore prima';
if (minutesBefore == 1440) return '1 giorno prima';
return '${minutesBefore ~/ 1440} giorni prima';
}
@override
List<Object?> get props => [minutesBefore, channel];
}