Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: format error message of date cell

appflowy36abd969ac00
diff --git a/frontend/app_flowy/assets/translations/en.json b/frontend/app_flowy/assets/translations/en.json
index 8755f05952..8fc9e90581 100644
--- a/frontend/app_flowy/assets/translations/en.json
+++ b/frontend/app_flowy/assets/translations/en.json
@@ -168,6 +168,7 @@
"dateFormatLocal": "Month/Month/Day",
"dateFormatUS": "Month/Month/Day",
"timeFormat": " Time format",
+ "invalidTimeFormat": "Invalid format",
"timeFormatTwelveHour": "12 hour",
"timeFormatTwentyFourHour": "24 hour",
"addSelectOption": "Add an option",
diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart
index 2e70ecddb2..ff001eaa75 100644
--- a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart
+++ b/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart
@@ -1,4 +1,6 @@
+import 'package:app_flowy/generated/locale_keys.g.dart';
import 'package:app_flowy/workspace/application/grid/field/field_service.dart';
+import 'package:easy_localization/easy_localization.dart' show StringTranslateExtension;
import 'package:flowy_sdk/log.dart';
import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
@@ -92,7 +94,7 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
case ErrorCode.InvalidDateTimeFormat:
emit(state.copyWith(
dateData: Some(newDateData),
- timeFormatError: Some(messageFromFlowyError(err)),
+ timeFormatError: Some(timeFormatPrompt(err)),
));
break;
default:
@@ -102,16 +104,19 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
);
}
- String messageFromFlowyError(FlowyError error) {
- switch (ErrorCode.valueOf(error.code)!) {
- case ErrorCode.EmailFormatInvalid:
- return state.copyWith(isSubmitting: false, emailError: some(error.msg), passwordError: none());
- case ErrorCode.PasswordFormatInvalid:
- return state.copyWith(isSubmitting: false, passwordError: some(error.msg), emailError: none());
+ String timeFormatPrompt(FlowyError error) {
+ String msg = LocaleKeys.grid_field_invalidTimeFormat.tr() + ". ";
+ switch (state.dateTypeOption.timeFormat) {
+ case TimeFormat.TwelveHour:
+ msg = msg + "e.g. 01: 00 AM";
+ break;
+ case TimeFormat.TwentyFourHour:
+ msg = msg + "e.g. 13: 00";
+ break;
default:
- return state.copyWith(isSubmitting: false, successOrFail: some(right(error)));
+ break;
}
- return "";
+ return msg;
}
@override
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart
index 5f0ccbc834..417c9f270e 100644
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart
@@ -18,7 +18,7 @@ abstract class GridCellDelegate {
GridCellDelegate get delegate;
}
-class DateCell extends GridCellWidget {
+class DateCell extends StatefulWidget with GridCellWidget {
final GridCellContextBuilder cellContextBuilder;
late final DateCellStyle? cellStyle;