Skip to content

Commit 5cab3c9

Browse files
authored
fix: prevent accounting before departure (#266)
1 parent 3115cb8 commit 5cab3c9

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

assets/i18n/en.i18n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@
360360
"account_info_not_set": "Account information is not set",
361361
"cost_cannot_be_negative": "Cost cannot be negative",
362362
"cost_per_user_mismatch": "Cost per user mismatch",
363-
"before_departure": "You cannot request accounting before confirming the departure time",
363+
"before_departure": "You can request accounting 10 minutes after the departure time",
364364
"not_a_participant": "You are not a participant",
365365
"pot_not_exist": "Pot does not exist",
366366
"pot_already_closed": "Pot has already been closed",

assets/i18n/ko.i18n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@
357357
"account_info_not_set": "계좌 정보가 설정되지 않았습니다",
358358
"cost_cannot_be_negative": "정산 금액은 0원 이상이어야 합니다",
359359
"cost_per_user_mismatch": "정산 금액이 동승자 수와 일치하지 않습니다",
360-
"before_departure": "출발 시간을 확정하지 않아 정산을 요청할 수 없습니다",
360+
"before_departure": "출발 시각 10분 후부터 정산이 가능합니다",
361361
"not_a_participant": "동승자가 아닙니다",
362362
"pot_not_exist": "팟이 존재하지 않습니다",
363363
"pot_already_closed": "팟이 이미 해산되었습니다",

lib/app/modules/chat/presentation/widgets/accounting_button.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@ class AccountingButton extends StatelessWidget {
1717
BuildContext context,
1818
PotInfoEntity pot,
1919
) async {
20-
if (pot.departureTime == null) {
20+
final departureTime = pot.departureTime;
21+
if (departureTime == null) {
2122
context.showToast(context.t.chat_room.accounting.before_confirm);
2223
return;
2324
}
25+
final tenMinutesAfterDeparture = departureTime.add(
26+
const Duration(minutes: 10),
27+
);
28+
if (DateTime.now().isBefore(tenMinutesAfterDeparture)) {
29+
context.showToast(
30+
context.t.chat_room.accounting.dutch.errors.before_departure,
31+
);
32+
return;
33+
}
2434
await AccountingRoute(pot: pot).push(context);
2535
}
2636

0 commit comments

Comments
 (0)