Fakultas Ilmu Komputer UI

Commit 1bc264ee authored by Yoga Pratama's avatar Yoga Pratama
Browse files

[CHORES] Change date_time field to created

parent 3f4ddbbd
Pipeline #80370 failed with stages
in 2 minutes and 2 seconds
......@@ -2,6 +2,6 @@ import 'package:intl/intl.dart';
class CustomSerializer {
static DateTime stringToDateTime(String date) {
return DateFormat('dd-MM-yyyy hh:mm:ss').parse(date);
return DateFormat('dd-MM-yyyy hh:mm').parse(date);
}
}
......@@ -14,10 +14,15 @@ class KomentarPostingModel {
final int id;
final String deskripsi;
final String creator;
@JsonKey(name: 'date_time', fromJson: CustomSerializer.stringToDateTime)
final DateTime dateTime;
@JsonKey(fromJson: CustomSerializer.stringToDateTime)
final DateTime created;
KomentarPostingModel({this.id, this.deskripsi, this.creator, this.dateTime});
KomentarPostingModel({
this.id,
this.deskripsi,
this.creator,
this.created,
});
factory KomentarPostingModel.fromJson(Map<String, dynamic> json) =>
_$KomentarPostingModelFromJson(json);
......
......@@ -27,7 +27,7 @@ KomentarPostingModel _$KomentarPostingModelFromJson(Map<String, dynamic> json) {
id: json['id'] as int,
deskripsi: json['deskripsi'] as String,
creator: json['creator'] as String,
dateTime: CustomSerializer.stringToDateTime(json['date_time'] as String),
created: CustomSerializer.stringToDateTime(json['created'] as String),
);
}
......@@ -37,5 +37,5 @@ Map<String, dynamic> _$KomentarPostingModelToJson(
'id': instance.id,
'deskripsi': instance.deskripsi,
'creator': instance.creator,
'date_time': instance.dateTime?.toIso8601String(),
'created': instance.created?.toIso8601String(),
};
import 'package:intl/intl.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:bisaGo/config/custom_serializer.dart';
......@@ -14,18 +15,18 @@ class KomentarPostingKegiatanModel {
final int id;
final String creator;
final String deskripsi;
@JsonKey(name: 'created', fromJson: CustomSerializer.stringToDateTime)
@JsonKey(name: 'created', fromJson: _stringToDateTime)
final DateTime created;
KomentarPostingKegiatanModel(
{this.id,
this.creator,
this.deskripsi,
this.created}
);
{this.id, this.creator, this.deskripsi, this.created});
factory KomentarPostingKegiatanModel.fromJson(Map<String, dynamic> json) =>
_$KomentarPostingKegiatanModelFromJson(json);
Map<String, dynamic> toJson() => _$KomentarPostingKegiatanModelToJson(this);
}
DateTime _stringToDateTime(String date) {
return DateFormat('yyy-MM-dd hh:mm').parse(date);
}
......@@ -29,7 +29,7 @@ KomentarPostingKegiatanModel _$KomentarPostingKegiatanModelFromJson(
id: json['id'] as int,
creator: json['creator'] as String,
deskripsi: json['deskripsi'] as String,
created: CustomSerializer.stringToDateTime(json['created'] as String),
created: _stringToDateTime(json['created'] as String),
);
}
......
......@@ -82,7 +82,7 @@ class DashboardState extends State<Dashboard> {
final String title = data['title'];
Flushbar(
title: title,
message: '"$msg"',
message: msg,
duration: Duration(seconds: 8),
backgroundColor: Color(0xFF003566),
onTap: (_) {
......
......@@ -296,7 +296,7 @@ class _DetailPostPageState extends State<DetailPostPage> {
return Column(
children: allKomentarPostingFromApi
.map<Widget>((k) => komentarPlaceHolder(
k.creator, k.dateTime, k.deskripsi))
k.creator, k.created, k.deskripsi))
.toList());
}
break;
......
......@@ -55,10 +55,12 @@ class KegiatanRepository implements BaseKegiatanRepository {
);
return response;
}
@override
Future<KegiatanModel> fetchDetailKegiatan(String placeId, int kegiatanId) async {
final url = '/informasi-fasilitas/lokasi/detail-kegiatan/$placeId/$kegiatanId/';
Future<KegiatanModel> fetchDetailKegiatan(
String placeId, int kegiatanId) async {
final url =
'/informasi-fasilitas/lokasi/detail-kegiatan/$placeId/$kegiatanId/';
final response = await _network.get(url: url, isLogin: false);
var kegiatan = KegiatanModel.fromJson(response);
kegiatan.image = await fetchImages(kegiatan.placeId, kegiatan.id);
......
......@@ -9,13 +9,13 @@ void main() {
'id': 1,
'deskripsi': 'This is a test',
'creator': 'Test',
'date_time': '2020-11-18 00:13:52.939668'
'created': '18-11-2020 00:13:52'
};
final returnKomentarPostingData = {
'id': 1,
'deskripsi': 'This is a test',
'creator': 'Test',
'date_time': '2020-11-18T00:13:00.000'
'created': '2020-11-18T00:13:00.000'
};
final userData = {
'is_login': true,
......@@ -36,7 +36,7 @@ void main() {
'deskripsi':
'Ada toilet khusus disabilitas terletak di lantai 2 dekat kintan',
'creator': '',
'date_time': '2020-11-18 00:13:52.939668',
'date_time': '18-11-2020 00:13:52',
'rating': 3,
'tag': 'KR',
'disabilitas': ['DF'],
......@@ -77,7 +77,7 @@ void main() {
id: 2,
deskripsi: 'This is a test',
creator: 'Test',
dateTime: DateTime.now());
created: DateTime.now());
expect(komentarPostingModel, isInstanceOf<KomentarPostingModel>());
expect(
komentarPostingWithConstructor, isInstanceOf<KomentarPostingModel>());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment